ctxpropagation

package
v0.0.0-...-94a9b73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

This sample Workflow demos context propagation through a Workflow. Details about context propagation are available here.

The sample Workflow initializes the client with a context propagator which propagates specific information in the context.Context object across the Workflow. The context.Context object is populated with the information prior to calling StartWorkflow. The Workflow demonstrates that the information is available in the Workflow and any activities executed.

Also, this sample initializes a Jaeger global tracer and pass it to the client. The sample will work without actual Jaeger instance -- just report every tracer call to the log. To see traces in Jaeger run it with follow command:

$ docker run --publish 6831:6831 --publish 16686:16686 jaegertracing/all-in-one:latest

Steps to run this sample:

  1. You need a Temporal service running. See details README.md.
  2. Run
go run ctxpropagation/worker/main.go

to start worker for ctxpropagation Workflow.

  1. Run:
go run ctxpropagation/starter/main.go

to start Workflow.

You should see prints showing the context information available in the workflow and activities.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PropagateKey = contextKey{}

PropagateKey is the key used to store the value in the Context object

Functions

func CtxPropWorkflow

func CtxPropWorkflow(ctx workflow.Context) (err error)

CtxPropWorkflow workflow definition

func NewContextPropagator

func NewContextPropagator() workflow.ContextPropagator

NewContextPropagator returns a context propagator that propagates a set of string key-value pairs across a workflow

func SetJaegerGlobalTracer

func SetJaegerGlobalTracer() io.Closer

Types

type Values

type Values struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Values is a struct holding values

func SampleActivity

func SampleActivity(ctx context.Context) (*Values, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL