diff --git a/ctxpropagation/activities.go b/ctxpropagation/activities.go index d30aabd4..7e343234 100644 --- a/ctxpropagation/activities.go +++ b/ctxpropagation/activities.go @@ -4,6 +4,7 @@ import ( "context" ) +// @@@SNIPSTART samples-go-ctx-propagation-activity func SampleActivity(ctx context.Context) (*Values, error) { if val := ctx.Value(PropagateKey); val != nil { vals := val.(Values) @@ -11,3 +12,4 @@ func SampleActivity(ctx context.Context) (*Values, error) { } return nil, nil } +// @@@SNIPEND diff --git a/ctxpropagation/propagator.go b/ctxpropagation/propagator.go index dec1eaf3..455292d6 100644 --- a/ctxpropagation/propagator.go +++ b/ctxpropagation/propagator.go @@ -7,6 +7,7 @@ import ( "go.temporal.io/sdk/workflow" ) +// @@@SNIPSTART samples-go-ctx-propagation-propagator type ( // contextKey is an unexported type used as key for items stored in the // Context object @@ -69,6 +70,7 @@ func (s *propagator) Extract(ctx context.Context, reader workflow.HeaderReader) return ctx, nil } +// @@@SNIPEND // ExtractToWorkflow extracts values from headers and puts them into context func (s *propagator) ExtractToWorkflow(ctx workflow.Context, reader workflow.HeaderReader) (workflow.Context, error) { diff --git a/ctxpropagation/starter/main.go b/ctxpropagation/starter/main.go index b2b07034..77bc156d 100644 --- a/ctxpropagation/starter/main.go +++ b/ctxpropagation/starter/main.go @@ -24,6 +24,7 @@ func main() { log.Fatalf("Failed creating interceptor: %v", err) } + // @@@SNIPSTART samples-go-ctx-propagation-starter // The client is a heavyweight object that should be created once per process. c, err := client.Dial(client.Options{ HostPort: client.DefaultHostPort, @@ -45,6 +46,7 @@ func main() { ctx = context.WithValue(ctx, ctxpropagation.PropagateKey, &ctxpropagation.Values{Key: "test", Value: "tested"}) we, err := c.ExecuteWorkflow(ctx, workflowOptions, ctxpropagation.CtxPropWorkflow) + // @@@SNIPEND if err != nil { log.Fatalln("Unable to execute workflow", err) } diff --git a/ctxpropagation/workflow.go b/ctxpropagation/workflow.go index b0121956..07ac7a31 100644 --- a/ctxpropagation/workflow.go +++ b/ctxpropagation/workflow.go @@ -6,6 +6,7 @@ import ( "go.temporal.io/sdk/workflow" ) +// @@@SNIPSTART samples-go-ctx-propagation-workflow // CtxPropWorkflow workflow definition func CtxPropWorkflow(ctx workflow.Context) (err error) { ao := workflow.ActivityOptions{ @@ -27,3 +28,4 @@ func CtxPropWorkflow(ctx workflow.Context) (err error) { workflow.GetLogger(ctx).Info("Workflow completed.") return nil } +// @@@SNIPEND