We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Badaas needs some to run some code periodically, such as the session cache refresh function.
I propose to create an interface
type Routine interface { // Start the routine Start() error // Stop the routines Stop() error // Return the name of the routine. Name() string }
since we use https://github.com/uber-go/fx it should be easy to create a lifecycle hook that manage collected routines.
func StartRoutine(lc fx.Lifecycle, routines []Routine) { lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { for routine := range routines { err := routine.Start() if err != nil { return fmt.Errorf("en error happened while starting routine %q. error=%w", routine.Name(), err) } } return nil }, OnStop: func(ctx context.Context) error { for routine := range routines { err := routine.Stop() if err != nil { return fmt.Errorf("en error happened while stopping routine %q. error=%w", routine.Name(), err) } } }, }) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Badaas needs some to run some code periodically, such as the session cache refresh function.
I propose to create an interface
since we use https://github.com/uber-go/fx it should be easy to create a lifecycle hook that manage collected routines.
The text was updated successfully, but these errors were encountered: