Skip to content

Commit

Permalink
fix: set cron request key header before calling (#3801)
Browse files Browse the repository at this point in the history
Fixes #3724
  • Loading branch information
wesbillman authored Dec 18, 2024
1 parent f5cb63d commit 0fca476
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/cron/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/block/ftl/internal/log"
"github.com/block/ftl/internal/model"
"github.com/block/ftl/internal/routing"
"github.com/block/ftl/internal/rpc/headers"
"github.com/block/ftl/internal/schema/schemaeventsource"
)

Expand Down Expand Up @@ -111,11 +112,17 @@ func callCronJob(ctx context.Context, verbClient routing.CallClient, cronJob cro
logger := log.FromContext(ctx).Scope("cron")
ref := schema.Ref{Module: cronJob.module, Name: cronJob.verb.Name}
logger.Debugf("Calling cron job %s", cronJob)
resp, err := verbClient.Call(ctx, connect.NewRequest(&ftlv1.CallRequest{

req := connect.NewRequest(&ftlv1.CallRequest{
Verb: ref.ToProto(),
Body: []byte(`{}`),
Metadata: &ftlv1.Metadata{},
}))
})

requestKey := model.NewRequestKey(model.OriginCron, schema.RefKey{Module: ref.Module, Name: ref.Name}.String())
headers.SetRequestKey(req.Header(), requestKey)

resp, err := verbClient.Call(ctx, req)
if err != nil {
return fmt.Errorf("%s: call to cron job failed: %w", ref, err)
}
Expand Down

0 comments on commit 0fca476

Please sign in to comment.