You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When triggering a projection schedule, the values provided with the Context are not available in the projection.Job (which is also a Context). This is because the projection schedules create a fresh Context for each projection job, and the Context passed to Schedule.Trigger() is only used to be able to cancel the trigger itself (not the projection job).
If projection jobs provided the values from the trigger context, it would be possible to provide dynamic options to a projection job.
Example
package example
import (
"context""time""github.com/modernice/goes/projection""github.com/modernice/goes/projection/schedule"
)
funcexample() {
s:= schedule.Continuously(...) // setup the projection schedulegos.Subscribe(context.Background(), applyJob)
// wait a bit, then trigger the projection
time.Sleep(3*time.Second)
ctx:=context.WithValue(context.Background(), "key", "value")
s.Trigger(ctx)
}
funcapplyJob(ctx projection.Job) error {
v:=ctx.Value("key") // <- this currently returns null, should return "value"returnnil
}
The text was updated successfully, but these errors were encountered:
When triggering a projection schedule, the values provided with the
Context
are not available in theprojection.Job
(which is also aContext
). This is because the projection schedules create a fresh Context for each projection job, and the Context passed toSchedule.Trigger()
is only used to be able to cancel the trigger itself (not the projection job).If projection jobs provided the values from the trigger context, it would be possible to provide dynamic options to a projection job.
Example
The text was updated successfully, but these errors were encountered: