Skip to content

Latest commit

 

History

History

crontab

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Crontab

Example

package main

import (
	"context"

	"github.com/flc1125/go-cron/v4"
	"github.com/go-fries/fries/crontab/v3"
	"github.com/go-kratos/kratos/v2"
)

func main() {
	c := cron.New(
		cron.WithSeconds(),
		cron.WithMiddleware( /*...*/ ),
	)

	_, _ = c.AddFunc("* * * * * *", func(context.Context) error {
		// do something
		return nil
	})

	// kratos app start
	app := kratos.New(
		kratos.Server(
			crontab.NewServer(c),
		),
	)

	err := app.Run()
	if err != nil {
		panic(err)
	}
}