Skip to content

Commit

Permalink
specify ScheduledAt since it's included in CreateAsyncCall and sqlc d…
Browse files Browse the repository at this point in the history
…efaults to zero
  • Loading branch information
safeer committed Aug 22, 2024
1 parent 26f6294 commit 27c5c20
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/controller/cronjobs/cronjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ func (s *Service) scheduleCronJob(ctx context.Context, tx *Tx, job model.CronJob

logger.Tracef("Scheduling cron job %q async_call execution at %s", job.Key, nextAttemptForJob)
_, err = tx.db.CreateAsyncCall(ctx, cronsql.CreateAsyncCallParams{
ScheduledAt: nextAttemptForJob,
Verb: schema.RefKey{Module: job.Verb.Module, Name: job.Verb.Name},
Origin: fmt.Sprintf("cron:%s", job.Key),
Request: []byte(`{}`),
RemainingAttempts: 0,
Backoff: 0,
MaxBackoff: 0,
CronJobKey: optional.Some(job.Key),
ScheduledAt: nextAttemptForJob,
})
if err != nil {
return fmt.Errorf("failed to create async call for job %q: %w", job.Key, err)
Expand Down
1 change: 1 addition & 0 deletions backend/controller/dal/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (d *DAL) StartFSMTransition(ctx context.Context, fsm schema.RefKey, instanc
// Create an async call for the event.
origin := AsyncOriginFSM{FSM: fsm, Key: instanceKey}
asyncCallID, err := d.db.CreateAsyncCall(ctx, sql.CreateAsyncCallParams{
ScheduledAt: time.Now(),
Verb: destinationState,
Origin: origin.String(),
Request: encryptedRequest,
Expand Down
1 change: 1 addition & 0 deletions backend/controller/dal/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (d *DAL) ProgressSubscriptions(ctx context.Context, eventConsumptionDelay t
}

_, err = tx.db.CreateAsyncCall(ctx, sql.CreateAsyncCallParams{
ScheduledAt: time.Now(),
Verb: subscriber.Sink,
Origin: origin.String(),
Request: nextCursor.Payload, // already encrypted
Expand Down

0 comments on commit 27c5c20

Please sign in to comment.