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

Support ticker-tasks as methods on modules rather than requiring separate implementing classes. #4171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scr-oath
Copy link
Contributor

@scr-oath scr-oath commented Jan 21, 2025

The motivational use-case for this is to add multiple tickers for a module. By including a RunnerFunc as an implementer of Runner, this will allow, for instance something like this:

type MyModule struct {}

func (m *MyModule) RunOneTask() error {
    // do something
    return nil
}

func (m *MyModule) RunAnotherTask() error {
    // do something else
    return nil
}

func BuildMyModule(_ json.RawMessage, _ moduledeps.ModuleDeps) (interface{}, error) {
    ret := &MyModule{}
    task.NewTickerTask(1 * time.Minute, runner.RunnerFunc(ret.RunOneTask))
    task.NewTickerTask(2 * time.Minute, runner.RunnerFunc(ret.RunAnotherTask))
    return ret, nil
}

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

Successfully merging this pull request may close these issues.

1 participant