finnlee87 / go-job-lite

distributed scheduler job for golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-job-lite

Install

go get com.github/finnlee87/go-job-lite

Go Version Join the chat at https://gitter.im/finn87/go-job-lite

How to use

1. init database

execute db/init.sql in mysql db.

2. modify config/default.yml in the project.

3. Write code like example.

func main() {
	jobEngine := engine.Default()
	jobEngine.Register(ExampleJob{})
	jobEngine.Run()

	ch := make(chan string)
	<-ch
}

Job must implement BaseJob

type ExampleJob struct {

}

func (example ExampleJob) Name() string {
	return "example-job"
}

func (example ExampleJob) Cron() string  {
	return "0/1 * * * * * *"
}

func (example ExampleJob) Execute() error {
	lib.Logger.Infoln("example job run.")
	return nil
}

About

distributed scheduler job for golang

License:Apache License 2.0


Languages

Language:Go 100.0%