Skip to content

Commit

Permalink
Add note for context-aware data converters (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz committed Jan 31, 2022
1 parent 37f56f0 commit 4915b0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions internal/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ type (
ExtractToWorkflow(Context, HeaderReader) (Context, error)
}

// ContextAware is an optional interface that can be implemented alongside DataConverter.
// This interface allows Temporal to pass Workflow/Activity contexts to the DataConverter
// so that it may tailor it's behaviour.
// ContextAware is an optional interface that can be implemented alongside
// DataConverter. This interface allows Temporal to pass Workflow/Activity
// contexts to the DataConverter so that it may tailor it's behaviour.
//
// Note that data converters may be called in non-context-aware situations to
// convert payloads that may not be customized per context. Data converter
// implementers should not expect or require contextual data be present.
ContextAware interface {
WithWorkflowContext(ctx Context) converter.DataConverter
WithContext(ctx context.Context) converter.DataConverter
Expand Down
10 changes: 7 additions & 3 deletions workflow/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ import (
// Context's methods may be called by multiple goroutines simultaneously.
type Context = internal.Context

// ContextAware is an optional interface that can be implemented alongside DataConverter.
// This interface allows Temporal to pass Workflow/Activity contexts to the DataConverter
// so that it may tailor it's behaviour.
// ContextAware is an optional interface that can be implemented alongside
// DataConverter. This interface allows Temporal to pass Workflow/Activity
// contexts to the DataConverter so that it may tailor it's behaviour.
//
// Note that data converters may be called in non-context-aware situations to
// convert payloads that may not be customized per context. Data converter
// implementers should not expect or require contextual data be present.
type ContextAware = internal.ContextAware

// ErrCanceled is the error returned by Context.Err when the context is canceled.
Expand Down

0 comments on commit 4915b0c

Please sign in to comment.