-
Notifications
You must be signed in to change notification settings - Fork 1
Scheduled job worker #106
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
Scheduled job worker #106
Conversation
|
@@ -110,6 +114,16 @@ func New(ctx context.Context, opts ...Option) (c *Client, err error) { | |||
} | |||
} | |||
|
|||
c.config.RiverConf.PeriodicJobs = append(c.config.RiverConf.PeriodicJobs, | |||
river.NewPeriodicJob( | |||
river.PeriodicInterval(1*time.Minute), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be configurable? I am thinking a default of maybe 3-4 minutes might be better
// DatabaseHost for connecting to the postgres database | ||
// This is for the core server database which can potentially be different from | ||
// river queue's | ||
DatabaseHost string `koanf:"databaseHost" json:"databaseHost" default:"postgres://postgres:password@0.0.0.0:5432/jobs?sslmode=disable"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already defined in the main river config: https://github.com/theopenlane/riverboat/blob/6d676116ba67bd3b1a38ae08b8f45c4a1f9f58b0/internal/river/config.go#L11C2-L11C14
Although the comment makes me think you want core
instead of jobs
? If that is the case - we shouldn't allow river to directly connect to the database.
g.SetLimit(maxConcurrentJobs) | ||
|
||
for { | ||
query := ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the API for this instead? This is potentially fragile and ideally river doesn't need direct DB access to core
|
||
// Work evaluates the available jobs and marks them as ready to be executed by agents if needed | ||
func (s *ScheduledJobWorker) Work(ctx context.Context, _ *river.Job[ScheduledJobArgs]) error { | ||
if err := s.validateConnection(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of querying the API - can we just insert a job from core
in a hook
with the cron config and let river handle all the scheduling?
this is moving into core now |
schedule_job_runs
so an agent can pick upruns
table can potentially get bloated. So every run that has it's exectution time in the past gets cleaned upecho {{ .URL }}
and in your config on the dashboard, you define{"ssl" : { "url" : "https://theopenlane.io"}
, now{{.URL}}
in your script will be replaced before the agent picks up to run