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

fix: set cron request key header before calling #3801

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading