Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: Middleware for a single job supports configuring some names, etc. #37

Open
flc1125 opened this issue Nov 2, 2024 · 0 comments

Comments

@flc1125
Copy link
Owner

flc1125 commented Nov 2, 2024

ex:

package main

import (
	"context"
	"log"
	"time"

	"github.com/flc1125/go-cron/v4"
	"github.com/flc1125/go-cron/v4/middleware/recovery"
)

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

	c.AddFunc("* * * * * *", func(ctx context.Context) error {
		log.Println("hello")
		return nil
	})
	c.AddFunc("* * * * * *", func(ctx context.Context) error {
		log.Println("world")
		return nil
	}, cron.WithName("world"))
	
	c.Start()
	defer c.Stop()
	
	time.Sleep(time.Second * 10)
}
@flc1125 flc1125 changed the title Middleware for a single job supports configuring some names, etc. proposal: Middleware for a single job supports configuring some names, etc. Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant