Skip to content

Commit f578fed

Browse files
Add documentation for propagators and how they are executed (#1312)
Clarify behavior on return of error Document the whole execution sequence Docs added to both internal package and exposed type alias due to: golang/go#44905 Signed-off-by: Alexander Shopov <[email protected]> Co-authored-by: David Porter <[email protected]>
1 parent ba7fa67 commit f578fed

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

internal/headers.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,24 @@ type HeaderReader interface {
3636
ForEachKey(handler func(string, []byte) error) error
3737
}
3838

39-
// ContextPropagator is an interface that determines what information from
40-
// context to pass along
39+
// ContextPropagator determines what information from context to pass along.
40+
//
41+
// The information passed is called Headers - a sequence of string to []byte
42+
// tuples of serialized data that should follow workflow and activity execution
43+
// around.
44+
//
45+
// Inject* methods are used on the way from the process to persistence in
46+
// Cadence - thus they use HeaderWriter-s to write the metadata. Extract*
47+
// methods are used on the way from persisted state in Cadence to execution
48+
// - thus they use HeaderReader-s to read the metadata and fill it in the
49+
// returned context. Returning error from Extract* methods prevents the
50+
// successful workflow run.
51+
//
52+
// The whole sequence of execution is:
53+
//
54+
// Process initiating the workflow -> Inject -> Cadence -> Go Workflow Worker
55+
// -> ExtractToWorkflow -> Start executing a workflow -> InjectFromWorkflow ->
56+
// Cadence -> Go Activity Worker -> Extract -> Execute Activity
4157
type ContextPropagator interface {
4258
// Inject injects information from a Go Context into headers
4359
Inject(context.Context, HeaderWriter) error

workflow/context_propagator.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,23 @@ type (
2929
// HeaderWriter is an interface to write information to cadence headers
3030
HeaderWriter = internal.HeaderWriter
3131

32-
// ContextPropagator is an interface that determines what information from
33-
// context to pass along
32+
// ContextPropagator determines what information from context to pass along.
33+
//
34+
// The information passed is called Headers - a sequence of string to []byte
35+
// tuples of serialized data that should follow workflow and activity execution
36+
// around.
37+
//
38+
// Inject* methods are used on the way from the process to persistence in
39+
// Cadence - thus they use HeaderWriter-s to write the metadata. Extract*
40+
// methods are used on the way from persisted state in Cadence to execution
41+
// - thus they use HeaderReader-s to read the metadata and fill it in the
42+
// returned context. Returning error from Extract* methods prevents the
43+
// successful workflow run.
44+
//
45+
// The whole sequence of execution is:
46+
//
47+
// Process initiating the workflow -> Inject -> Cadence -> Go Workflow Worker
48+
// -> ExtractToWorkflow -> Start executing a workflow -> InjectFromWorkflow ->
49+
// Cadence -> Go Activity Worker -> Extract -> Execute Activity
3450
ContextPropagator = internal.ContextPropagator
3551
)

0 commit comments

Comments
 (0)