Documentation
¶
Overview ¶
Package chasm is a generated GoMock package.
Package chasm is a generated GoMock package.
Package chasm is a generated GoMock package.
Package chasm is a generated GoMock package.
Package chasm is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ContextWithValue[C Context](c C, key any, value any) C
- func DeleteExecution[C RootComponent](ctx context.Context, key ExecutionKey, request DeleteExecutionRequest) error
- func ExecutionStateChanged(c Component, ctx Context, refBytes []byte) (bool, error)
- func FullyQualifiedName(libName, name string) string
- func GenerateNexusCallback(serializedRef []byte, requestID string, encodeToken bool) (*commonpb.Callback, error)
- func GenerateTypeID(fqn string) uint32
- func NewContextWithOperationIntent(ctx context.Context, intent OperationIntent) context.Context
- func NewEngineContext(ctx context.Context, engine Engine) context.Context
- func NewVisibilityManagerContext(ctx context.Context, engine VisibilityManager) context.Context
- func PollComponent[C any, R []byte | ComponentRef, I any, O any](ctx context.Context, r R, ...) (O, []byte, error)
- func ReadComponent[C any, R []byte | ComponentRef, I any, O any](ctx context.Context, r R, readFn func(C, Context, I) (O, error), input I, ...) (O, error)
- func SearchAttributeValue[T any](m SearchAttributesMap, sa typedSearchAttribute[T]) (val T, ok bool)
- func UnpackNexusCallbackToken(encoded string) (componentRef []byte, requestID string, err error)
- func UpdateComponent[C any, R []byte | ComponentRef, I any, O any](ctx context.Context, r R, updateFn func(C, MutableContext, I) (O, error), ...) (O, []byte, error)
- type Archetype
- type ArchetypeID
- type BusinessIDConflictPolicy
- type BusinessIDReusePolicy
- type ChasmEngineInterceptor
- type ChasmVisibilityInterceptor
- type ClusterLocalStateMergeResult
- type Component
- type ComponentFieldOption
- type ComponentRef
- func DeserializeComponentRef(data []byte) (ComponentRef, error)
- func NewComponentRef[C Component](executionKey ExecutionKey) ComponentRef
- func NewComponentRefByArchetypeID(executionKey ExecutionKey, archetypeID ArchetypeID) ComponentRef
- func ProtoRefToComponentRef(pRef *persistencespb.ChasmComponentRef) ComponentRef
- type Context
- type CoreLibrary
- type CountExecutionsRequest
- type CountExecutionsResponse
- type DeleteExecutionRequest
- type EndpointRegistry
- type Engine
- type EngineUpdateWithStartExecutionResult
- type ExecutionAlreadyStartedError
- type ExecutionInfo
- type ExecutionKey
- type Field
- func ComponentPointerTo[C Component](ctx MutableContext, c C) Field[C]
- func DataPointerTo[D proto.Message](ctx MutableContext, d D) Field[D]
- func NewComponentField[C Component](ctx MutableContext, c C, options ...ComponentFieldOption) Field[C]
- func NewDataField[D proto.Message](ctx MutableContext, d D) Field[D]
- func NewEmptyField[T any]() Field[T]
- type Group
- type Library
- type LifecycleState
- type ListExecutionsRequest
- type ListExecutionsResponse
- type MSPointer
- func (m MSPointer) AddHistoryEvent(t enumspb.EventType, setAttributes func(*historypb.HistoryEvent)) *historypb.HistoryEvent
- func (m MSPointer) GenerateEventLoadToken(event *historypb.HistoryEvent) ([]byte, error)
- func (m MSPointer) GetNexusCompletion(ctx Context, requestID string) (nexusrpc.CompleteOperationOptions, error)
- func (m MSPointer) GetNexusUpdateCompletion(ctx Context, updateID string, requestID string) (nexusrpc.CompleteOperationOptions, error)
- func (m MSPointer) GetWorkflowTypeName() string
- func (m MSPointer) HasAnyBufferedEvent(filter func(*historypb.HistoryEvent) bool) bool
- func (m MSPointer) LoadHistoryEvent(ctx Context, token []byte) (*historypb.HistoryEvent, error)
- func (m MSPointer) WorkflowRunTimeout() time.Duration
- type Map
- type MockComponent
- type MockComponentMockRecorder
- type MockContext
- func (c *MockContext) EndpointByName(name string) (*persistencespb.NexusEndpointEntry, error)
- func (c *MockContext) ExecutionInfo() ExecutionInfo
- func (c *MockContext) ExecutionKey() ExecutionKey
- func (c *MockContext) Links(component Component) []*commonpb.Link
- func (c *MockContext) Logger() log.Logger
- func (c *MockContext) MetricsHandler() metrics.Handler
- func (c *MockContext) NamespaceEntry() *namespace.Namespace
- func (c *MockContext) Now(cmp Component) time.Time
- func (c *MockContext) Ref(cmp Component) ([]byte, error)
- func (c *MockContext) RegisterComponentContextValues(keyValues map[any]any)
- func (c *MockContext) RequestHeader(key string) string
- func (c *MockContext) RequestLinks(component Component, requestID string) ([]*commonpb.Link, error)
- func (c *MockContext) UserMetadata(component Component) *sdkpb.UserMetadata
- func (c *MockContext) Value(key any) any
- type MockEngine
- func (m *MockEngine) DeleteExecution(arg0 context.Context, arg1 ComponentRef, arg2 DeleteExecutionRequest) error
- func (m *MockEngine) EXPECT() *MockEngineMockRecorder
- func (m *MockEngine) NotifyExecution(arg0 ExecutionKey)
- func (m *MockEngine) PollComponent(arg0 context.Context, arg1 ComponentRef, ...) ([]byte, error)
- func (m *MockEngine) ReadComponent(arg0 context.Context, arg1 ComponentRef, arg2 func(Context, Component) error, ...) error
- func (m *MockEngine) StartExecution(arg0 context.Context, arg1 ComponentRef, ...) (StartExecutionResult, error)
- func (m *MockEngine) UpdateComponent(arg0 context.Context, arg1 ComponentRef, ...) ([]byte, error)
- func (m *MockEngine) UpdateWithStartExecution(arg0 context.Context, arg1 ComponentRef, ...) (EngineUpdateWithStartExecutionResult, error)
- type MockEngineMockRecorder
- func (mr *MockEngineMockRecorder) DeleteExecution(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockEngineMockRecorder) NotifyExecution(arg0 any) *gomock.Call
- func (mr *MockEngineMockRecorder) PollComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
- func (mr *MockEngineMockRecorder) ReadComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
- func (mr *MockEngineMockRecorder) StartExecution(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
- func (mr *MockEngineMockRecorder) UpdateComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
- func (mr *MockEngineMockRecorder) UpdateWithStartExecution(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call
- type MockLibrary
- func (m *MockLibrary) Components() []*RegistrableComponent
- func (m *MockLibrary) EXPECT() *MockLibraryMockRecorder
- func (m *MockLibrary) Name() string
- func (m *MockLibrary) NexusServiceProcessors() []*NexusServiceProcessor
- func (m *MockLibrary) NexusServices() []*nexus.Service
- func (m *MockLibrary) RegisterServices(server *grpc.Server)
- func (m *MockLibrary) Tasks() []*RegistrableTask
- type MockLibraryMockRecorder
- func (mr *MockLibraryMockRecorder) Components() *gomock.Call
- func (mr *MockLibraryMockRecorder) Name() *gomock.Call
- func (mr *MockLibraryMockRecorder) NexusServiceProcessors() *gomock.Call
- func (mr *MockLibraryMockRecorder) NexusServices() *gomock.Call
- func (mr *MockLibraryMockRecorder) RegisterServices(server any) *gomock.Call
- func (mr *MockLibraryMockRecorder) Tasks() *gomock.Call
- type MockMutableContext
- func (c *MockMutableContext) AddTask(component Component, attributes TaskAttributes, payload any)
- func (c *MockMutableContext) SetRequestLinks(component Component, requestID string, links []*commonpb.Link) error
- func (c *MockMutableContext) SetUserMetadata(component Component, md *sdkpb.UserMetadata) error
- type MockNodeBackend
- func (m *MockNodeBackend) AddHistoryEvent(t enumspb.EventType, setAttributes func(*historypb.HistoryEvent)) *historypb.HistoryEvent
- func (m *MockNodeBackend) AddTasks(ts ...tasks.Task)
- func (m *MockNodeBackend) ChasmSkipPersistenceEnabled() bool
- func (m *MockNodeBackend) CurrentVersionedTransition() *persistencespb.VersionedTransition
- func (m *MockNodeBackend) DeleteCHASMPureTasks(maxScheduledTime time.Time)
- func (m *MockNodeBackend) EndpointRegistry() EndpointRegistry
- func (m *MockNodeBackend) GenerateEventLoadToken(event *historypb.HistoryEvent) ([]byte, error)
- func (m *MockNodeBackend) GetApproximatePersistedSize() int
- func (m *MockNodeBackend) GetCurrentVersion() int64
- func (m *MockNodeBackend) GetExecutionInfo() *persistencespb.WorkflowExecutionInfo
- func (m *MockNodeBackend) GetExecutionState() *persistencespb.WorkflowExecutionState
- func (m *MockNodeBackend) GetNamespaceEntry() *namespace.Namespace
- func (m *MockNodeBackend) GetNexusCompletion(ctx context.Context, requestID string) (nexusrpc.CompleteOperationOptions, error)
- func (m *MockNodeBackend) GetNexusUpdateCompletion(ctx context.Context, updateID string, requestID string) (nexusrpc.CompleteOperationOptions, error)
- func (m *MockNodeBackend) GetWorkflowKey() definition.WorkflowKey
- func (m *MockNodeBackend) HasAnyBufferedEvent(filter func(*historypb.HistoryEvent) bool) bool
- func (m *MockNodeBackend) IsWorkflow() bool
- func (m *MockNodeBackend) LastDeletePureTaskCall() time.Time
- func (m *MockNodeBackend) LastUpdateWorkflowState() enumsspb.WorkflowExecutionState
- func (m *MockNodeBackend) LastUpdateWorkflowStatus() enumspb.WorkflowExecutionStatus
- func (m *MockNodeBackend) LoadHistoryEvent(ctx context.Context, token []byte) (*historypb.HistoryEvent, error)
- func (m *MockNodeBackend) NextTransitionCount() int64
- func (m *MockNodeBackend) NumTasksAdded() int
- func (m *MockNodeBackend) UpdateWorkflowStateStatus(state enumsspb.WorkflowExecutionState, status enumspb.WorkflowExecutionStatus) (bool, error)
- type MockNodePureTask
- type MockPureTaskHandler
- func (m *MockPureTaskHandler[C, T]) EXPECT() *MockPureTaskHandlerMockRecorder[C, T]
- func (m *MockPureTaskHandler[C, T]) Execute(arg0 MutableContext, arg1 C, arg2 TaskAttributes, arg3 T) error
- func (m *MockPureTaskHandler[C, T]) Validate(arg0 Context, arg1 C, arg2 TaskInvocation, arg3 T) (bool, error)
- type MockPureTaskHandlerMockRecorder
- type MockRootComponent
- func (m *MockRootComponent) ContextMetadata(arg0 Context) map[string]string
- func (m *MockRootComponent) EXPECT() *MockRootComponentMockRecorder
- func (m *MockRootComponent) LifecycleState(arg0 Context) LifecycleState
- func (m *MockRootComponent) Terminate(arg0 MutableContext, arg1 TerminateComponentRequest) (TerminateComponentResponse, error)
- type MockRootComponentMockRecorder
- type MockSideEffectTaskHandler
- func (m *MockSideEffectTaskHandler[C, T]) Discard(arg0 context.Context, arg1 ComponentRef, arg2 TaskAttributes, arg3 T) error
- func (m *MockSideEffectTaskHandler[C, T]) EXPECT() *MockSideEffectTaskHandlerMockRecorder[C, T]
- func (m *MockSideEffectTaskHandler[C, T]) Execute(arg0 context.Context, arg1 ComponentRef, arg2 TaskAttributes, arg3 T) error
- func (m *MockSideEffectTaskHandler[C, T]) Validate(arg0 Context, arg1 C, arg2 TaskInvocation, arg3 T) (bool, error)
- type MockSideEffectTaskHandlerMockRecorder
- func (mr *MockSideEffectTaskHandlerMockRecorder[C, T]) Discard(arg0, arg1, arg2, arg3 any) *gomock.Call
- func (mr *MockSideEffectTaskHandlerMockRecorder[C, T]) Execute(arg0, arg1, arg2, arg3 any) *gomock.Call
- func (mr *MockSideEffectTaskHandlerMockRecorder[C, T]) Validate(arg0, arg1, arg2, arg3 any) *gomock.Call
- type MockTask
- type MockTaskValidator
- type MockTaskValidatorMockRecorder
- type MockTerminableComponent
- type MockTerminableComponentMockRecorder
- type MockVisibilityManager
- func (m *MockVisibilityManager) CountExecutions(arg0 context.Context, arg1 reflect.Type, arg2 *CountExecutionsRequest) (*visibilityservice.CountChasmExecutionsResponse, error)
- func (m *MockVisibilityManager) EXPECT() *MockVisibilityManagerMockRecorder
- func (m *MockVisibilityManager) ListExecutions(arg0 context.Context, arg1 reflect.Type, arg2 *ListExecutionsRequest) (*visibilityservice.ListChasmExecutionsResponse, error)
- type MockVisibilityManagerMockRecorder
- type Mocknamer
- type MocknamerMockRecorder
- type MutableContext
- type NexusCompletionHandler
- type NexusEndpointProcessor
- func (p *NexusEndpointProcessor) MustRegisterServiceProcessor(processor *NexusServiceProcessor)
- func (p *NexusEndpointProcessor) ProcessInput(ctx NexusOperationProcessorContext, service, operation string, ...) (*NexusOperationProcessorResult, error)
- func (p *NexusEndpointProcessor) RegisterServiceProcessor(processor *NexusServiceProcessor) error
- type NexusOperationProcessor
- type NexusOperationProcessorContext
- type NexusOperationProcessorResult
- type NexusOperationRoutingKey
- type NexusOperationRoutingKeyExecution
- type NexusOperationRoutingKeyRandom
- type NexusServiceProcessor
- func (p *NexusServiceProcessor) MustRegisterOperation(name string, op RegisterableNexusOperationProcessor)
- func (p *NexusServiceProcessor) ProcessInput(ctx NexusOperationProcessorContext, opName string, input *commonpb.Payload) (*NexusOperationProcessorResult, error)
- func (p *NexusServiceProcessor) RegisterOperation(name string, op RegisterableNexusOperationProcessor) error
- type NoValue
- type Node
- func (n *Node) AddTask(component Component, taskAttributes TaskAttributes, task any)
- func (n *Node) ApplyMutation(mutation NodesMutation) error
- func (n *Node) ApplySnapshot(incomingSnapshot NodesSnapshot) error
- func (n *Node) ApplySystemMutation(mutation NodesMutation) error
- func (n *Node) Archetype() (Archetype, error)
- func (n *Node) ArchetypeID() ArchetypeID
- func (n *Node) CloseTransaction() (NodesMutation, error)
- func (n *Node) Component(chasmContext Context, ref ComponentRef) (Component, error)
- func (n *Node) ComponentByPath(chasmContext Context, path []string) (Component, error)
- func (n *Node) EachPureTask(referenceTime time.Time, ...) error
- func (n *Node) ExecutePureTask(baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any) (_ bool, retErr error)
- func (n *Node) ExecuteSideEffectDiscardTask(ctx context.Context, executionKey ExecutionKey, chasmTask *tasks.ChasmTask, ...) error
- func (n *Node) ExecuteSideEffectTask(ctx context.Context, executionKey ExecutionKey, chasmTask *tasks.ChasmTask, ...) error
- func (n *Node) IsDirty() bool
- func (n *Node) IsStale(ref ComponentRef) error
- func (n *Node) IsStateDirty() bool
- func (n *Node) Now(_ Component) time.Time
- func (n *Node) PartitionedSnapshot(exclusiveMinVT *persistencespb.VersionedTransition) (NodesSnapshot, *persistencespb.ChasmLocalState)
- func (n *Node) Ref(component Component) ([]byte, error)
- func (n *Node) RefreshTasks() error
- func (n *Node) SetDeleteAfterClose(deleteAfterClose bool)
- func (n *Node) SetRootComponent(rootComponent RootComponent) error
- func (n *Node) Snapshot(exclusiveMinVT *persistencespb.VersionedTransition) NodesSnapshot
- func (n *Node) Terminate(request TerminateComponentRequest) error
- func (n *Node) ValidateSideEffectTask(ctx context.Context, chasmTask *tasks.ChasmTask) (isTaskInTree bool, isValidByComponent bool, retErr error)
- type NodeBackend
- type NodePathEncoder
- type NodePureTask
- type NodesMutation
- type NodesSnapshot
- type OperationIntent
- type ParentPtr
- type PureTaskHandler
- type PureTaskHandlerBase
- type RefConsistencyLevel
- type RegisterableNexusOperationProcessor
- type RegistrableComponent
- type RegistrableComponentOption
- func WithBusinessIDAlias(alias string) RegistrableComponentOption
- func WithContextValues(keyVals map[any]any) RegistrableComponentOption
- func WithDetached() RegistrableComponentOption
- func WithEphemeral() RegistrableComponentOption
- func WithSearchAttributes(searchAttributes ...SearchAttribute) RegistrableComponentOption
- func WithSingleCluster() RegistrableComponentOption
- type RegistrableTask
- type RegistrableTaskOption
- type Registry
- func (r *Registry) ArchetypeDisplayName(id ArchetypeID) (string, bool)
- func (r *Registry) ArchetypeIDOf(componentGoType reflect.Type) (ArchetypeID, bool)
- func (r *Registry) ComponentByID(id uint32) (*RegistrableComponent, bool)
- func (r *Registry) ComponentFqnByID(id uint32) (string, bool)
- func (r *Registry) ComponentIDByFqn(fqn string) (uint32, bool)
- func (r *Registry) ComponentIDFor(componentInstance any) (uint32, bool)
- func (r *Registry) NexusServices() map[string]*nexus.Service
- func (r *Registry) Register(lib Library) error
- func (r *Registry) RegisterServices(server *grpc.Server)
- func (r *Registry) TaskByID(id uint32) (*RegistrableTask, bool)
- func (r *Registry) TaskFqnByID(id uint32) (string, bool)
- func (r *Registry) TaskIDFor(taskInstance any) (uint32, bool)
- type RootComponent
- type SearchAttribute
- type SearchAttributeBool
- type SearchAttributeDateTime
- type SearchAttributeDouble
- type SearchAttributeFieldBool
- type SearchAttributeFieldDateTime
- type SearchAttributeFieldDouble
- type SearchAttributeFieldInt
- type SearchAttributeFieldKeyword
- type SearchAttributeFieldKeywordList
- type SearchAttributeFieldText
- type SearchAttributeInt
- type SearchAttributeKeyValue
- type SearchAttributeKeyword
- type SearchAttributeKeywordList
- type SearchAttributeText
- type SearchAttributesMap
- type SideEffectTaskHandler
- type SideEffectTaskHandlerBase
- type SingletonTaskMode
- type StartExecutionResult
- type StateMachine
- type TaskAttributes
- type TaskInvocation
- type TaskValidator
- type TerminableComponent
- type TerminateComponentRequest
- type TerminateComponentResponse
- type Transition
- type TransitionOption
- type TransitionOptions
- type UnimplementedComponent
- type UnimplementedLibrary
- func (UnimplementedLibrary) Components() []*RegistrableComponent
- func (UnimplementedLibrary) NexusServiceProcessors() []*NexusServiceProcessor
- func (UnimplementedLibrary) NexusServices() []*nexus.Service
- func (UnimplementedLibrary) RegisterServices(_ *grpc.Server)
- func (UnimplementedLibrary) Tasks() []*RegistrableTask
- type UpdateWithStartExecutionResult
- type Visibility
- func (v *Visibility) CustomMemo(chasmContext Context) map[string]*commonpb.Payload
- func (v *Visibility) CustomSearchAttributes(chasmContext Context) map[string]*commonpb.Payload
- func (v *Visibility) LifecycleState(_ Context) LifecycleState
- func (v *Visibility) MergeCustomMemo(mutableContext MutableContext, customMemo map[string]*commonpb.Payload)
- func (v *Visibility) MergeCustomSearchAttributes(mutableContext MutableContext, ...)
- func (v *Visibility) ReplaceCustomMemo(mutableContext MutableContext, customMemo map[string]*commonpb.Payload)
- func (v *Visibility) ReplaceCustomSearchAttributes(mutableContext MutableContext, ...)
- type VisibilityExecutionInfo
- type VisibilityManager
- type VisibilityMemoProvider
- type VisibilitySearchAttributesMapper
- func (v *VisibilitySearchAttributesMapper) Alias(field string) (string, error)
- func (v *VisibilitySearchAttributesMapper) Field(alias string) (string, error)
- func (v *VisibilitySearchAttributesMapper) IsSystemOverride(field string) bool
- func (v *VisibilitySearchAttributesMapper) OverriddenSystemFields() map[string]enumspb.IndexedValueType
- func (v *VisibilitySearchAttributesMapper) SATypeMap() map[string]enumspb.IndexedValueType
- func (v *VisibilitySearchAttributesMapper) ValueType(fieldName string) (enumspb.IndexedValueType, error)
- type VisibilitySearchAttributesProvider
- type VisibilityValue
- type VisibilityValueBool
- type VisibilityValueFloat64
- type VisibilityValueInt64
- type VisibilityValueKeyword
- type VisibilityValueStringSlice
- type VisibilityValueText
- type VisibilityValueTime
Constants ¶
const ( CallbackLibraryName = "callback" CallbackComponentName = "callback" )
const ( SchedulerLibraryName = "scheduler" SchedulerComponentName = "scheduler" )
const ( UserMemoKey = "__user__" ChasmMemoKey = "__chasm__" )
const ( WorkflowLibraryName = "workflow" WorkflowComponentName = "workflow" )
const NexusCompletionHandlerURL = "temporal://internal"
NexusCompletionHandlerURL is the user-visible URL for Nexus->CHASM callbacks.
Variables ¶
var ( SchedulerArchetype = Archetype(FullyQualifiedName(SchedulerLibraryName, SchedulerComponentName)) SchedulerArchetypeID = ArchetypeID(GenerateTypeID(SchedulerArchetype)) )
var ( SearchAttributeFieldBool01 = newSearchAttributeFieldBool(1) SearchAttributeFieldBool02 = newSearchAttributeFieldBool(2) SearchAttributeFieldDateTime01 = newSearchAttributeFieldDateTime(1) SearchAttributeFieldDateTime02 = newSearchAttributeFieldDateTime(2) SearchAttributeFieldInt01 = newSearchAttributeFieldInt(1) SearchAttributeFieldInt02 = newSearchAttributeFieldInt(2) SearchAttributeFieldDouble01 = newSearchAttributeFieldDouble(1) SearchAttributeFieldDouble02 = newSearchAttributeFieldDouble(2) SearchAttributeFieldKeyword01 = newSearchAttributeFieldKeyword(1) SearchAttributeFieldKeyword02 = newSearchAttributeFieldKeyword(2) SearchAttributeFieldKeyword03 = newSearchAttributeFieldKeyword(3) SearchAttributeFieldKeyword04 = newSearchAttributeFieldKeyword(4) // SearchAttributeFieldLowCardinalityKeyword is a search attribute field for a low cardinality keyword value. // Used for categorical data that support GROUP BY aggregations, eg. CHASM Execution Statuses. SearchAttributeFieldLowCardinalityKeyword01 = newSearchAttributeFieldLowCardinalityKeyword(1) SearchAttributeFieldKeywordList01 = newSearchAttributeFieldKeywordList(1) SearchAttributeFieldKeywordList02 = newSearchAttributeFieldKeywordList(2) // Predefined search attributes use their system field names as aliases. // TaskQueue and ExecutionTime are system search attributes; a component may override the value // written to their system column by registering the identity-mapped attribute below and emitting // its own value from SearchAttributes(). See sadefs.IsChasmOverridableSystem. SearchAttributeTaskQueue = newSearchAttributeKeywordByField(sadefs.TaskQueue) SearchAttributeExecutionTime = newSearchAttributeDateTimeByField(sadefs.ExecutionTime) SearchAttributeTemporalChangeVersion = newSearchAttributeKeywordListByField(sadefs.TemporalChangeVersion) SearchAttributeBinaryChecksums = newSearchAttributeKeywordListByField(sadefs.BinaryChecksums) SearchAttributeBuildIds = newSearchAttributeKeywordListByField(sadefs.BuildIds) SearchAttributeBatcherNamespace = newSearchAttributeKeywordByField(sadefs.BatcherNamespace) SearchAttributeBatcherUser = newSearchAttributeKeywordByField(sadefs.BatcherUser) SearchAttributeTemporalScheduledStartTime = newSearchAttributeDateTimeByField(sadefs.TemporalScheduledStartTime) SearchAttributeTemporalScheduledByID = newSearchAttributeKeywordByField(sadefs.TemporalScheduledById) SearchAttributeTemporalSchedulePaused = newSearchAttributeBoolByField(sadefs.TemporalSchedulePaused) SearchAttributeTemporalNamespaceDivision = newSearchAttributeKeywordByField(sadefs.TemporalNamespaceDivision) SearchAttributeTemporalPauseInfo = newSearchAttributeKeywordListByField(sadefs.TemporalPauseInfo) SearchAttributeTemporalReportedProblems = newSearchAttributeKeywordListByField(sadefs.TemporalReportedProblems) SearchAttributeTemporalWorkerDeploymentVersion = newSearchAttributeKeywordByField(sadefs.TemporalWorkerDeploymentVersion) SearchAttributeTemporalWorkflowVersioningBehavior = newSearchAttributeKeywordByField(sadefs.TemporalWorkflowVersioningBehavior) SearchAttributeTemporalWorkerDeployment = newSearchAttributeKeywordByField(sadefs.TemporalWorkerDeployment) SearchAttributeTemporalUsedWorkerDeploymentVersions = newSearchAttributeKeywordListByField(sadefs.TemporalUsedWorkerDeploymentVersions) )
CHASM Search Attribute User Guide:
This contains CHASM search attribute field constants. These predefined fields correspond to the exact column name in Visibility storage. For each root component, search attributes can be mapped from a user defined alias to these fields. Each component must register its search attributes with the CHASM Registry.
To define a CHASM search attribute, create this as a package/global scoped variable. Below is an example: var testComponentCompletedSearchAttribute = NewSearchAttributeBool("Completed", SearchAttributeFieldBool01) var testComponentFailedSearchAttribute = NewSearchAttributeBool("Failed", SearchAttributeFieldBool02) var testComponentStartTimeSearchAttribute = NewSearchAttributeTime("StartTime", SearchAttributeFieldDateTime01) var testComponentCategorySearchAttribute = NewSearchAttributeLowCardinalityKeyword("Category", SearchAttributeFieldLowCardinalityKeyword01)
Each CHASM search attribute field is associated with a specific indexed value type. The Value() method of a search attribute specifies the supported value type to set at compile time. eg. DateTime values must be set with a time.Time typed value.
Low Cardinality Keyword Fields: used for categorical data that support GROUP BY aggregations. Values must be limited to a small number of dimensions.
Each root component can only use a predefined search attribute field once. Developers should not reassign aliases to different fields. Reassiging aliases to different fields will result in incorrect visibility query results.
To register these search attributes with the CHASM Registry, use the WithSearchAttributes() option when creating the component in the library. eg. NewRegistrableComponent[T]("testcomponent", WithSearchAttributes(testComponentCompletedSearchAttribute, testComponentStartTimeSearchAttribute))
var ( WorkflowArchetype = FullyQualifiedName(WorkflowLibraryName, WorkflowComponentName) WorkflowArchetypeID = GenerateTypeID(WorkflowArchetype) )
var (
CallbackComponentID = GenerateTypeID(FullyQualifiedName(CallbackLibraryName, CallbackComponentName))
)
var ErrInvalidComponentRef = serviceerror.NewInvalidArgument("invalid component ref")
ErrInvalidComponentRef is returned when component ref bytes deserialize to an invalid component ref.
var ErrInvalidRefConsistencyLevel = serviceerror.NewInvalidArgument("invalid consistency level for component ref")
ErrInvalidRefConsistencyLevel is returned when a component ref cannot be used at the requested RefConsistencyLevel.
var ErrInvalidTransition = serviceerror.NewFailedPrecondition("invalid transition")
ErrInvalidTransition is returned from Transition.Apply on an invalid state transition.
var ErrMalformedComponentRef = serviceerror.NewInvalidArgument("malformed component ref")
ErrMalformedComponentRef is returned when component ref bytes cannot be deserialized.
var ErrTaskDiscarded = errors.New("standby task pending for too long")
ErrTaskDiscarded is the error returned by the default SideEffectTaskHandlerBase Discard implementation, indicating that a side-effect task on a standby cluster has been pending past the discard delay.
var Module = fx.Module( "chasm", fx.Provide(NewRegistry), fx.Invoke(func(registry *Registry) error { return registry.Register(&CoreLibrary{}) }), )
var TaskScheduledTimeImmediate = time.Time{}
TaskScheduledTimeImmediate is the zero time value used to indicate that a task should execute immediately.
var UnimplementedComponentT = reflect.TypeFor[UnimplementedComponent]()
Functions ¶
func ContextWithValue ¶ added in v1.31.0
ContextWithValue returns a new Context with the given key-value pair added. Added key-value pairs will be accessible via the Value() method on the returned Context, and the behavior of the key-value pair is the same as context.Context.WithValue().
func DeleteExecution ¶ added in v1.31.0
func DeleteExecution[C RootComponent]( ctx context.Context, key ExecutionKey, request DeleteExecutionRequest, ) error
DeleteExecution deletes the execution identified by the supplied execution key. If the execution is still running, it is terminated first. A DeleteExecutionTask is then queued to remove all execution data from persistence.
func ExecutionStateChanged ¶ added in v1.30.0
ExecutionStateChanged returns true if execution state has advanced beyond the state encoded in refBytes. It may return ErrInvalidComponentRef or ErrMalformedComponentRef. Callers should consider converting these to serviceerror.NewInvalidArgument.
func FullyQualifiedName ¶ added in v1.31.0
FullyQualifiedName creates a fully qualified name (FQN) by combining a library name and a component or task name. The FQN is used to uniquely identify components and tasks within the CHASM framework. The format of the returned FQN is: "libName.name"
func GenerateNexusCallback ¶ added in v1.30.0
func GenerateNexusCallback(serializedRef []byte, requestID string, encodeToken bool) (*commonpb.Callback, error)
GenerateNexusCallback builds a Nexus completion callback targeting the CHASM component identified by serializedRef (obtained from Context.Ref). When encodeToken is true, the request ID is packed into the callback token (a NexusOperationCompletion envelope), so the completion is matched by a request ID that rides in the callback header and survives continue-as-new, rather than one read from mutable state. When encodeToken is false, the legacy format is emitted: the token is the bare base64-encoded ChasmComponentRef with no request ID. The caller chooses encodeToken (e.g. gated behind dynamic config) to keep the envelope format off the wire until the whole fleet can read it. Either format is always decodable by UnpackNexusCallbackToken.
func GenerateTypeID ¶ added in v1.31.0
GenerateTypeID generates a unique 32-bit identifier from a fully qualified name (FQN). The generated ID is used to uniquely identify components and tasks within the CHASM framework. The same FQN will always produce the same ID.
func NewContextWithOperationIntent ¶
func NewContextWithOperationIntent( ctx context.Context, intent OperationIntent, ) context.Context
NewContextWithOperationIntent returns a child context carrying the given OperationIntent. See OperationIntent for the access semantics.
func NewEngineContext ¶ added in v1.29.0
this will be done by the nexus handler? alternatively the engine can be a global variable, but not a good practice in fx.
func NewVisibilityManagerContext ¶ added in v1.30.0
func NewVisibilityManagerContext( ctx context.Context, engine VisibilityManager, ) context.Context
func PollComponent ¶
func PollComponent[C any, R []byte | ComponentRef, I any, O any]( ctx context.Context, r R, monotonicPredicate func(C, Context, I) (O, bool, error), input I, opts ...TransitionOption, ) (O, []byte, error)
PollComponent waits until the predicate is true when evaluated against the component identified by the supplied component reference. If this times out due to a server-imposed long-poll timeout then it returns (nil, nil, nil), as an indication that the caller should continue long-polling. Otherwise it returns (output, ref, err), where output is the output of the predicate function, and ref is a component reference identifying the state at which the predicate was satisfied. The predicate must be monotonic: if it returns true at execution state transition s then it must return true at all transitions t > s. If the predicate is true at the outset then PollComponent returns immediately. opts are currently ignored.
func ReadComponent ¶
func ReadComponent[C any, R []byte | ComponentRef, I any, O any]( ctx context.Context, r R, readFn func(C, Context, I) (O, error), input I, opts ...TransitionOption, ) (O, error)
ReadComponent returns the result of evaluating readFn against the component identified by the component reference. opts are currently ignored.
func SearchAttributeValue ¶ added in v1.31.0
func SearchAttributeValue[T any](m SearchAttributesMap, sa typedSearchAttribute[T]) (val T, ok bool)
SearchAttributeValue returns the value for a given SearchAttribute with compile-time type safety. The return type T is inferred from the SearchAttribute's type parameter. For example, SearchAttributeBool will return a bool value. If the value is not found or the type does not match, the zero value for the type T is returned and the second return value is false.
func UnpackNexusCallbackToken ¶
UnpackNexusCallbackToken decodes a callback token produced by GenerateNexusCallback, returning the component ref and request ID. It accepts both token formats regardless of how the token was written: the NexusOperationCompletion envelope, and (for backward compatibility) the legacy bare base64-encoded ChasmComponentRef, in which case the request ID is empty.
func UpdateComponent ¶
func UpdateComponent[C any, R []byte | ComponentRef, I any, O any]( ctx context.Context, r R, updateFn func(C, MutableContext, I) (O, error), input I, opts ...TransitionOption, ) (O, []byte, error)
TODO:
- consider merge with ReadComponent
- consider remove ComponentRef from the return value and allow components to get the ref in the transition function. There are some caveats there, check the comment of the NewRef method in MutableContext.
UpdateComponent applies updateFn to the component identified by the supplied component reference.
The only opts currently honored is WithRefConsistencyLevel; it selects the RefConsistencyLevel used to resolve and validate the ref (see that type for the ladder of levels). Other options are ignored.
It returns the result, along with the new component reference. The returned reference may be nil when updateFn deletes the component in the same transaction and the component is not the root component.
Types ¶
type Archetype ¶ added in v1.29.0
type Archetype = string
Archetype is the fully qualified name of the root component of a CHASM execution.
type ArchetypeID ¶ added in v1.30.0
type ArchetypeID = uint32
ArchetypeID is CHASM framework's internal ID for an Archetype.
const ( // UnspecifiedArchetypeID is a reserved special ArchetypeID value indicating that the // ArchetypeID is not specified. // This typically happens when: // 1. The chasm tree is not yet initialized with a root component, // 2. If it's a field in a persisted record, it means the record is persisted before archetypeID // was introduced (basically Workflow). UnspecifiedArchetypeID ArchetypeID = 0 )
type BusinessIDConflictPolicy ¶
type BusinessIDConflictPolicy int
const ( BusinessIDConflictPolicyFail BusinessIDConflictPolicy = iota BusinessIDConflictPolicyTerminateExisting BusinessIDConflictPolicyUseExisting )
type BusinessIDReusePolicy ¶
type BusinessIDReusePolicy int
const ( BusinessIDReusePolicyAllowDuplicate BusinessIDReusePolicy = iota BusinessIDReusePolicyAllowDuplicateFailedOnly BusinessIDReusePolicyRejectDuplicate )
type ChasmEngineInterceptor ¶ added in v1.30.0
type ChasmEngineInterceptor struct {
// contains filtered or unexported fields
}
ChasmEngineInterceptor Interceptor that intercepts RPC requests, detects CHASM-specific calls and does additional boilerplate processing before handing off. Visibility is injected separately with ChasmVisibilityInterceptor.
func ChasmEngineInterceptorProvider ¶ added in v1.30.0
func (*ChasmEngineInterceptor) Intercept ¶ added in v1.30.0
func (i *ChasmEngineInterceptor) Intercept( ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (resp any, retError error)
type ChasmVisibilityInterceptor ¶ added in v1.30.0
type ChasmVisibilityInterceptor struct {
// contains filtered or unexported fields
}
ChasmVisibilityInterceptor intercepts RPC requests and adds the CHASM VisibilityManager to their context.
func ChasmVisibilityInterceptorProvider ¶ added in v1.30.0
func ChasmVisibilityInterceptorProvider(visibilityMgr VisibilityManager) *ChasmVisibilityInterceptor
func (*ChasmVisibilityInterceptor) Intercept ¶ added in v1.30.0
func (i *ChasmVisibilityInterceptor) Intercept( ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (resp any, retError error)
type ClusterLocalStateMergeResult ¶
type ClusterLocalStateMergeResult struct {
// NodesWithUncoveredTasks counts nodes that had more tasks than stored statuses. The extra
// tasks keep their zeroed status (physicalTaskStatusNone) and get a physical task created on
// the next transaction. Benign and self-healing — typically the writer's captured state was
// slightly behind the authoritative snapshot.
NodesWithUncoveredTasks int
// NodesWithExtraStatuses counts nodes that had more stored statuses than tasks. The surplus
// statuses have no task to apply to and are dropped. Suspicious: the stored state referenced
// tasks absent from the authoritative snapshot, which can indicate cluster divergence (e.g.
// split-brain). Detecting and resolving true divergence belongs to the replication conflict
// path; this count is a diagnostic signal, not the resolution.
NodesWithExtraStatuses int
}
ClusterLocalStateMergeResult reports, per direction, how many nodes had a task/status count mismatch during MergeClusterLocalState. The two directions differ in significance, so they are tracked separately rather than as a single count.
type Component ¶
type Component interface {
LifecycleState(Context) LifecycleState
// contains filtered or unexported methods
}
type ComponentFieldOption ¶
type ComponentFieldOption func(*componentFieldOptions)
func ComponentFieldDetached ¶
func ComponentFieldDetached() ComponentFieldOption
type ComponentRef ¶
type ComponentRef struct {
ExecutionKey
// contains filtered or unexported fields
}
func DeserializeComponentRef ¶
func DeserializeComponentRef(data []byte) (ComponentRef, error)
DeserializeComponentRef deserializes a byte slice into a ComponentRef. Provides caller the access to information including ExecutionKey, Archetype, and ShardingKey.
func NewComponentRef ¶
func NewComponentRef[C Component]( executionKey ExecutionKey, ) ComponentRef
NewComponentRef creates a new ComponentRef with a registered root component go type.
In V1, if you don't have a ref, then you can only interact with the (top level) execution.
func NewComponentRefByArchetypeID ¶ added in v1.31.0
func NewComponentRefByArchetypeID( executionKey ExecutionKey, archetypeID ArchetypeID, ) ComponentRef
NewComponentRefByArchetypeID creates a new ComponentRef with a known archetype ID. This should only be used by CHASM framework internals. CHASM library developers should use NewComponentRef instead.
func ProtoRefToComponentRef ¶ added in v1.30.0
func ProtoRefToComponentRef(pRef *persistencespb.ChasmComponentRef) ComponentRef
ProtoRefToComponentRef converts a persistence ChasmComponentRef reference to a ComponentRef. This is useful for situations where the protobuf ComponentRef has already been deserialized as part of an enclosing message.
func (*ComponentRef) ArchetypeID ¶ added in v1.30.0
func (r *ComponentRef) ArchetypeID( registry *Registry, ) (ArchetypeID, error)
type Context ¶
type Context interface {
// NOTE: component created in the current transaction won't have a ref
// this is a Ref to the component state at the start of the transition
Ref(Component) ([]byte, error)
// Now returns the current time in the context of the given component.
// In a context of a transaction, this time must be used to allow for framework support of pause and time skipping.
Now(Component) time.Time
// ExecutionKey returns the execution key for the execution the context is operating on.
ExecutionKey() ExecutionKey
// ExecutionInfo returns metadata information about the execution.
ExecutionInfo() ExecutionInfo
// Logger returns a logger tagged with execution key and other chasm framework internal information.
Logger() log.Logger
// NamespaceEntry returns the namespace entry for the execution.
NamespaceEntry() *namespace.Namespace
// EndpointByName resolves a nexus endpoint entry.
EndpointByName(endpointName string) (*persistencespb.NexusEndpointEntry, error)
// MetricsHandler returns a metrics handler with namespace tag.
MetricsHandler() metrics.Handler
// Value returns the value associated with this context for key. The behavior is the same as context.Context.Value().
// Use WithContextValues RegistrableComponentOption to set key values pair for a component upon registration.
// Registered key-value pairs will automatically be added to the Context whenever framework accesses the component.
// Alternatively, use ContextWithValue() to manually set values on Context which will take precedence over registered ones.
Value(key any) any
// RequestHeader returns the first value of the named gRPC metadata header from the inbound request context, or ""
// if absent.
//
// Only available when this Context was constructed from an inbound gRPC request, i.e. inside the start/update/read
// callbacks invoked by the chasm engine. In other contexts, such as pure tasks executed at the end of a transaction
// or background task handlers, the underlying ctx has no gRPC metadata and this method always returns "".
RequestHeader(key string) string
// Links returns the union of links attached to the given component across all requests.
// Returns nil for components that are not (yet) registered as tree nodes.
Links(Component) []*commonpb.Link
// RequestLinks returns the links attached to the given component for the specific requestID.
// Returns nil if no entry exists for that requestID. Empty requestID is rejected.
RequestLinks(Component, string) ([]*commonpb.Link, error)
// UserMetadata returns the user metadata attached to the given component, or nil if none.
UserMetadata(Component) *sdkpb.UserMetadata
// contains filtered or unexported methods
}
func NewContext ¶ added in v1.28.0
NewContext creates a new Context from an existing Context and root Node.
NOTE: Library authors should not invoke this constructor directly, and instead use ReadComponent.
type CoreLibrary ¶ added in v1.29.0
type CoreLibrary struct {
UnimplementedLibrary
}
CoreLibrary contains built-in components maintained as part of the CHASM framework.
func (*CoreLibrary) Components ¶ added in v1.29.0
func (b *CoreLibrary) Components() []*RegistrableComponent
func (*CoreLibrary) Name ¶ added in v1.29.0
func (b *CoreLibrary) Name() string
func (*CoreLibrary) Tasks ¶ added in v1.29.0
func (b *CoreLibrary) Tasks() []*RegistrableTask
type CountExecutionsRequest ¶ added in v1.30.0
type CountExecutionsResponse ¶ added in v1.30.0
func CountExecutions ¶ added in v1.30.0
func CountExecutions[C Component]( ctx context.Context, request *CountExecutionsRequest, ) (*CountExecutionsResponse, error)
CountExecutions counts the executions of a CHASM archetype given an initial query. The generic parameter C is the CHASM component type used for executions and search attribute filtering. The query string can specify any combination of CHASM, custom, and predefined/system search attributes. Note: For CHASM executions, TemporalNamespaceDivision is the predefined search attribute that is used to identify the archetype of the execution. If the query string does not specify TemporalNamespaceDivision, the archetype C of the request will be used to count the executions. If the initial query already specifies TemporalNamespaceDivision, the archetype C of the request will only be used to get the registered SearchAttributes.
type DeleteExecutionRequest ¶ added in v1.31.0
type DeleteExecutionRequest struct {
TerminateComponentRequest
}
DeleteExecutionRequest is the request for DeleteExecution. TerminateComponentRequest will only be used if the execution is still running. The actual deletion of the execution is async, and will return after creating the DeleteExecutionTask.
type EndpointRegistry ¶
type EndpointRegistry interface {
GetByName(ctx context.Context, namespaceID namespace.ID, endpointName string) (*persistencespb.NexusEndpointEntry, error)
}
type Engine ¶ added in v1.29.0
type Engine interface {
StartExecution(
context.Context,
ComponentRef,
func(MutableContext) (RootComponent, error),
...TransitionOption,
) (StartExecutionResult, error)
UpdateWithStartExecution(
context.Context,
ComponentRef,
func(MutableContext) (RootComponent, error),
func(MutableContext, Component) error,
...TransitionOption,
) (EngineUpdateWithStartExecutionResult, error)
UpdateComponent(
context.Context,
ComponentRef,
func(MutableContext, Component) error,
...TransitionOption,
) ([]byte, error)
ReadComponent(
context.Context,
ComponentRef,
func(Context, Component) error,
...TransitionOption,
) error
PollComponent(
context.Context,
ComponentRef,
func(Context, Component) (bool, error),
...TransitionOption,
) ([]byte, error)
DeleteExecution(
context.Context,
ComponentRef,
DeleteExecutionRequest,
) error
// NotifyExecution notifies any PollComponent callers waiting on the execution.
NotifyExecution(ExecutionKey)
}
type EngineUpdateWithStartExecutionResult ¶ added in v1.31.0
type EngineUpdateWithStartExecutionResult = UpdateWithStartExecutionResult[struct{}]
EngineUpdateWithStartExecutionResult is a type alias for the result type returned by the UpdateWithStart Engine implementation.
type ExecutionAlreadyStartedError ¶ added in v1.30.0
type ExecutionAlreadyStartedError struct {
Message string
CurrentRequestID string
CurrentRunID string
}
func NewExecutionAlreadyStartedErr ¶ added in v1.30.0
func NewExecutionAlreadyStartedErr( message, currentRequestID, currentRunID string, ) *ExecutionAlreadyStartedError
func (*ExecutionAlreadyStartedError) Error ¶ added in v1.30.0
func (e *ExecutionAlreadyStartedError) Error() string
type ExecutionInfo ¶ added in v1.30.0
type ExecutionInfo struct {
// StateTransitionCount is the number of create/update transactions in the history of this execution.
StateTransitionCount int64
// ApproximateStateSize is the approximate size in bytes of the persisted execution state of this execution.
ApproximateStateSize int
// CloseTime is the time when the execution was closed.
// An execution is closed when its root component reaches a terminal state in its lifecycle.
// If the component is still running (not yet closed), it returns a zero time.Time value.
CloseTime time.Time
}
type ExecutionKey ¶ added in v1.30.0
ExecutionKey uniquely identifies a CHASM execution in the system.
type Field ¶
type Field[T any] struct { // This struct needs to be created via reflection, but reflection can't set private fields. Internal fieldInternal }
func ComponentPointerTo ¶ added in v1.29.0
func ComponentPointerTo[C Component]( ctx MutableContext, c C, ) Field[C]
ComponentPointerTo returns a CHASM field populated with a pointer to the given component. The target component must be a proper ancestor of the referring component within the same component tree. Pointers to non-ancestor components (e.g., siblings, descendants, or components from a different tree) will cause the transaction to fail when it is closed.
func DataPointerTo ¶ added in v1.29.0
func DataPointerTo[D proto.Message]( ctx MutableContext, d D, ) Field[D]
DataPointerTo returns a CHASM field populated with a pointer to the given message. Pointers are resolved at the time the transaction is closed, and the transaction will fail if any pointers cannot be resolved.
func NewComponentField ¶
func NewComponentField[C Component]( ctx MutableContext, c C, options ...ComponentFieldOption, ) Field[C]
func NewDataField ¶
func NewDataField[D proto.Message]( ctx MutableContext, d D, ) Field[D]
re. Data v.s. Component. Components have behavior and has a lifecycle. while Data doesn't and must be attached to a component.
You can define a component just for storing the data, that may contain other information like ref count etc. most importantly, the framework needs to know when it's safe to delete the data. i.e. the lifecycle of that data component reaches completed.
func NewEmptyField ¶ added in v1.28.0
func (Field[T]) Get ¶
Get returns the value of the field, deserializing it if necessary. Panics rather than returning an error, as errors are supposed to be handled by the framework as opposed to the application, even if the error is an application bug.
func (Field[T]) TryGet ¶ added in v1.30.0
TryGet returns the value of the field and a boolean indicating if the value was found, deserializing if necessary. Panics rather than returning an error, as errors are supposed to be handled by the framework as opposed to the application, even if the error is an application bug.
type Library ¶
type Library interface {
Name() string
Components() []*RegistrableComponent
Tasks() []*RegistrableTask
RegisterServices(server *grpc.Server)
// NexusServices returns a list of nexus.Service instances to register with the __temporal_system Nexus endpoint.
NexusServices() []*nexus.Service
// NexusServiceProcessors returns a list of NexusServiceProcessor instances to register with the __temporal_system
// Nexus endpoint.
NexusServiceProcessors() []*NexusServiceProcessor
// contains filtered or unexported methods
}
type LifecycleState ¶
type LifecycleState int
Shall it be named ComponentLifecycleState?
const ( // Lifecycle states that are considered OPEN // // LifecycleStateCreated LifecycleState = 1 << iota LifecycleStateRunning LifecycleState = 2 << iota LifecycleStatePaused // Lifecycle states that are considered CLOSED // LifecycleStateCompleted LifecycleStateFailed )
func (LifecycleState) IsClosed ¶ added in v1.28.0
func (s LifecycleState) IsClosed() bool
func (LifecycleState) IsPaused ¶
func (s LifecycleState) IsPaused() bool
func (LifecycleState) String ¶ added in v1.28.0
func (s LifecycleState) String() string
type ListExecutionsRequest ¶ added in v1.30.0
type ListExecutionsResponse ¶ added in v1.30.0
type ListExecutionsResponse[M proto.Message] struct { Executions []*VisibilityExecutionInfo[M] NextPageToken []byte }
func ListExecutions ¶ added in v1.30.0
func ListExecutions[C Component, M proto.Message]( ctx context.Context, request *ListExecutionsRequest, ) (*ListExecutionsResponse[M], error)
ListExecutions lists the executions of a CHASM archetype given an initial query. The query string can specify any combination of CHASM, custom, and predefined/system search attributes. The generic parameter C is the CHASM component type used for executions and search attribute filtering. The generic parameter M is the type of the memo payload to be unmarshaled from the execution. PageSize is required, must be greater than 0. NextPageToken is optional, set on subsequent requests to continue listing the next page of executions. Note: For CHASM executions, TemporalNamespaceDivision is the predefined search attribute that is used to identify the archetype of the execution. If the query string does not specify TemporalNamespaceDivision, the archetype C of the request will be used to filter the executions. If the initial query already specifies TemporalNamespaceDivision, the archetype C of the request will only be used to get the registered SearchAttributes.
type MSPointer ¶ added in v1.30.0
type MSPointer struct {
// contains filtered or unexported fields
}
MSPointer is a special CHASM type which components can use to access their Node's underlying backend (i.e. mutable state). It is used to expose methods needed from the mutable state without polluting the chasm.Context interface. When deserializing components with fields of this type, the CHASM engine will set the value to its NodeBackend. This should only be used by the Workflow component.
func NewMSPointer ¶ added in v1.30.0
func NewMSPointer(backend NodeBackend) MSPointer
NewMSPointer creates a new MSPointer instance.
func (MSPointer) AddHistoryEvent ¶
func (m MSPointer) AddHistoryEvent(t enumspb.EventType, setAttributes func(*historypb.HistoryEvent)) *historypb.HistoryEvent
AddHistoryEvent adds a history event via the underlying mutable state.
func (MSPointer) GenerateEventLoadToken ¶
func (m MSPointer) GenerateEventLoadToken(event *historypb.HistoryEvent) ([]byte, error)
func (MSPointer) GetNexusCompletion ¶ added in v1.30.0
func (m MSPointer) GetNexusCompletion(ctx Context, requestID string) (nexusrpc.CompleteOperationOptions, error)
GetNexusCompletion retrieves the Nexus operation completion data for the given request ID from the underlying mutable state.
func (MSPointer) GetNexusUpdateCompletion ¶
func (m MSPointer) GetNexusUpdateCompletion(ctx Context, updateID string, requestID string) (nexusrpc.CompleteOperationOptions, error)
GetNexusUpdateCompletion retrieves the Nexus operation completion data for the given update ID and request ID from the underlying mutable state.
func (MSPointer) GetWorkflowTypeName ¶
GetWorkflowTypeName retrieves the workflow type name from the underlying mutable state.
func (MSPointer) HasAnyBufferedEvent ¶
func (m MSPointer) HasAnyBufferedEvent(filter func(*historypb.HistoryEvent) bool) bool
HasAnyBufferedEvent returns true if there is at least one buffered event that matches the provided filter.
func (MSPointer) LoadHistoryEvent ¶
LoadHistoryEvent loads a history event from the underlying mutable state using the given token.
func (MSPointer) WorkflowRunTimeout ¶
WorkflowRunTimeout returns the workflow run timeout duration. Returns 0 if no timeout is set.
type MockComponent ¶
type MockComponent struct {
// contains filtered or unexported fields
}
MockComponent is a mock of Component interface.
func NewMockComponent ¶
func NewMockComponent(ctrl *gomock.Controller) *MockComponent
NewMockComponent creates a new mock instance.
func (*MockComponent) EXPECT ¶
func (m *MockComponent) EXPECT() *MockComponentMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockComponent) LifecycleState ¶
func (m *MockComponent) LifecycleState(arg0 Context) LifecycleState
LifecycleState mocks base method.
type MockComponentMockRecorder ¶
type MockComponentMockRecorder struct {
// contains filtered or unexported fields
}
MockComponentMockRecorder is the mock recorder for MockComponent.
func (*MockComponentMockRecorder) LifecycleState ¶
func (mr *MockComponentMockRecorder) LifecycleState(arg0 any) *gomock.Call
LifecycleState indicates an expected call of LifecycleState.
type MockContext ¶ added in v1.29.0
type MockContext struct {
HandleExecutionKey func() ExecutionKey
HandleNow func(component Component) time.Time
HandleRef func(component Component) ([]byte, error)
HandleExecutionCloseTime func() time.Time
HandleStateTransitionCount func() int64
HandleExecutionInfo func() ExecutionInfo
HandleLibrary func(name string) (Library, bool)
HandleNamespaceEntry func() *namespace.Namespace
HandleEndpointByName func(string) (*persistencespb.NexusEndpointEntry, error)
HandleMetricsHandler func() metrics.Handler
HandleLinks func(component Component) []*commonpb.Link
HandleRequestLinks func(component Component, requestID string) ([]*commonpb.Link, error)
HandleUserMetadata func(component Component) *sdkpb.UserMetadata
// GoCtx is the underlying context.Context used for context value lookups.
// Any values set on it will be available via the CHASM mock context's Value method,
// and take precedence over any registered context values.
// Defaults to context.Background() if nil.
GoCtx context.Context
// contains filtered or unexported fields
}
MockContext is a mock implementation of Context.
func (*MockContext) EndpointByName ¶
func (c *MockContext) EndpointByName(name string) (*persistencespb.NexusEndpointEntry, error)
func (*MockContext) ExecutionInfo ¶ added in v1.31.0
func (c *MockContext) ExecutionInfo() ExecutionInfo
func (*MockContext) ExecutionKey ¶ added in v1.30.0
func (c *MockContext) ExecutionKey() ExecutionKey
func (*MockContext) Logger ¶ added in v1.31.0
func (c *MockContext) Logger() log.Logger
func (*MockContext) MetricsHandler ¶ added in v1.31.0
func (c *MockContext) MetricsHandler() metrics.Handler
func (*MockContext) NamespaceEntry ¶
func (c *MockContext) NamespaceEntry() *namespace.Namespace
func (*MockContext) RegisterComponentContextValues ¶ added in v1.31.0
func (c *MockContext) RegisterComponentContextValues( keyValues map[any]any, )
func (*MockContext) RequestHeader ¶
func (c *MockContext) RequestHeader(key string) string
func (*MockContext) RequestLinks ¶
func (*MockContext) UserMetadata ¶
func (c *MockContext) UserMetadata(component Component) *sdkpb.UserMetadata
func (*MockContext) Value ¶ added in v1.31.0
func (c *MockContext) Value(key any) any
type MockEngine ¶ added in v1.29.0
type MockEngine struct {
// contains filtered or unexported fields
}
MockEngine is a mock of Engine interface.
func NewMockEngine ¶ added in v1.29.0
func NewMockEngine(ctrl *gomock.Controller) *MockEngine
NewMockEngine creates a new mock instance.
func (*MockEngine) DeleteExecution ¶ added in v1.31.0
func (m *MockEngine) DeleteExecution(arg0 context.Context, arg1 ComponentRef, arg2 DeleteExecutionRequest) error
DeleteExecution mocks base method.
func (*MockEngine) EXPECT ¶ added in v1.29.0
func (m *MockEngine) EXPECT() *MockEngineMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockEngine) NotifyExecution ¶ added in v1.30.0
func (m *MockEngine) NotifyExecution(arg0 ExecutionKey)
NotifyExecution mocks base method.
func (*MockEngine) PollComponent ¶ added in v1.29.0
func (m *MockEngine) PollComponent(arg0 context.Context, arg1 ComponentRef, arg2 func(Context, Component) (bool, error), arg3 ...TransitionOption) ([]byte, error)
PollComponent mocks base method.
func (*MockEngine) ReadComponent ¶ added in v1.29.0
func (m *MockEngine) ReadComponent(arg0 context.Context, arg1 ComponentRef, arg2 func(Context, Component) error, arg3 ...TransitionOption) error
ReadComponent mocks base method.
func (*MockEngine) StartExecution ¶ added in v1.31.0
func (m *MockEngine) StartExecution(arg0 context.Context, arg1 ComponentRef, arg2 func(MutableContext) (RootComponent, error), arg3 ...TransitionOption) (StartExecutionResult, error)
StartExecution mocks base method.
func (*MockEngine) UpdateComponent ¶ added in v1.29.0
func (m *MockEngine) UpdateComponent(arg0 context.Context, arg1 ComponentRef, arg2 func(MutableContext, Component) error, arg3 ...TransitionOption) ([]byte, error)
UpdateComponent mocks base method.
func (*MockEngine) UpdateWithStartExecution ¶ added in v1.31.0
func (m *MockEngine) UpdateWithStartExecution(arg0 context.Context, arg1 ComponentRef, arg2 func(MutableContext) (RootComponent, error), arg3 func(MutableContext, Component) error, arg4 ...TransitionOption) (EngineUpdateWithStartExecutionResult, error)
UpdateWithStartExecution mocks base method.
type MockEngineMockRecorder ¶ added in v1.29.0
type MockEngineMockRecorder struct {
// contains filtered or unexported fields
}
MockEngineMockRecorder is the mock recorder for MockEngine.
func (*MockEngineMockRecorder) DeleteExecution ¶ added in v1.31.0
func (mr *MockEngineMockRecorder) DeleteExecution(arg0, arg1, arg2 any) *gomock.Call
DeleteExecution indicates an expected call of DeleteExecution.
func (*MockEngineMockRecorder) NotifyExecution ¶ added in v1.30.0
func (mr *MockEngineMockRecorder) NotifyExecution(arg0 any) *gomock.Call
NotifyExecution indicates an expected call of NotifyExecution.
func (*MockEngineMockRecorder) PollComponent ¶ added in v1.29.0
func (mr *MockEngineMockRecorder) PollComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
PollComponent indicates an expected call of PollComponent.
func (*MockEngineMockRecorder) ReadComponent ¶ added in v1.29.0
func (mr *MockEngineMockRecorder) ReadComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
ReadComponent indicates an expected call of ReadComponent.
func (*MockEngineMockRecorder) StartExecution ¶ added in v1.31.0
func (mr *MockEngineMockRecorder) StartExecution(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
StartExecution indicates an expected call of StartExecution.
func (*MockEngineMockRecorder) UpdateComponent ¶ added in v1.29.0
func (mr *MockEngineMockRecorder) UpdateComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
UpdateComponent indicates an expected call of UpdateComponent.
func (*MockEngineMockRecorder) UpdateWithStartExecution ¶ added in v1.31.0
func (mr *MockEngineMockRecorder) UpdateWithStartExecution(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call
UpdateWithStartExecution indicates an expected call of UpdateWithStartExecution.
type MockLibrary ¶
type MockLibrary struct {
// contains filtered or unexported fields
}
MockLibrary is a mock of Library interface.
func NewMockLibrary ¶
func NewMockLibrary(ctrl *gomock.Controller) *MockLibrary
NewMockLibrary creates a new mock instance.
func (*MockLibrary) Components ¶
func (m *MockLibrary) Components() []*RegistrableComponent
Components mocks base method.
func (*MockLibrary) EXPECT ¶
func (m *MockLibrary) EXPECT() *MockLibraryMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockLibrary) NexusServiceProcessors ¶ added in v1.31.0
func (m *MockLibrary) NexusServiceProcessors() []*NexusServiceProcessor
NexusServiceProcessors mocks base method.
func (*MockLibrary) NexusServices ¶ added in v1.31.0
func (m *MockLibrary) NexusServices() []*nexus.Service
NexusServices mocks base method.
func (*MockLibrary) RegisterServices ¶ added in v1.30.0
func (m *MockLibrary) RegisterServices(server *grpc.Server)
RegisterServices mocks base method.
func (*MockLibrary) Tasks ¶
func (m *MockLibrary) Tasks() []*RegistrableTask
Tasks mocks base method.
type MockLibraryMockRecorder ¶
type MockLibraryMockRecorder struct {
// contains filtered or unexported fields
}
MockLibraryMockRecorder is the mock recorder for MockLibrary.
func (*MockLibraryMockRecorder) Components ¶
func (mr *MockLibraryMockRecorder) Components() *gomock.Call
Components indicates an expected call of Components.
func (*MockLibraryMockRecorder) Name ¶
func (mr *MockLibraryMockRecorder) Name() *gomock.Call
Name indicates an expected call of Name.
func (*MockLibraryMockRecorder) NexusServiceProcessors ¶ added in v1.31.0
func (mr *MockLibraryMockRecorder) NexusServiceProcessors() *gomock.Call
NexusServiceProcessors indicates an expected call of NexusServiceProcessors.
func (*MockLibraryMockRecorder) NexusServices ¶ added in v1.31.0
func (mr *MockLibraryMockRecorder) NexusServices() *gomock.Call
NexusServices indicates an expected call of NexusServices.
func (*MockLibraryMockRecorder) RegisterServices ¶ added in v1.30.0
func (mr *MockLibraryMockRecorder) RegisterServices(server any) *gomock.Call
RegisterServices indicates an expected call of RegisterServices.
func (*MockLibraryMockRecorder) Tasks ¶
func (mr *MockLibraryMockRecorder) Tasks() *gomock.Call
Tasks indicates an expected call of Tasks.
type MockMutableContext ¶ added in v1.29.0
type MockMutableContext struct {
MockContext
Tasks []MockTask
LinksByRequest map[Component]map[string][]*commonpb.Link
UserMetadataByComponent map[Component]*sdkpb.UserMetadata
// contains filtered or unexported fields
}
MockMutableContext is a mock implementation of MutableContext that records added tasks for inspection in tests.
func (*MockMutableContext) AddTask ¶ added in v1.29.0
func (c *MockMutableContext) AddTask(component Component, attributes TaskAttributes, payload any)
func (*MockMutableContext) SetRequestLinks ¶
func (*MockMutableContext) SetUserMetadata ¶
func (c *MockMutableContext) SetUserMetadata(component Component, md *sdkpb.UserMetadata) error
type MockNodeBackend ¶ added in v1.28.0
type MockNodeBackend struct {
// Optional function overrides. If nil, methods return zero-values.
HandleGetExecutionState func() *persistencespb.WorkflowExecutionState
HandleGetExecutionInfo func() *persistencespb.WorkflowExecutionInfo
HandleGetCurrentVersion func() int64
HandleNextTransitionCount func() int64
HandleGetApproximatePersistedSize func() int
HandleChasmSkipPersistenceEnabled func() bool
HandleCurrentVersionedTransition func() *persistencespb.VersionedTransition
HandleGetWorkflowKey func() definition.WorkflowKey
HandleUpdateWorkflowStateStatus func(state enumsspb.WorkflowExecutionState, status enumspb.WorkflowExecutionStatus) (bool, error)
HandleIsWorkflow func() bool
HandleGetNexusCompletion func(ctx context.Context, requestID string) (nexusrpc.CompleteOperationOptions, error)
HandleGetNexusUpdateCompletion func(ctx context.Context, updateID string, requestID string) (nexusrpc.CompleteOperationOptions, error)
HandleAddHistoryEvent func(t enumspb.EventType, setAttributes func(*historypb.HistoryEvent)) *historypb.HistoryEvent
HandleLoadHistoryEvent func(ctx context.Context, token []byte) (*historypb.HistoryEvent, error)
HandleGenerateEventLoadToken func(event *historypb.HistoryEvent) ([]byte, error)
HandleHasAnyBufferedEvent func(filter func(*historypb.HistoryEvent) bool) bool
HandleGetNamespaceEntry func() *namespace.Namespace
HandleEndpointRegistry func() EndpointRegistry
TasksByCategory map[tasks.Category][]tasks.Task
DeletePureTaskCalls []time.Time
UpdateCalls []struct {
State enumsspb.WorkflowExecutionState
Status enumspb.WorkflowExecutionStatus
}
// contains filtered or unexported fields
}
MockNodeBackend is a lightweight manual mock for the NodeBackend interface. Methods may be stubbed by assigning the corresponding Handle fields. Update call history is recorded in the struct fields (thread-safe).
func (*MockNodeBackend) AddHistoryEvent ¶
func (m *MockNodeBackend) AddHistoryEvent(t enumspb.EventType, setAttributes func(*historypb.HistoryEvent)) *historypb.HistoryEvent
func (*MockNodeBackend) AddTasks ¶ added in v1.28.0
func (m *MockNodeBackend) AddTasks(ts ...tasks.Task)
func (*MockNodeBackend) ChasmSkipPersistenceEnabled ¶
func (m *MockNodeBackend) ChasmSkipPersistenceEnabled() bool
func (*MockNodeBackend) CurrentVersionedTransition ¶ added in v1.29.0
func (m *MockNodeBackend) CurrentVersionedTransition() *persistencespb.VersionedTransition
func (*MockNodeBackend) DeleteCHASMPureTasks ¶ added in v1.30.0
func (m *MockNodeBackend) DeleteCHASMPureTasks(maxScheduledTime time.Time)
func (*MockNodeBackend) EndpointRegistry ¶
func (m *MockNodeBackend) EndpointRegistry() EndpointRegistry
func (*MockNodeBackend) GenerateEventLoadToken ¶
func (m *MockNodeBackend) GenerateEventLoadToken(event *historypb.HistoryEvent) ([]byte, error)
func (*MockNodeBackend) GetApproximatePersistedSize ¶ added in v1.31.0
func (m *MockNodeBackend) GetApproximatePersistedSize() int
func (*MockNodeBackend) GetCurrentVersion ¶ added in v1.28.0
func (m *MockNodeBackend) GetCurrentVersion() int64
func (*MockNodeBackend) GetExecutionInfo ¶ added in v1.28.0
func (m *MockNodeBackend) GetExecutionInfo() *persistencespb.WorkflowExecutionInfo
func (*MockNodeBackend) GetExecutionState ¶ added in v1.29.0
func (m *MockNodeBackend) GetExecutionState() *persistencespb.WorkflowExecutionState
func (*MockNodeBackend) GetNamespaceEntry ¶
func (m *MockNodeBackend) GetNamespaceEntry() *namespace.Namespace
func (*MockNodeBackend) GetNexusCompletion ¶ added in v1.30.0
func (m *MockNodeBackend) GetNexusCompletion( ctx context.Context, requestID string, ) (nexusrpc.CompleteOperationOptions, error)
func (*MockNodeBackend) GetNexusUpdateCompletion ¶
func (m *MockNodeBackend) GetNexusUpdateCompletion( ctx context.Context, updateID string, requestID string, ) (nexusrpc.CompleteOperationOptions, error)
func (*MockNodeBackend) GetWorkflowKey ¶ added in v1.28.0
func (m *MockNodeBackend) GetWorkflowKey() definition.WorkflowKey
func (*MockNodeBackend) HasAnyBufferedEvent ¶
func (m *MockNodeBackend) HasAnyBufferedEvent(filter func(*historypb.HistoryEvent) bool) bool
func (*MockNodeBackend) IsWorkflow ¶ added in v1.30.0
func (m *MockNodeBackend) IsWorkflow() bool
func (*MockNodeBackend) LastDeletePureTaskCall ¶ added in v1.30.0
func (m *MockNodeBackend) LastDeletePureTaskCall() time.Time
func (*MockNodeBackend) LastUpdateWorkflowState ¶ added in v1.30.0
func (m *MockNodeBackend) LastUpdateWorkflowState() enumsspb.WorkflowExecutionState
func (*MockNodeBackend) LastUpdateWorkflowStatus ¶ added in v1.30.0
func (m *MockNodeBackend) LastUpdateWorkflowStatus() enumspb.WorkflowExecutionStatus
func (*MockNodeBackend) LoadHistoryEvent ¶
func (m *MockNodeBackend) LoadHistoryEvent(ctx context.Context, token []byte) (*historypb.HistoryEvent, error)
func (*MockNodeBackend) NextTransitionCount ¶ added in v1.28.0
func (m *MockNodeBackend) NextTransitionCount() int64
func (*MockNodeBackend) NumTasksAdded ¶ added in v1.30.0
func (m *MockNodeBackend) NumTasksAdded() int
func (*MockNodeBackend) UpdateWorkflowStateStatus ¶ added in v1.28.0
func (m *MockNodeBackend) UpdateWorkflowStateStatus( state enumsspb.WorkflowExecutionState, status enumspb.WorkflowExecutionStatus, ) (bool, error)
type MockNodePureTask ¶ added in v1.29.0
type MockNodePureTask struct {
HandleExecutePureTask func(baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any) (bool, error)
ExecuteCalls []struct {
BaseCtx context.Context
Attributes TaskAttributes
Task any
}
// contains filtered or unexported fields
}
MockNodePureTask is a lightweight manual mock for the NodePureTask interface. Methods may be stubbed by assigning the corresponding Handle fields. Call history is recorded in the struct fields (thread-safe).
func (*MockNodePureTask) ExecutePureTask ¶ added in v1.29.0
func (m *MockNodePureTask) ExecutePureTask( baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any, ) (bool, error)
type MockPureTaskHandler ¶ added in v1.31.0
MockPureTaskHandler is a mock of PureTaskHandler interface.
func NewMockPureTaskHandler ¶ added in v1.31.0
func NewMockPureTaskHandler[C any, T any](ctrl *gomock.Controller) *MockPureTaskHandler[C, T]
NewMockPureTaskHandler creates a new mock instance.
func (*MockPureTaskHandler[C, T]) EXPECT ¶ added in v1.31.0
func (m *MockPureTaskHandler[C, T]) EXPECT() *MockPureTaskHandlerMockRecorder[C, T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPureTaskHandler[C, T]) Execute ¶ added in v1.31.0
func (m *MockPureTaskHandler[C, T]) Execute(arg0 MutableContext, arg1 C, arg2 TaskAttributes, arg3 T) error
Execute mocks base method.
func (*MockPureTaskHandler[C, T]) Validate ¶ added in v1.31.0
func (m *MockPureTaskHandler[C, T]) Validate(arg0 Context, arg1 C, arg2 TaskInvocation, arg3 T) (bool, error)
Validate mocks base method.
type MockPureTaskHandlerMockRecorder ¶ added in v1.31.0
type MockPureTaskHandlerMockRecorder[C any, T any] struct { // contains filtered or unexported fields }
MockPureTaskHandlerMockRecorder is the mock recorder for MockPureTaskHandler.
type MockRootComponent ¶ added in v1.31.0
type MockRootComponent struct {
// contains filtered or unexported fields
}
MockRootComponent is a mock of RootComponent interface.
func NewMockRootComponent ¶ added in v1.31.0
func NewMockRootComponent(ctrl *gomock.Controller) *MockRootComponent
NewMockRootComponent creates a new mock instance.
func (*MockRootComponent) ContextMetadata ¶ added in v1.31.0
func (m *MockRootComponent) ContextMetadata(arg0 Context) map[string]string
ContextMetadata mocks base method.
func (*MockRootComponent) EXPECT ¶ added in v1.31.0
func (m *MockRootComponent) EXPECT() *MockRootComponentMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockRootComponent) LifecycleState ¶ added in v1.31.0
func (m *MockRootComponent) LifecycleState(arg0 Context) LifecycleState
LifecycleState mocks base method.
func (*MockRootComponent) Terminate ¶ added in v1.31.0
func (m *MockRootComponent) Terminate(arg0 MutableContext, arg1 TerminateComponentRequest) (TerminateComponentResponse, error)
Terminate mocks base method.
type MockRootComponentMockRecorder ¶ added in v1.31.0
type MockRootComponentMockRecorder struct {
// contains filtered or unexported fields
}
MockRootComponentMockRecorder is the mock recorder for MockRootComponent.
func (*MockRootComponentMockRecorder) ContextMetadata ¶ added in v1.31.0
func (mr *MockRootComponentMockRecorder) ContextMetadata(arg0 any) *gomock.Call
ContextMetadata indicates an expected call of ContextMetadata.
func (*MockRootComponentMockRecorder) LifecycleState ¶ added in v1.31.0
func (mr *MockRootComponentMockRecorder) LifecycleState(arg0 any) *gomock.Call
LifecycleState indicates an expected call of LifecycleState.
type MockSideEffectTaskHandler ¶ added in v1.31.0
MockSideEffectTaskHandler is a mock of SideEffectTaskHandler interface.
func NewMockSideEffectTaskHandler ¶ added in v1.31.0
func NewMockSideEffectTaskHandler[C any, T any](ctrl *gomock.Controller) *MockSideEffectTaskHandler[C, T]
NewMockSideEffectTaskHandler creates a new mock instance.
func (*MockSideEffectTaskHandler[C, T]) Discard ¶ added in v1.31.0
func (m *MockSideEffectTaskHandler[C, T]) Discard(arg0 context.Context, arg1 ComponentRef, arg2 TaskAttributes, arg3 T) error
Discard mocks base method.
func (*MockSideEffectTaskHandler[C, T]) EXPECT ¶ added in v1.31.0
func (m *MockSideEffectTaskHandler[C, T]) EXPECT() *MockSideEffectTaskHandlerMockRecorder[C, T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSideEffectTaskHandler[C, T]) Execute ¶ added in v1.31.0
func (m *MockSideEffectTaskHandler[C, T]) Execute(arg0 context.Context, arg1 ComponentRef, arg2 TaskAttributes, arg3 T) error
Execute mocks base method.
func (*MockSideEffectTaskHandler[C, T]) Validate ¶ added in v1.31.0
func (m *MockSideEffectTaskHandler[C, T]) Validate(arg0 Context, arg1 C, arg2 TaskInvocation, arg3 T) (bool, error)
Validate mocks base method.
type MockSideEffectTaskHandlerMockRecorder ¶ added in v1.31.0
type MockSideEffectTaskHandlerMockRecorder[C any, T any] struct { // contains filtered or unexported fields }
MockSideEffectTaskHandlerMockRecorder is the mock recorder for MockSideEffectTaskHandler.
func (*MockSideEffectTaskHandlerMockRecorder[C, T]) Discard ¶ added in v1.31.0
func (mr *MockSideEffectTaskHandlerMockRecorder[C, T]) Discard(arg0, arg1, arg2, arg3 any) *gomock.Call
Discard indicates an expected call of Discard.
type MockTask ¶ added in v1.30.0
type MockTask struct {
Component Component
Attributes TaskAttributes
Payload any
}
type MockTaskValidator ¶ added in v1.28.0
MockTaskValidator is a mock of TaskValidator interface.
func NewMockTaskValidator ¶ added in v1.28.0
func NewMockTaskValidator[C any, T any](ctrl *gomock.Controller) *MockTaskValidator[C, T]
NewMockTaskValidator creates a new mock instance.
func (*MockTaskValidator[C, T]) EXPECT ¶ added in v1.28.0
func (m *MockTaskValidator[C, T]) EXPECT() *MockTaskValidatorMockRecorder[C, T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTaskValidator[C, T]) Validate ¶ added in v1.28.0
func (m *MockTaskValidator[C, T]) Validate(arg0 Context, arg1 C, arg2 TaskInvocation, arg3 T) (bool, error)
Validate mocks base method.
type MockTaskValidatorMockRecorder ¶ added in v1.28.0
type MockTaskValidatorMockRecorder[C any, T any] struct { // contains filtered or unexported fields }
MockTaskValidatorMockRecorder is the mock recorder for MockTaskValidator.
type MockTerminableComponent ¶ added in v1.31.0
type MockTerminableComponent struct {
// contains filtered or unexported fields
}
MockTerminableComponent is a mock of TerminableComponent interface.
func NewMockTerminableComponent ¶ added in v1.31.0
func NewMockTerminableComponent(ctrl *gomock.Controller) *MockTerminableComponent
NewMockTerminableComponent creates a new mock instance.
func (*MockTerminableComponent) EXPECT ¶ added in v1.31.0
func (m *MockTerminableComponent) EXPECT() *MockTerminableComponentMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTerminableComponent) LifecycleState ¶ added in v1.31.0
func (m *MockTerminableComponent) LifecycleState(arg0 Context) LifecycleState
LifecycleState mocks base method.
func (*MockTerminableComponent) Terminate ¶ added in v1.31.0
func (m *MockTerminableComponent) Terminate(arg0 MutableContext, arg1 TerminateComponentRequest) (TerminateComponentResponse, error)
Terminate mocks base method.
type MockTerminableComponentMockRecorder ¶ added in v1.31.0
type MockTerminableComponentMockRecorder struct {
// contains filtered or unexported fields
}
MockTerminableComponentMockRecorder is the mock recorder for MockTerminableComponent.
func (*MockTerminableComponentMockRecorder) LifecycleState ¶ added in v1.31.0
func (mr *MockTerminableComponentMockRecorder) LifecycleState(arg0 any) *gomock.Call
LifecycleState indicates an expected call of LifecycleState.
type MockVisibilityManager ¶ added in v1.30.0
type MockVisibilityManager struct {
// contains filtered or unexported fields
}
MockVisibilityManager is a mock of VisibilityManager interface.
func NewMockVisibilityManager ¶ added in v1.30.0
func NewMockVisibilityManager(ctrl *gomock.Controller) *MockVisibilityManager
NewMockVisibilityManager creates a new mock instance.
func (*MockVisibilityManager) CountExecutions ¶ added in v1.30.0
func (m *MockVisibilityManager) CountExecutions(arg0 context.Context, arg1 reflect.Type, arg2 *CountExecutionsRequest) (*visibilityservice.CountChasmExecutionsResponse, error)
CountExecutions mocks base method.
func (*MockVisibilityManager) EXPECT ¶ added in v1.30.0
func (m *MockVisibilityManager) EXPECT() *MockVisibilityManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockVisibilityManager) ListExecutions ¶ added in v1.30.0
func (m *MockVisibilityManager) ListExecutions(arg0 context.Context, arg1 reflect.Type, arg2 *ListExecutionsRequest) (*visibilityservice.ListChasmExecutionsResponse, error)
ListExecutions mocks base method.
type MockVisibilityManagerMockRecorder ¶ added in v1.30.0
type MockVisibilityManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockVisibilityManagerMockRecorder is the mock recorder for MockVisibilityManager.
func (*MockVisibilityManagerMockRecorder) CountExecutions ¶ added in v1.30.0
func (mr *MockVisibilityManagerMockRecorder) CountExecutions(arg0, arg1, arg2 any) *gomock.Call
CountExecutions indicates an expected call of CountExecutions.
func (*MockVisibilityManagerMockRecorder) ListExecutions ¶ added in v1.30.0
func (mr *MockVisibilityManagerMockRecorder) ListExecutions(arg0, arg1, arg2 any) *gomock.Call
ListExecutions indicates an expected call of ListExecutions.
type Mocknamer ¶ added in v1.28.0
type Mocknamer struct {
// contains filtered or unexported fields
}
Mocknamer is a mock of namer interface.
func NewMocknamer ¶ added in v1.28.0
func NewMocknamer(ctrl *gomock.Controller) *Mocknamer
NewMocknamer creates a new mock instance.
func (*Mocknamer) EXPECT ¶ added in v1.28.0
func (m *Mocknamer) EXPECT() *MocknamerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MocknamerMockRecorder ¶ added in v1.28.0
type MocknamerMockRecorder struct {
// contains filtered or unexported fields
}
MocknamerMockRecorder is the mock recorder for Mocknamer.
func (*MocknamerMockRecorder) Name ¶ added in v1.28.0
func (mr *MocknamerMockRecorder) Name() *gomock.Call
Name indicates an expected call of Name.
type MutableContext ¶
type MutableContext interface {
Context
// AddTask adds a task to be emitted as part of the current transaction.
// The task is associated with the given component and will be invoked via the registered handler for the given task
// referencing the component.
AddTask(Component, TaskAttributes, any)
// SetRequestLinks records the links contributed by the given request on the
// component, replacing any prior entry for the same request ID. Passing
// nil/empty links removes the entry.
SetRequestLinks(Component, string, []*commonpb.Link) error
// SetUserMetadata replaces the user metadata attached to the given component.
SetUserMetadata(Component, *sdkpb.UserMetadata) error
}
func NewMutableContext ¶ added in v1.28.0
func NewMutableContext( ctx context.Context, node *Node, ) MutableContext
NewMutableContext creates a new MutableContext from an existing Context and root Node.
NOTE: Library authors should not invoke this constructor directly, and instead use the UpdateComponent, UpdateWithStartExecution, or StartExecution APIs.
type NexusCompletionHandler ¶ added in v1.30.0
type NexusCompletionHandler interface {
HandleNexusCompletion(ctx MutableContext, completion *persistencespb.ChasmNexusCompletion) error
}
NexusCompletionHandler is implemented by CHASM components that want to handle Nexus operation completion callbacks.
type NexusEndpointProcessor ¶ added in v1.31.0
type NexusEndpointProcessor struct {
// contains filtered or unexported fields
}
NexusEndpointProcessor handles input processing for Nexus operations across multiple services within a Nexus endpoint. It routes requests to the appropriate service processor based on the service name.
func NewNexusEndpointProcessor ¶ added in v1.31.0
func NewNexusEndpointProcessor() *NexusEndpointProcessor
NewNexusEndpointProcessor creates a new NexusEndpointProcessor.
func (*NexusEndpointProcessor) MustRegisterServiceProcessor ¶ added in v1.31.0
func (p *NexusEndpointProcessor) MustRegisterServiceProcessor(processor *NexusServiceProcessor)
MustRegisterServiceProcessor registers the service processor and panics if registration fails.
func (*NexusEndpointProcessor) ProcessInput ¶ added in v1.31.0
func (p *NexusEndpointProcessor) ProcessInput(ctx NexusOperationProcessorContext, service, operation string, input *commonpb.Payload) (*NexusOperationProcessorResult, error)
ProcessInput routes the input processing request to the appropriate service processor and returns routing information for the operation.
Returns a nexus.HandlerError if the service is not found or if input processing fails.
func (*NexusEndpointProcessor) RegisterServiceProcessor ¶ added in v1.31.0
func (p *NexusEndpointProcessor) RegisterServiceProcessor(processor *NexusServiceProcessor) error
RegisterServiceProcessor adds a service-level processor to the endpoint keyed by its name. Returns an error if a processor with the same name is already registered.
type NexusOperationProcessor ¶ added in v1.31.0
type NexusOperationProcessor[I any] interface { // ProcessInput validates the input, and returns routing information for processing this operation. The // method may mutate the input to set default values. ProcessInput(ctx NexusOperationProcessorContext, input I) (*NexusOperationProcessorResult, error) }
NexusOperationProcessor is an interface that can be implemented per operation to validate and determine routing for the operation.
type NexusOperationProcessorContext ¶ added in v1.31.0
type NexusOperationProcessorContext struct {
// Namespace is the target namespace used for routing and validation of Nexus operations.
Namespace *namespace.Namespace
// RequestID is a unique identifier for the incoming operation request, used for correlation and idempotency
// across retries.
RequestID string
Links []nexus.Link
// A boolean indicating whether the operation processor framework should re-serialize the input and store it in the
// [NexusOperationProcessorResult.ReserializedInputPayload] field. Processor implementations may mutate the input regardless.
ReserializeInputPayload bool
}
NexusOperationProcessorContext contains context for processing a Nexus operation's input, including the target namespace and a request identifier used for tracing and idempotency.
type NexusOperationProcessorResult ¶ added in v1.31.0
type NexusOperationProcessorResult struct {
// RoutingKey determines which history shard should process the operation.
RoutingKey NexusOperationRoutingKey
// A field set by the framework to containing the re-serialized input payload if requested in the given context.
ReserializedInputPayload *commonpb.Payload
}
NexusOperationProcessorResult contains the result of processing a Nexus operation input, including the routing key that determines which shard should handle the operation.
type NexusOperationRoutingKey ¶ added in v1.31.0
type NexusOperationRoutingKey interface {
// ShardID returns the target shard ID for this routing key given the total number of shards.
ShardID(numShards int32) int32
}
NexusOperationRoutingKey determines which history shard should process a Nexus operation. Different implementations provide different routing strategies (e.g., by execution, random).
type NexusOperationRoutingKeyExecution ¶ added in v1.31.0
type NexusOperationRoutingKeyExecution struct {
// NamespaceID is the ID of the namespace containing the execution whose shard should be targeted.
NamespaceID string
// BusinessID is the business identifier (e.g., workflow ID) of the execution.
BusinessID string
}
NexusOperationRoutingKeyExecution routes operations to a specific shard based on an execution key. This ensures that operations related to the same execution are processed on the same shard.
func (NexusOperationRoutingKeyExecution) ShardID ¶ added in v1.31.0
func (r NexusOperationRoutingKeyExecution) ShardID(numShards int32) int32
ShardID returns the shard that owns the execution identified by the namespace and business IDs.
type NexusOperationRoutingKeyRandom ¶ added in v1.31.0
type NexusOperationRoutingKeyRandom struct {
}
NexusOperationRoutingKeyRandom routes operations to a random shard. The ShardID method returns a randomly selected valid shard ID.
func (NexusOperationRoutingKeyRandom) ShardID ¶ added in v1.31.0
func (NexusOperationRoutingKeyRandom) ShardID(numShards int32) int32
ShardID returns a randomly selected shard ID in the range [1, numShards].
type NexusServiceProcessor ¶ added in v1.31.0
type NexusServiceProcessor struct {
// contains filtered or unexported fields
}
NexusServiceProcessor handles input processing for operations within a specific Nexus service. It uses reflection to dynamically invoke the ProcessInput method on operations that implement it.
func NewNexusServiceProcessor ¶ added in v1.31.0
func NewNexusServiceProcessor(name string) *NexusServiceProcessor
NewNexusServiceProcessor constructs a processor for a single Nexus service that can register and invoke operation processors by name.
func (*NexusServiceProcessor) MustRegisterOperation ¶ added in v1.31.0
func (p *NexusServiceProcessor) MustRegisterOperation(name string, op RegisterableNexusOperationProcessor)
MustRegisterOperation registers a named operation and panics if registration fails.
func (*NexusServiceProcessor) ProcessInput ¶ added in v1.31.0
func (p *NexusServiceProcessor) ProcessInput(ctx NexusOperationProcessorContext, opName string, input *commonpb.Payload) (*NexusOperationProcessorResult, error)
ProcessInput routes the input processing request to the appropriate operation processor and returns routing information for the operation.
Returns a nexus.HandlerError if the operation is not found or if input processing fails.
func (*NexusServiceProcessor) RegisterOperation ¶ added in v1.31.0
func (p *NexusServiceProcessor) RegisterOperation(name string, op RegisterableNexusOperationProcessor) error
RegisterOperation registers a named operation with this service processor. Returns an error if an operation with the same name is already registered.
type NoValue ¶ added in v1.30.0
type NoValue = *struct{}
NoValue is a sentinel type representing no value. Useful for accessing components using the engine methods (e.g., [GetComponent]) with a function that does not need to return any information.
type Node ¶ added in v1.28.0
type Node struct {
// contains filtered or unexported fields
}
Node is the in-memory representation of a persisted CHASM node.
Node and all its methods are NOT meant to be used by CHASM component authors. They are exported for use by the CHASM engine and underlying MutableState implementation only.
func NewEmptyTree ¶ added in v1.28.0
func NewEmptyTree( registry *Registry, timeSource clock.TimeSource, backend NodeBackend, pathEncoder NodePathEncoder, logger log.Logger, metricsHandler metrics.Handler, ) *Node
NewEmptyTree creates a new empty in-memory CHASM tree.
func NewTreeFromDB ¶ added in v1.30.0
func NewTreeFromDB( serializedNodes map[string]*persistencespb.ChasmNode, registry *Registry, timeSource clock.TimeSource, backend NodeBackend, pathEncoder NodePathEncoder, logger log.Logger, metricsHandler metrics.Handler, ) (*Node, error)
NewTreeFromDB creates a new in-memory CHASM tree from a collection of flattened persistence CHASM nodes. This method should only be used when loading an existing CHASM tree from database. If serializedNodes is empty, the tree will be considered as a legacy Workflow execution without any CHASM nodes.
func (*Node) AddTask ¶ added in v1.28.0
func (n *Node) AddTask( component Component, taskAttributes TaskAttributes, task any, )
AddTask implements the CHASM MutableContext interface
func (*Node) ApplyMutation ¶ added in v1.28.0
func (n *Node) ApplyMutation( mutation NodesMutation, ) error
ApplyMutation is used by replication stack to apply node mutations from the source cluster.
NOTE: It will be an error if UpdatedNodes and DeletedNodes have overlapping keys, as the CHASM tree does not have enough information to tell if the deletion happens before or after the update.
func (*Node) ApplySnapshot ¶ added in v1.28.0
func (n *Node) ApplySnapshot( incomingSnapshot NodesSnapshot, ) error
ApplySnapshot is used by replication stack to apply node snapshot from the source cluster.
If we simply substituting the entire CHASM tree, we will be forced to close the transaction as snapshot and potentially write extra data to persistence. This method will instead figure out the mutations needed to bring the current tree to the be the same as the snapshot, thus allowing us to close the transaction as mutation.
func (*Node) ApplySystemMutation ¶ added in v1.31.0
func (n *Node) ApplySystemMutation( mutation NodesMutation, ) error
ApplySystemMutation should only used by internal persistence layer logic to force apply cluster specific chasm tree changes. DO NOT USE if you don't know why this method is introduced.
func (*Node) Archetype ¶ added in v1.28.0
Archetype returns the root component's fully qualified name. Deprecated: use ArchetypeID() instead, this method will be removed.
func (*Node) ArchetypeID ¶ added in v1.30.0
func (n *Node) ArchetypeID() ArchetypeID
ArchetypeID returns the framework's internal ID for the root component's fully qualified name.
func (*Node) CloseTransaction ¶ added in v1.28.0
func (n *Node) CloseTransaction() (NodesMutation, error)
CloseTransaction is used by MutableState to close the transaction and track changes made in the current transaction.
func (*Node) Component ¶ added in v1.28.0
func (n *Node) Component( chasmContext Context, ref ComponentRef, ) (Component, error)
Component retrieves a component from the tree rooted at node n using the provided component reference It also performs access rule, and task validation checks (for task processing requests) before returning the component.
func (*Node) ComponentByPath ¶ added in v1.29.0
func (*Node) EachPureTask ¶ added in v1.28.0
func (n *Node) EachPureTask( referenceTime time.Time, callback func(handler NodePureTask, taskAttributes TaskAttributes, taskInstance any) (bool, error), ) error
EachPureTask runs the callback for all expired/runnable pure tasks within the CHASM tree (including invalid tasks). The CHASM tree is left untouched, even if invalid tasks are detected (these are cleaned up as part of transaction close).
func (*Node) ExecutePureTask ¶ added in v1.28.0
func (n *Node) ExecutePureTask( baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any, ) (_ bool, retErr error)
ExecutePureTask validates and then executes the given taskInstance against the node's component. Executing an invalid task is a no-op (no error returned).
func (*Node) ExecuteSideEffectDiscardTask ¶ added in v1.31.0
func (n *Node) ExecuteSideEffectDiscardTask( ctx context.Context, executionKey ExecutionKey, chasmTask *tasks.ChasmTask, validate func(NodeBackend, Context, Component) error, ) error
ExecuteSideEffectDiscardTask executes the discard handler for the given ChasmTask. This is called on standby clusters when a side effect task has been pending past the discard delay, allowing custom discard behavior (e.g., spilling activity tasks to matching).
func (*Node) ExecuteSideEffectTask ¶ added in v1.29.0
func (n *Node) ExecuteSideEffectTask( ctx context.Context, executionKey ExecutionKey, chasmTask *tasks.ChasmTask, validate func(NodeBackend, Context, Component) error, ) error
ExecuteSideEffectTask executes the given ChasmTask on its associated node without holding the execution lock.
WARNING: This method *must not* access the node's properties without first locking the execution.
ctx should have a CHASM engine already set.
func (*Node) IsDirty ¶ added in v1.28.0
IsDirty returns true if any node in the tree has been modified, and need to be persisted in DB. The result will be reset to false after a call to CloseTransaction().
func (*Node) IsStale ¶ added in v1.28.0
func (n *Node) IsStale( ref ComponentRef, ) error
func (*Node) IsStateDirty ¶ added in v1.29.0
IsStateDirty returns true if any node in the tree has USER DATA modified, which need to be persisted to DB AND replicated to other clusters. The result will be reset to false after a call to CloseTransaction().
func (*Node) PartitionedSnapshot ¶
func (n *Node) PartitionedSnapshot( exclusiveMinVT *persistencespb.VersionedTransition, ) (NodesSnapshot, *persistencespb.ChasmLocalState)
PartitionedSnapshot returns the tree's state split into two parts:
- A NodesSnapshot with cluster-local fields (physical task statuses) zeroed, safe to upload to object storage or replicate to another cluster.
- A ChasmLocalState capturing the extracted cluster-local fields, keyed by encoded node path. Only nodes that carry such metadata are present.
The returned snapshot has the same node keys as Snapshot would: PartitionedSnapshot only zeroes field values, it never adds or removes nodes. The live in-memory tree is left untouched: nodes whose cluster-local fields are zeroed are deep-copied first, since Snapshot returns the tree's live node references.
The returned ChasmLocalState has an empty Nodes map when no node carries cluster-local fields; MergeClusterLocalState treats an empty (or nil) state as a no-op.
func (*Node) RefreshTasks ¶ added in v1.29.0
func (*Node) SetDeleteAfterClose ¶ added in v1.31.0
SetDeleteAfterClose suppresses the close visibility task when an execution is being terminated as part of a delete operation. Must be called before a [Terminate] call, like in DeleteExecution.
func (*Node) SetRootComponent ¶ added in v1.29.0
func (n *Node) SetRootComponent( rootComponent RootComponent, ) error
func (*Node) Snapshot ¶ added in v1.28.0
func (n *Node) Snapshot( exclusiveMinVT *persistencespb.VersionedTransition, ) NodesSnapshot
Snapshot returns all nodes in the tree that have been modified after the given min versioned transition. A nil exclusiveMinVT will be treated as the same as the zero versioned transition and returns all nodes in the tree. This method should only be invoked on root CHASM node when IsDirty() is false.
func (*Node) Terminate ¶ added in v1.28.0
func (n *Node) Terminate( request TerminateComponentRequest, ) error
func (*Node) ValidateSideEffectTask ¶ added in v1.29.0
func (n *Node) ValidateSideEffectTask( ctx context.Context, chasmTask *tasks.ChasmTask, ) (isTaskInTree bool, isValidByComponent bool, retErr error)
ValidateSideEffectTask checks whether a side effect task should still be executed. Intended for use by standby handlers.
It returns two booleans:
- isTaskInTree: true if the task's logical counterpart still exists in the replicated tree state (node found, InitialVersionedTransition matches, and logical task present in SideEffectTasks). A false value here means the active cluster has definitively invalidated the task via replication — the physical task should be dropped.
- isValidByComponent: true if the component's own Validate method approves the task. Only meaningful when isTaskInTree is true. A false value here may be a transient false-negative caused by a code deployment changing validation logic without a corresponding state change.
If an error is returned both booleans are false.
type NodeBackend ¶ added in v1.28.0
type NodeBackend interface {
// TODO: Add methods needed from MutateState here.
GetExecutionState() *persistencespb.WorkflowExecutionState
GetExecutionInfo() *persistencespb.WorkflowExecutionInfo
GetApproximatePersistedSize() int
ChasmSkipPersistenceEnabled() bool
GetNamespaceEntry() *namespace.Namespace
GetCurrentVersion() int64
NextTransitionCount() int64
CurrentVersionedTransition() *persistencespb.VersionedTransition
GetWorkflowKey() definition.WorkflowKey
AddTasks(...tasks.Task)
AddHistoryEvent(t enumspb.EventType, setAttributes func(*historypb.HistoryEvent)) *historypb.HistoryEvent
GenerateEventLoadToken(event *historypb.HistoryEvent) ([]byte, error)
LoadHistoryEvent(ctx context.Context, token []byte) (*historypb.HistoryEvent, error)
HasAnyBufferedEvent(filter func(*historypb.HistoryEvent) bool) bool
DeleteCHASMPureTasks(maxScheduledTime time.Time)
UpdateWorkflowStateStatus(
state enumsspb.WorkflowExecutionState,
status enumspb.WorkflowExecutionStatus,
) (bool, error)
IsWorkflow() bool
GetNexusCompletion(
ctx context.Context,
requestID string,
) (nexusrpc.CompleteOperationOptions, error)
GetNexusUpdateCompletion(
ctx context.Context,
updateID string,
requestID string,
) (nexusrpc.CompleteOperationOptions, error)
EndpointRegistry() EndpointRegistry
}
NodeBackend is a set of methods needed from MutableState.
This is for breaking cycle dependency between this package and service/history/workflow package where MutableState is defined.
type NodePathEncoder ¶ added in v1.28.0
type NodePathEncoder interface {
Encode(node *Node, path []string) (string, error)
// TODO: Return a iterator on node name instead of []string,
// so that we can get a node by encoded path without additional
// allocation for the decoded path.
Decode(encodedPath string) ([]string, error)
}
NodePathEncoder is an interface for encoding and decoding node paths. Logic outside the chasm package should only work with encoded paths.
var DefaultPathEncoder NodePathEncoder = &defaultPathEncoder{}
type NodePureTask ¶ added in v1.29.0
type NodePureTask interface {
ExecutePureTask(baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any) (bool, error)
}
NodePureTask is intended to be implemented and used within the CHASM framework only.
type NodesMutation ¶ added in v1.28.0
type NodesMutation struct {
UpdatedNodes map[string]*persistencespb.ChasmNode // encoded node path -> chasm node
DeletedNodes map[string]struct{}
}
NodesMutation is a set of mutations for all nodes rooted at a given node n, including the node n itself.
type NodesSnapshot ¶ added in v1.28.0
type NodesSnapshot struct {
Nodes map[string]*persistencespb.ChasmNode // encoded node path -> chasm node
}
NodesSnapshot is a snapshot for all nodes rooted at a given node n, including the node n itself.
func (*NodesSnapshot) MergeClusterLocalState ¶
func (s *NodesSnapshot) MergeClusterLocalState(state *persistencespb.ChasmLocalState) ClusterLocalStateMergeResult
MergeClusterLocalState restores cluster-local metadata into the snapshot, inverting the extraction performed by PartitionedSnapshot. Nodes present in both the snapshot and the state are updated; nodes in the state but not the snapshot are silently skipped (the node may have been deleted). Statuses are matched to tasks by position; a length mismatch applies only the overlapping prefix. It returns per-direction counts of nodes whose status count didn't match the task count (see ClusterLocalStateMergeResult), so callers can react to a (usually stale-data) merge and escalate the suspicious direction.
The merge performs no version/ordering checks; callers must apply it only against a final local tree (e.g. defer until the execution is completed and its close version has caught up to the source), so a length mismatch signals real divergence rather than normal replication lag.
type OperationIntent ¶
type OperationIntent int
OperationIntent declares how a caller intends to access a component. Set it with NewContextWithOperationIntent.
const ( // OperationIntentProgress means the caller intends to modify the component. // Rejected for closed executions. OperationIntentProgress OperationIntent = 1 << iota // OperationIntentObserve means the caller only intends to read the component. // Allowed for closed executions. OperationIntentObserve // OperationIntentUnspecified is the zero value and is treated like observe. OperationIntentUnspecified = OperationIntent(0) )
type ParentPtr ¶ added in v1.30.0
type ParentPtr[T any] struct { // Exporting this field as this generic struct needs to be created via reflection, // and reflection can't set private fields. Internal parentPtrInternal }
ParentPtr is a in-memory pointer to the parent component of a CHASM component.
CHASM map is not a component, so if a component is inside a map, its ParentPtr will point to the nearest ancestor component that is not a map.
ParentPtr is only initialized and available for use **after** the transition that creates the component using ParentPtr is completed.
func NewMockParentPtr ¶
NewMockParentPtr creates a ParentPtr[T] backed by real Node instances that returns the given parent value when Get or TryGet is called. This is intended for use in unit tests where a full CHASM tree is not needed.
func (ParentPtr[T]) Get ¶ added in v1.30.0
Get returns the parent component, deserializing it if necessary. Panics rather than returning an error, as errors are supposed to be handled by the framework as opposed to the application.
type PureTaskHandler ¶ added in v1.31.0
type PureTaskHandler[C any, T any] interface { TaskValidator[C, T] Execute(MutableContext, C, TaskAttributes, T) error // contains filtered or unexported methods }
PureTaskHandler handles pure tasks that run while holding execution state write lock and should not do I/O. Implementations must embed PureTaskHandlerBase.
type PureTaskHandlerBase ¶ added in v1.31.0
type PureTaskHandlerBase struct{}
PureTaskHandlerBase must be embedded in all pure task handler implementations.
type RefConsistencyLevel ¶
type RefConsistencyLevel int
RefConsistencyLevel controls how strictly a ComponentRef is validated when it is used to address a component in UpdateComponent. Each level selects which versioned transition the execution staleness check (Node.IsStale) keys off — i.e. how fresh the loaded mutable state must be — and, at the weakest level, whether the run ID is honored. It governs only the consistency-token / run resolution of the ref; archetype validation and access-intent (operation-intent) checks always apply.
The levels form a ladder from strongest to weakest:
- ExecutionLastUpdate: staleness is checked against the execution's last-update versioned transition — the loaded state must be at the exact transition the ref was taken at. Strongest; the default.
- ComponentCreation: staleness is checked against the target component's initial (creation) versioned transition — the loaded state need only be at least as new as when the component was created (so it is guaranteed to know about the component), tolerating a stale execution transition. The creation transition is additionally matched in Node.Component so the same component instance must still exist at the path.
- CurrentRun: the ref is resolved by component path on the current run, dropping the run ID and every versioned transition (no staleness check). Callers relying on this level must re-establish identity in component logic (e.g. by request ID). Weakest; note this resolves the current run only and does NOT verify the ref's run and the current run are in the same chain.
const ( RefConsistencyLevelExecutionLastUpdate RefConsistencyLevel = iota RefConsistencyLevelComponentCreation RefConsistencyLevelCurrentRun )
type RegisterableNexusOperationProcessor ¶ added in v1.31.0
type RegisterableNexusOperationProcessor struct {
// contains filtered or unexported fields
}
RegisterableNexusOperationProcessor adapts a typed Nexus operation processor for dynamic registration and invocation within a service processor.
func NewRegisterableNexusOperationProcessor ¶ added in v1.31.0
func NewRegisterableNexusOperationProcessor[I any](op NexusOperationProcessor[I]) RegisterableNexusOperationProcessor
NewRegisterableNexusOperationProcessor wraps a typed NexusOperationProcessor and returns a registerable adapter.
type RegistrableComponent ¶
type RegistrableComponent struct {
// contains filtered or unexported fields
}
func NewRegistrableComponent ¶
func NewRegistrableComponent[C Component]( componentType string, opts ...RegistrableComponentOption, ) *RegistrableComponent
func (*RegistrableComponent) GoType ¶ added in v1.31.0
func (rc *RegistrableComponent) GoType() reflect.Type
GoType returns the reflect.Type of the component's Go struct.
func (*RegistrableComponent) IsDetached ¶ added in v1.31.0
func (rc *RegistrableComponent) IsDetached() bool
IsDetached returns true if the component type is registered as detached.
func (*RegistrableComponent) SearchAttributesMapper ¶ added in v1.30.0
func (rc *RegistrableComponent) SearchAttributesMapper() *VisibilitySearchAttributesMapper
SearchAttributesMapper returns the search attributes mapper for this component.
type RegistrableComponentOption ¶
type RegistrableComponentOption func(*RegistrableComponent)
func WithBusinessIDAlias ¶ added in v1.30.0
func WithBusinessIDAlias( alias string, ) RegistrableComponentOption
WithBusinessIDAlias allows specifying the business ID alias of the component. This option must be specified if the archetype uses the Visibility component.
func WithContextValues ¶ added in v1.31.0
func WithContextValues( keyVals map[any]any, ) RegistrableComponentOption
WithContextValues allows specifying key-value pairs that will be available in the Context via the Value() method whenever the chasm framework starts, updates, reads, polls, executes or validates tasks on a component.
This is useful for propagating values needed for those processing logic but are not avaiable via the component's struct definition, such as configurations.
Keys need to be globally unique across components. Conflicting keys across will cause component registration to fail.
Manually added key-value pairs via ContextWithValue() will take precedence over registered context values.
func WithDetached ¶ added in v1.31.0
func WithDetached() RegistrableComponentOption
WithDetached marks the registrable component as detached. Detached components ignore parent lifecycle validation, allowing them to continue operating when their parent is closed/terminated. If a registrable component is not detached by default, a component definition can specify its child as detached via ComponentFieldDetached() option.
func WithEphemeral ¶
func WithEphemeral() RegistrableComponentOption
func WithSearchAttributes ¶ added in v1.30.0
func WithSearchAttributes( searchAttributes ...SearchAttribute, ) RegistrableComponentOption
func WithSingleCluster ¶
func WithSingleCluster() RegistrableComponentOption
Is there any use case where we don't want to replicate certain instances of a archetype?
type RegistrableTask ¶
type RegistrableTask struct {
// contains filtered or unexported fields
}
func NewRegistrablePureTask ¶ added in v1.28.0
func NewRegistrablePureTask[C any, T any]( taskType string, handler PureTaskHandler[C, T], opts ...RegistrableTaskOption, ) *RegistrableTask
func NewRegistrableSideEffectTask ¶ added in v1.28.0
func NewRegistrableSideEffectTask[C any, T any]( taskType string, handler SideEffectTaskHandler[C, T], opts ...RegistrableTaskOption, ) *RegistrableTask
NewRegistrableSideEffectTask creates a new registrable side-effect task. NOTE: C is not Component but any. The handler's Discard method is called on standby clusters when a task has been pending past the discard delay.
func (*RegistrableTask) GoType ¶ added in v1.31.0
func (rt *RegistrableTask) GoType() reflect.Type
GoType returns the reflect.Type of the task's Go struct.
func (*RegistrableTask) TaskGroup ¶
func (rt *RegistrableTask) TaskGroup() string
TaskGroup returns the side-effect task group for the task.
type RegistrableTaskOption ¶
type RegistrableTaskOption func(*RegistrableTask)
func WithSingletonTask ¶
func WithSingletonTask(mode SingletonTaskMode) RegistrableTaskOption
WithSingletonTask configures the task type as a singleton: at most one task of this type may exist per component instance at any time. The mode controls what happens when a new task is added while one already exists:
- SingletonTaskModeReplace: the existing task is removed and the new one takes its place.
- SingletonTaskModeIgnore: the existing task is kept and the new one is discarded.
Singleton semantics are enforced after task validation, so an invalid new task is dropped before any replacement or ignore logic applies.
func WithTaskGroup ¶
func WithTaskGroup(taskgroup string) RegistrableTaskOption
WithTaskGroup sets the task group for the task. The task group is used when the side effect's destination is specified for grouping semantics on the outbound queue, affects multi-cursor and the circuit breaker. If task group isn't provided, the task group will default to the fully qualified name at library registration.
type Registry ¶
type Registry struct {
NexusEndpointProcessor *NexusEndpointProcessor
// contains filtered or unexported fields
}
func NewRegistry ¶
func (*Registry) ArchetypeDisplayName ¶ added in v1.31.0
func (r *Registry) ArchetypeDisplayName(id ArchetypeID) (string, bool)
ArchetypeDisplayName returns the human-readable name for a given archetype ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.
func (*Registry) ArchetypeIDOf ¶ added in v1.30.0
func (r *Registry) ArchetypeIDOf(componentGoType reflect.Type) (ArchetypeID, bool)
ArchetypeIDOf returns the ArchetypeID for the given component Go type. This method should only be used by CHASM framework internal code, NOT CHASM library developers.
func (*Registry) ComponentByID ¶ added in v1.30.0
func (r *Registry) ComponentByID(id uint32) (*RegistrableComponent, bool)
ComponentByID returns the registrable component for a given archetype ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.
func (*Registry) ComponentFqnByID ¶ added in v1.30.0
ComponentFqnByID converts component type ID to fully qualified component type name. This method should only be used by CHASM framework internal code, NOT CHASM library developers.
func (*Registry) ComponentIDByFqn ¶ added in v1.30.0
ComponentIDByFqn converts fully qualified component type name to component type ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.
func (*Registry) ComponentIDFor ¶ added in v1.30.0
ComponentIDFor converts registered component instance to component type ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.
func (*Registry) NexusServices ¶ added in v1.31.0
NexusServices returns all registered Nexus services.
func (*Registry) RegisterServices ¶ added in v1.30.0
RegisterServices registers all gRPC services from all registered libraries.
func (*Registry) TaskByID ¶ added in v1.31.0
func (r *Registry) TaskByID(id uint32) (*RegistrableTask, bool)
TaskByID returns the registrable task for a given task type ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.
func (*Registry) TaskFqnByID ¶ added in v1.30.0
TaskFqnByID converts task type ID to fully qualified task type name. This method should only be used by CHASM framework internal code, NOT CHASM library developers.
type RootComponent ¶ added in v1.31.0
type RootComponent interface {
TerminableComponent
// ContextMetadata returns execution metadata to propagate to the request context.
// When the ContextMetadataInterceptor is configured with setTrailer=true (history, matching),
// these keys are propagated via gRPC trailers. Keys defined in common/contextutil/metadata.go.
ContextMetadata(Context) map[string]string
}
RootComponent is the interface that must be implemented by the top level component of a chasm execution. When the RootComponent's LifecycleState transitions to a closed state, the entire execution is considered closed, and will be cleaned up by the chasm framework after namespace's retention period. The BusinessID is also available for reuse.
TODO: (not yet true) Visibility record will no longer be updated after RootComponent is closed.
type SearchAttribute ¶ added in v1.30.0
type SearchAttribute interface {
// contains filtered or unexported methods
}
SearchAttribute is a shared interface for all search attribute types. Each type must embed searchAttributeDefinition.
type SearchAttributeBool ¶ added in v1.30.0
type SearchAttributeBool struct {
// contains filtered or unexported fields
}
SearchAttributeBool is a search attribute for a boolean value.
func NewSearchAttributeBool ¶ added in v1.30.0
func NewSearchAttributeBool(alias string, boolField SearchAttributeFieldBool) SearchAttributeBool
NewSearchAttributeBool creates a new boolean search attribute given a predefined chasm field
func (SearchAttributeBool) Value ¶ added in v1.30.0
func (s SearchAttributeBool) Value(value bool) SearchAttributeKeyValue
Value sets the boolean value of the search attribute.
type SearchAttributeDateTime ¶ added in v1.30.0
type SearchAttributeDateTime struct {
// contains filtered or unexported fields
}
SearchAttributeDateTime is a search attribute for a datetime value.
func NewSearchAttributeDateTime ¶ added in v1.30.0
func NewSearchAttributeDateTime(alias string, datetimeField SearchAttributeFieldDateTime) SearchAttributeDateTime
NewSearchAttributeDateTime creates a new date time search attribute given a predefined chasm field
func (SearchAttributeDateTime) Value ¶ added in v1.30.0
func (s SearchAttributeDateTime) Value(value time.Time) SearchAttributeKeyValue
Value sets the date time value of the search attribute.
type SearchAttributeDouble ¶ added in v1.30.0
type SearchAttributeDouble struct {
// contains filtered or unexported fields
}
SearchAttributeDouble is a search attribute for a double value.
func NewSearchAttributeDouble ¶ added in v1.30.0
func NewSearchAttributeDouble(alias string, doubleField SearchAttributeFieldDouble) SearchAttributeDouble
NewSearchAttributeDouble creates a new double search attribute given a predefined chasm field
func (SearchAttributeDouble) Value ¶ added in v1.30.0
func (s SearchAttributeDouble) Value(value float64) SearchAttributeKeyValue
Value sets the double value of the search attribute.
type SearchAttributeFieldBool ¶ added in v1.30.0
type SearchAttributeFieldBool struct {
// contains filtered or unexported fields
}
SearchAttributeFieldBool is a search attribute field for a boolean value.
type SearchAttributeFieldDateTime ¶ added in v1.30.0
type SearchAttributeFieldDateTime struct {
// contains filtered or unexported fields
}
SearchAttributeFieldDateTime is a search attribute field for a datetime value.
type SearchAttributeFieldDouble ¶ added in v1.30.0
type SearchAttributeFieldDouble struct {
// contains filtered or unexported fields
}
SearchAttributeFieldDouble is a search attribute field for a double value.
type SearchAttributeFieldInt ¶ added in v1.30.0
type SearchAttributeFieldInt struct {
// contains filtered or unexported fields
}
SearchAttributeFieldInt is a search attribute field for an integer value.
type SearchAttributeFieldKeyword ¶ added in v1.30.0
type SearchAttributeFieldKeyword struct {
// contains filtered or unexported fields
}
SearchAttributeFieldKeyword is a search attribute field for a keyword value.
type SearchAttributeFieldKeywordList ¶ added in v1.30.0
type SearchAttributeFieldKeywordList struct {
// contains filtered or unexported fields
}
SearchAttributeFieldKeywordList is a search attribute field for a keyword list value.
type SearchAttributeFieldText ¶
type SearchAttributeFieldText struct {
// contains filtered or unexported fields
}
SearchAttributeFieldText is a search attribute field for a text value.
type SearchAttributeInt ¶ added in v1.30.0
type SearchAttributeInt struct {
// contains filtered or unexported fields
}
SearchAttributeInt is a search attribute for an integer value.
func NewSearchAttributeInt ¶ added in v1.30.0
func NewSearchAttributeInt(alias string, intField SearchAttributeFieldInt) SearchAttributeInt
NewSearchAttributeInt creates a new integer search attribute given a predefined chasm field
func (SearchAttributeInt) Value ¶ added in v1.30.0
func (s SearchAttributeInt) Value(value int64) SearchAttributeKeyValue
Value sets the integer value of the search attribute.
type SearchAttributeKeyValue ¶ added in v1.30.0
type SearchAttributeKeyValue struct {
// Alias refers to the user defined name of the search attribute
Alias string
// Field refers to a fully formed schema field, which is a Predefined CHASM search attribute
Field string
// Value refers to the current value of the search attribute. Must support encoding to a Payload.
Value VisibilityValue
}
SearchAttributeKeyValue is a key value pair of a search attribute. Represents the current value of a search attribute in a CHASM Component during a transaction.
type SearchAttributeKeyword ¶ added in v1.30.0
type SearchAttributeKeyword struct {
// contains filtered or unexported fields
}
SearchAttributeKeyword is a search attribute for a keyword value.
func NewSearchAttributeKeyword ¶ added in v1.30.0
func NewSearchAttributeKeyword(alias string, keywordField SearchAttributeFieldKeyword) SearchAttributeKeyword
NewSearchAttributeKeyword creates a new keyword search attribute given a predefined chasm field
func (SearchAttributeKeyword) Value ¶ added in v1.30.0
func (s SearchAttributeKeyword) Value(value string) SearchAttributeKeyValue
Value sets the string value of the search attribute.
type SearchAttributeKeywordList ¶ added in v1.30.0
type SearchAttributeKeywordList struct {
// contains filtered or unexported fields
}
SearchAttributeKeywordList is a search attribute for a keyword list value.
func NewSearchAttributeKeywordList ¶ added in v1.30.0
func NewSearchAttributeKeywordList(alias string, keywordListField SearchAttributeFieldKeywordList) SearchAttributeKeywordList
NewSearchAttributeKeywordList creates a new keyword list search attribute given a predefined chasm field
func (SearchAttributeKeywordList) Value ¶ added in v1.30.0
func (s SearchAttributeKeywordList) Value(value []string) SearchAttributeKeyValue
Value sets the string list value of the search attribute.
type SearchAttributeText ¶
type SearchAttributeText struct {
// contains filtered or unexported fields
}
SearchAttributeText is a search attribute for a text value.
func NewSearchAttributeText ¶
func NewSearchAttributeText(alias string, textField SearchAttributeFieldText) SearchAttributeText
NewSearchAttributeText creates a new text search attribute given a predefined chasm field
func (SearchAttributeText) Value ¶
func (s SearchAttributeText) Value(value string) SearchAttributeKeyValue
Value sets the string value of the search attribute.
type SearchAttributesMap ¶ added in v1.30.0
type SearchAttributesMap struct {
// contains filtered or unexported fields
}
SearchAttributesMap wraps search attribute values with type-safe access.
func NewSearchAttributesMap ¶ added in v1.30.0
func NewSearchAttributesMap(values map[string]VisibilityValue) SearchAttributesMap
NewSearchAttributesMap creates a new SearchAttributeMap from raw values.
type SideEffectTaskHandler ¶ added in v1.31.0
type SideEffectTaskHandler[C any, T any] interface { TaskValidator[C, T] Execute(context.Context, ComponentRef, TaskAttributes, T) error // Discard implements custom discard behavior on standby clusters. When a side-effect task has been // pending on standby past the discard delay, the framework calls Discard instead of silently dropping // the task. For example, the activity dispatch handler implements this to spill tasks to matching. // The ctx carries engine access, but implementations must avoid mutating component state on standby // clusters. Discard(context.Context, ComponentRef, TaskAttributes, T) error // contains filtered or unexported methods }
SideEffectTaskHandler handles side effect tasks that run outside of the state lock and have access to a Go context to perform I/O and access chasm engine methods such as UpdateComponent. Implementations must embed SideEffectTaskHandlerBase.
type SideEffectTaskHandlerBase ¶ added in v1.31.0
type SideEffectTaskHandlerBase[T any] struct{}
SideEffectTaskHandlerBase provides a default Discard implementation that returns ErrTaskDiscarded. Embed this in side-effect task handler structs to satisfy the SideEffectTaskHandler interface.
func (SideEffectTaskHandlerBase[T]) Discard ¶ added in v1.31.0
func (SideEffectTaskHandlerBase[T]) Discard(_ context.Context, _ ComponentRef, _ TaskAttributes, _ T) error
type SingletonTaskMode ¶
type SingletonTaskMode int
SingletonTaskMode controls how the framework handles a new task of a singleton type when a task of the same type already exists on the component instance.
const ( // SingletonTaskModeReplace removes the existing task and schedules the new one in its place. SingletonTaskModeReplace SingletonTaskMode = iota + 1 // SingletonTaskModeIgnore keeps the existing task and discards the new one. SingletonTaskModeIgnore )
type StartExecutionResult ¶ added in v1.31.0
type StartExecutionResult struct {
ExecutionKey ExecutionKey
ExecutionRef []byte
Created bool
}
StartExecutionResult contains the outcome of creating a new execution via StartExecution.
This struct provides information about whether a new execution was actually created, along with identifiers needed to reference the execution in subsequent operations.
Fields:
- ExecutionKey: The unique identifier for the execution. This key can be used to look up or reference the execution in future operations.
- ExecutionRef: A serialized reference to the newly created root component. This can be passed to UpdateComponent, ReadComponent, or PollComponent to interact with the component. Use DeserializeComponentRef to convert this back to a ComponentRef if needed.
- Created: Indicates whether a new execution was actually created. When false, the execution already existed (based on the BusinessIDReusePolicy and BusinessIDConflictPolicy configured via WithBusinessIDPolicy), and the existing execution was returned instead.
func StartExecution ¶ added in v1.31.0
func StartExecution[C RootComponent, I any]( ctx context.Context, key ExecutionKey, startFn func(MutableContext, I) (C, error), input I, opts ...TransitionOption, ) (StartExecutionResult, error)
StartExecution creates a new execution with a component initialized by the provided factory function.
This is the primary entry point for starting a new execution in the CHASM engine. It handles the lifecycle of creating and persisting a new component within an execution context.
Type Parameters:
- C: The component type to create, must implement RootComponent
- I: The input type passed to the factory function
- O: The output type returned by the factory function
Parameters:
- ctx: Context containing the CHASM engine (must be created via NewEngineContext)
- key: Unique identifier for the execution, used for deduplication and lookup
- startFn: Factory function that creates the component and produces output. Receives a MutableContext for accessing engine capabilities and the input value.
- input: Application-specific data passed to startFn
- opts: Optional TransitionOption functions to configure creation behavior:
- WithBusinessIDPolicy: Controls duplicate handling and conflict resolution
- WithRequestID: Sets a request ID for idempotency
- WithSpeculative: Defers persistence until the next non-speculative transition
Returns:
- O: The output value produced by startFn
- [NewExecutionResult]: Contains the execution key, serialized ref, and whether a new execution was created
- error: Non-nil if creation failed or policy constraints were violated
type StateMachine ¶ added in v1.30.0
type StateMachine[S comparable] interface { StateMachineState() S SetStateMachineState(S) }
A StateMachine is anything that can get and set a comparable state S and re-generate tasks based on current state. It is meant to be used with Transition objects to safely transition their state on a given event.
type TaskAttributes ¶
type TaskAttributes struct {
// ScheduledTime is when the task should fire. Use [TaskScheduledTimeImmediate] (zero value)
// for tasks that should execute as soon as possible.
ScheduledTime time.Time
// Destination is an optional routing key for outbound tasks (e.g., a URL host for HTTP
// callbacks). When non-empty, the task is categorized as outbound; when empty, it is
// categorized as a transfer task. Destination must only be set on immediate tasks.
Destination string
}
TaskAttributes specifies scheduling metadata for a task, supplied by the component author when the task is added via MutableContext.AddTask.
func (*TaskAttributes) IsImmediate ¶ added in v1.30.0
func (a *TaskAttributes) IsImmediate() bool
IsImmediate reports whether the task is scheduled for immediate execution (zero or unset scheduled time).
func (*TaskAttributes) IsValid ¶ added in v1.30.0
func (a *TaskAttributes) IsValid() bool
IsValid reports whether the task attributes are well-formed. A Destination may only be set on immediate tasks; deferred tasks with a Destination are invalid.
type TaskInvocation ¶
type TaskInvocation struct {
TaskAttributes
// Attempt is the current processing attempt for this task, starting at 1. It comes from the
// task executable and is not persisted; it resets to 1 on shard reload and on active or
// standby failover. It is 0 when the task is validated outside of task processing, such as
// during transaction close. A best effort validator may compare it against a threshold and
// return false to give up on a task that would otherwise never become invalid on its own.
Attempt int
}
TaskInvocation is passed to a task's Validate callback. It carries the task's TaskAttributes together with framework-supplied state for the current processing attempt.
type TaskValidator ¶ added in v1.28.0
type TaskValidator[C any, T any] interface { // Validate determines whether a task should proceed with execution based on the current context, component // state, task attributes, and task data. // // This function serves as a gate to prevent unnecessary task execution in several scenarios: // 1. Standby cluster deduplication: When state is replicated to standby clusters, tasks are also replicated. // Validate allows standby clusters to check if a task was already completed on the active cluster and // skip execution if so (e.g., checking if an activity already transitioned from scheduled to started state). // 2. Task obsolescence: Tasks can become irrelevant when state changes invalidate them (e.g., when a scheduler // is updated to run at a different time, making the previously scheduled task invalid for the new state). // For pure tasks that can run in a single transaction, Validate is called before execution to avoid // unnecessary work. // // The framework automatically calls Validate at key points, such as after closing transactions, to check all // generated tasks before they execute. // // Returns: // - (true, nil) if the task is valid and should be executed // - (false, nil) if the task should be silently dropped (it's no longer relevant) // - (anything, error) if validation fails with an error Validate(Context, C, TaskInvocation, T) (bool, error) }
TaskValidator is implemented by both SideEffectTaskHandler and PureTaskHandler to gate whether a task should proceed with execution.
type TerminableComponent ¶ added in v1.31.0
type TerminableComponent interface {
Component
// Terminate method is invoked by the chasm framework on an execution's root component when the execution
// needs to be forcefully terminated.
// Some examples include:
// - Execution state becomes too large.
// - Two running executions with the same businessID when namespace performs a force failover.
Terminate(MutableContext, TerminateComponentRequest) (TerminateComponentResponse, error)
}
type TerminateComponentRequest ¶ added in v1.28.0
type TerminateComponentResponse ¶ added in v1.28.0
type TerminateComponentResponse struct{}
type Transition ¶ added in v1.30.0
type Transition[S comparable, SM StateMachine[S], E any] struct { // Source states that are valid for this transition. Sources []S // Destination state to transition to. Destination S // contains filtered or unexported fields }
Transition represents a state machine transition for a machine of type SM with state S and event E.
func NewTransition ¶ added in v1.30.0
func NewTransition[S comparable, SM StateMachine[S], E any](src []S, dst S, apply func(SM, MutableContext, E) error) Transition[S, SM, E]
NewTransition creates a new Transition from the given source states to a destination state for a given event. The apply function is called after verifying the transition is possible but before setting the destination state, so it can inspect the current (source) state.
func (Transition[S, SM, E]) Apply ¶ added in v1.30.0
func (t Transition[S, SM, E]) Apply(sm SM, ctx MutableContext, event E) (retErr error)
Apply applies a transition event to the given state machine changing the state machine's state to the transition's Destination on success. The apply function is called before the state is changed, so it can inspect the current (source) state.
func (Transition[S, SM, E]) Possible ¶ added in v1.30.0
func (t Transition[S, SM, E]) Possible(sm SM) bool
Possible returns a boolean indicating whether the transition is possible for the current state.
type TransitionOption ¶
type TransitionOption func(*TransitionOptions)
func WithBusinessIDPolicy ¶
func WithBusinessIDPolicy( reusePolicy BusinessIDReusePolicy, conflictPolicy BusinessIDConflictPolicy, ) TransitionOption
WithBusinessIDPolicy sets the businessID reuse and conflict policy used in the transition when creating a new execution. This option only applies to StartExecution() and UpdateWithStartExecution().
func WithRefConsistencyLevel ¶
func WithRefConsistencyLevel(level RefConsistencyLevel) TransitionOption
WithRefConsistencyLevel sets the RefConsistencyLevel for the transition, controlling how strictly the supplied component ref is validated. Currently only UpdateComponent() honors it; it defaults to RefConsistencyLevelExecutionLastUpdate.
func WithRequestID ¶ added in v1.29.0
func WithRequestID( requestID string, ) TransitionOption
WithRequestID sets the requestID used when creating a new execution. This option only applies to StartExecution() and UpdateWithStartExecution().
func WithSpeculative ¶
func WithSpeculative() TransitionOption
(only) this transition will not be persisted The next non-speculative transition will persist this transition as well. Compared to the ExecutionEphemeral() operation on RegistrableComponent, the scope of this operation is limited to a certain transition, while the ExecutionEphemeral() applies to all transitions. TODO: we need to figure out a way to run the tasks generated in a speculative transition
type TransitionOptions ¶ added in v1.29.0
type TransitionOptions struct {
ReusePolicy BusinessIDReusePolicy
ConflictPolicy BusinessIDConflictPolicy
ConsistencyLevel RefConsistencyLevel
RequestID string
Speculative bool
}
type UnimplementedComponent ¶
type UnimplementedComponent struct{}
Embed UnimplementedComponent to get forward compatibility
type UnimplementedLibrary ¶
type UnimplementedLibrary struct{}
func (UnimplementedLibrary) Components ¶
func (UnimplementedLibrary) Components() []*RegistrableComponent
func (UnimplementedLibrary) NexusServiceProcessors ¶ added in v1.31.0
func (UnimplementedLibrary) NexusServiceProcessors() []*NexusServiceProcessor
func (UnimplementedLibrary) NexusServices ¶ added in v1.31.0
func (UnimplementedLibrary) NexusServices() []*nexus.Service
func (UnimplementedLibrary) RegisterServices ¶ added in v1.30.0
func (UnimplementedLibrary) RegisterServices(_ *grpc.Server)
RegisterServices Registers the gRPC calls to the handlers of the library.
func (UnimplementedLibrary) Tasks ¶
func (UnimplementedLibrary) Tasks() []*RegistrableTask
type UpdateWithStartExecutionResult ¶ added in v1.31.0
type UpdateWithStartExecutionResult[O any] struct { ExecutionKey ExecutionKey ExecutionRef []byte Created bool UpdateOutput O }
UpdateWithStartExecutionResult is the result of a UpdateWithStartExecution operation.
Fields:
- ExecutionKey: The unique identifier for the execution. This key can be used to look up or reference the execution in future operations.
- ExecutionRef: A serialized reference to the newly created root component. This can be passed to UpdateComponent, ReadComponent, or PollComponent to interact with the component. Use DeserializeComponentRef to convert this back to a ComponentRef if needed.
- Created: Indicates whether a new execution was actually created. When false, the execution already existed (based on the BusinessIDReusePolicy and BusinessIDConflictPolicy configured via WithBusinessIDPolicy), and the existing execution was returned instead.
- UpdateOutput: The output value returned by the update function.
func UpdateWithStartExecution ¶ added in v1.31.0
func UpdateWithStartExecution[C RootComponent, I any, O any]( ctx context.Context, key ExecutionKey, startFn func(MutableContext, I) (C, error), updateFn func(C, MutableContext, I) (O, error), input I, opts ...TransitionOption, ) (UpdateWithStartExecutionResult[O], error)
type Visibility ¶ added in v1.29.0
type Visibility struct {
UnimplementedComponent
Data *persistencespb.ChasmVisibilityData
// Do NOT access those fields directly.
// Use the provided getters and setters instead.
SA Field[*commonpb.SearchAttributes]
Memo Field[*commonpb.Memo]
}
func NewVisibility ¶ added in v1.29.0
func NewVisibility( mutableContext MutableContext, ) *Visibility
func NewVisibilityWithData ¶ added in v1.30.0
func NewVisibilityWithData( mutableContext MutableContext, customSearchAttributes map[string]*commonpb.Payload, customMemo map[string]*commonpb.Payload, ) *Visibility
func (*Visibility) CustomMemo ¶ added in v1.30.0
func (v *Visibility) CustomMemo( chasmContext Context, ) map[string]*commonpb.Payload
CustomMemo returns the stored custom memo fields. Nil is returned if there are none.
Returned map is a shallow copy: callers may add, delete, or reassign keys without affecting the stored data, but the *commonpb.Payload values are shared.
func (*Visibility) CustomSearchAttributes ¶ added in v1.30.0
func (v *Visibility) CustomSearchAttributes( chasmContext Context, ) map[string]*commonpb.Payload
CustomSearchAttributes returns the stored custom search attribute fields. Nil is returned if there are none.
Returned map is a shallow copy: callers may add, delete, or reassign keys without affecting the stored data, but the *commonpb.Payload values are shared.
func (*Visibility) LifecycleState ¶ added in v1.29.0
func (v *Visibility) LifecycleState(_ Context) LifecycleState
func (*Visibility) MergeCustomMemo ¶ added in v1.30.0
func (v *Visibility) MergeCustomMemo( mutableContext MutableContext, customMemo map[string]*commonpb.Payload, )
MergeCustomMemo merges the provided custom memo fields into the existing ones.
- If a key in `customMemo` already exists, the value in `customMemo` replaces the existing value.
- If a key in `customMemo` has nil or empty slice payload value, the key is deleted from the existing memo if it exists. If all memo fields are removed, the underlying memo node is deleted.
- If `customMemo` is empty, this is a no-op.
func (*Visibility) MergeCustomSearchAttributes ¶ added in v1.30.0
func (v *Visibility) MergeCustomSearchAttributes( mutableContext MutableContext, customSearchAttributes map[string]*commonpb.Payload, )
MergeCustomSearchAttributes merges the provided custom search attribute fields into the existing ones.
- If a key in `customSearchAttributes` already exists, the value in `customSearchAttributes` replaces the existing value.
- If a key in `customSearchAttributes` has nil or empty slice payload value, the key is deleted from the existing search attributes if it exists. If all search attributes are removed, the underlying search attributes node is deleted.
- If `customSearchAttributes` is empty, this is a no-op.
func (*Visibility) ReplaceCustomMemo ¶ added in v1.30.0
func (v *Visibility) ReplaceCustomMemo( mutableContext MutableContext, customMemo map[string]*commonpb.Payload, )
ReplaceCustomMemo replaces the existing custom memo fields with the provided ones. If `customMemo` is empty, the underlying memo node is deleted.
func (*Visibility) ReplaceCustomSearchAttributes ¶ added in v1.30.0
func (v *Visibility) ReplaceCustomSearchAttributes( mutableContext MutableContext, customSearchAttributes map[string]*commonpb.Payload, )
ReplaceCustomSearchAttributes replaces the existing custom search attribute fields with the provided ones. Nil/empty payload values are filtered. If `customSearchAttributes` is empty or all values are nil after filtering, the underlying search attributes node is deleted.
type VisibilityExecutionInfo ¶ added in v1.31.0
type VisibilityExecutionInfo[M proto.Message] struct { BusinessID string RunID string StartTime time.Time CloseTime time.Time HistoryLength int64 HistorySizeBytes int64 StateTransitionCount int64 ChasmSearchAttributes SearchAttributesMap CustomSearchAttributes map[string]*commonpb.Payload Memo *commonpb.Memo ChasmMemo M }
type VisibilityManager ¶ added in v1.30.0
type VisibilityManager interface {
ListExecutions(
context.Context,
reflect.Type,
*ListExecutionsRequest,
) (*visibilityservice.ListChasmExecutionsResponse, error)
CountExecutions(
context.Context,
reflect.Type,
*CountExecutionsRequest,
) (*visibilityservice.CountChasmExecutionsResponse, error)
}
type VisibilityMemoProvider ¶ added in v1.30.0
VisibilityMemoProvider if implemented by the root Component, allows the CHASM framework to automatically determine, at the end of a transaction, if a visibility task needs to be generated to update the visibility record with the returned memo.
type VisibilitySearchAttributesMapper ¶ added in v1.30.0
type VisibilitySearchAttributesMapper struct {
// contains filtered or unexported fields
}
VisibilitySearchAttributesMapper is a mapper for CHASM search attributes.
func NewTestVisibilitySearchAttributesMapper ¶ added in v1.30.0
func NewTestVisibilitySearchAttributesMapper( fieldToAlias map[string]string, saTypeMap map[string]enumspb.IndexedValueType, ) *VisibilitySearchAttributesMapper
NewTestVisibilitySearchAttributesMapper creates a new VisibilitySearchAttributesMapper. For testing only.
func (*VisibilitySearchAttributesMapper) Alias ¶ added in v1.30.0
func (v *VisibilitySearchAttributesMapper) Alias(field string) (string, error)
Alias returns the alias for a given field.
func (*VisibilitySearchAttributesMapper) Field ¶ added in v1.30.0
func (v *VisibilitySearchAttributesMapper) Field(alias string) (string, error)
Field returns the field for a given alias.
func (*VisibilitySearchAttributesMapper) IsSystemOverride ¶
func (v *VisibilitySearchAttributesMapper) IsSystemOverride(field string) bool
IsSystemOverride returns true if this archetype overrides the given system search attribute field with its own value (written to the dedicated system column).
func (*VisibilitySearchAttributesMapper) OverriddenSystemFields ¶
func (v *VisibilitySearchAttributesMapper) OverriddenSystemFields() map[string]enumspb.IndexedValueType
OverriddenSystemFields returns the system search attribute fields this archetype overrides, keyed by field name with the field's indexed value type as the value.
func (*VisibilitySearchAttributesMapper) SATypeMap ¶ added in v1.30.0
func (v *VisibilitySearchAttributesMapper) SATypeMap() map[string]enumspb.IndexedValueType
SATypeMap returns the type map for the CHASM search attributes.
func (*VisibilitySearchAttributesMapper) ValueType ¶ added in v1.30.0
func (v *VisibilitySearchAttributesMapper) ValueType(fieldName string) (enumspb.IndexedValueType, error)
ValueType returns the type of a CHASM search attribute field. Returns an error if the field is not found in the type map.
type VisibilitySearchAttributesProvider ¶ added in v1.30.0
type VisibilitySearchAttributesProvider interface {
SearchAttributes(Context) []SearchAttributeKeyValue
}
VisibilitySearchAttributesProvider if implemented by the root Component, allows the CHASM framework to automatically determine, at the end of a transaction, if a visibility task needs to be generated to update the visibility record with the returned search attributes.
type VisibilityValue ¶ added in v1.30.0
type VisibilityValue interface {
MustEncode() *commonpb.Payload
Equal(VisibilityValue) bool
Value() any
}
type VisibilityValueBool ¶ added in v1.30.0
type VisibilityValueBool bool
func (VisibilityValueBool) Equal ¶ added in v1.30.0
func (v VisibilityValueBool) Equal(other VisibilityValue) bool
func (VisibilityValueBool) MustEncode ¶ added in v1.30.0
func (v VisibilityValueBool) MustEncode() *commonpb.Payload
func (VisibilityValueBool) Value ¶ added in v1.30.0
func (v VisibilityValueBool) Value() any
type VisibilityValueFloat64 ¶ added in v1.30.0
type VisibilityValueFloat64 float64
func (VisibilityValueFloat64) Equal ¶ added in v1.30.0
func (v VisibilityValueFloat64) Equal(other VisibilityValue) bool
func (VisibilityValueFloat64) MustEncode ¶ added in v1.30.0
func (v VisibilityValueFloat64) MustEncode() *commonpb.Payload
func (VisibilityValueFloat64) Value ¶ added in v1.30.0
func (v VisibilityValueFloat64) Value() any
type VisibilityValueInt64 ¶ added in v1.30.0
type VisibilityValueInt64 int64
func (VisibilityValueInt64) Equal ¶ added in v1.30.0
func (v VisibilityValueInt64) Equal(other VisibilityValue) bool
func (VisibilityValueInt64) MustEncode ¶ added in v1.30.0
func (v VisibilityValueInt64) MustEncode() *commonpb.Payload
func (VisibilityValueInt64) Value ¶ added in v1.30.0
func (v VisibilityValueInt64) Value() any
type VisibilityValueKeyword ¶ added in v1.31.0
type VisibilityValueKeyword string
func (VisibilityValueKeyword) Equal ¶ added in v1.31.0
func (v VisibilityValueKeyword) Equal(other VisibilityValue) bool
func (VisibilityValueKeyword) MustEncode ¶ added in v1.31.0
func (v VisibilityValueKeyword) MustEncode() *commonpb.Payload
func (VisibilityValueKeyword) Value ¶ added in v1.31.0
func (v VisibilityValueKeyword) Value() any
type VisibilityValueStringSlice ¶ added in v1.30.0
type VisibilityValueStringSlice []string
func (VisibilityValueStringSlice) Equal ¶ added in v1.30.0
func (v VisibilityValueStringSlice) Equal(other VisibilityValue) bool
func (VisibilityValueStringSlice) MustEncode ¶ added in v1.30.0
func (v VisibilityValueStringSlice) MustEncode() *commonpb.Payload
func (VisibilityValueStringSlice) Value ¶ added in v1.30.0
func (v VisibilityValueStringSlice) Value() any
type VisibilityValueText ¶
type VisibilityValueText string
func (VisibilityValueText) Equal ¶
func (v VisibilityValueText) Equal(other VisibilityValue) bool
func (VisibilityValueText) MustEncode ¶
func (v VisibilityValueText) MustEncode() *commonpb.Payload
func (VisibilityValueText) Value ¶
func (v VisibilityValueText) Value() any
type VisibilityValueTime ¶ added in v1.30.0
func (VisibilityValueTime) Equal ¶ added in v1.30.0
func (v VisibilityValueTime) Equal(other VisibilityValue) bool
func (VisibilityValueTime) MustEncode ¶ added in v1.30.0
func (v VisibilityValueTime) MustEncode() *commonpb.Payload
func (VisibilityValueTime) Value ¶ added in v1.30.0
func (v VisibilityValueTime) Value() any
Source Files
¶
- archetype.go
- callback.go
- component.go
- component_field_option.go
- component_mock.go
- context.go
- context_mock.go
- engine.go
- engine_mock.go
- errors.go
- field.go
- field_internal.go
- field_type.go
- fields_iterator.go
- fx.go
- interceptors.go
- library.go
- library_core.go
- library_mock.go
- map.go
- ms_pointer.go
- nexus_completion.go
- nexus_operation_processor.go
- node_backend_mock.go
- node_pure_task_mock.go
- parent_pointer.go
- parent_pointer_mock.go
- path_encoder.go
- ref.go
- registrable_component.go
- registrable_task.go
- registry.go
- scheduler.go
- search_attribute.go
- statemachine.go
- task.go
- task_handler_base.go
- task_mock.go
- test_visibility.go
- transition_history.go
- tree.go
- visibility.go
- visibility_manager.go
- visibility_manager_mock.go
- visibility_value.go
- workflow.go
Directories
¶
| Path | Synopsis |
|---|---|
|
lib
|
|
|
activity/gen/activitypb/v1
Code generated by protoc-gen-go-helpers.
|
Code generated by protoc-gen-go-helpers. |
|
activity/model
Package model is an implementation-independent vocabulary for specifying a sequence of events (a 'trace') in the lifetime of an activity.
|
Package model is an implementation-independent vocabulary for specifying a sequence of events (a 'trace') in the lifetime of an activity. |
|
callback/gen/callbackpb/v1
Code generated by protoc-gen-go-helpers.
|
Code generated by protoc-gen-go-helpers. |
|
nexusoperation/gen/nexusoperationpb/v1
Code generated by protoc-gen-go-helpers.
|
Code generated by protoc-gen-go-helpers. |
|
scheduler
Package scheduler is a generated GoMock package.
|
Package scheduler is a generated GoMock package. |
|
scheduler/gen/schedulerpb/v1
Code generated by protoc-gen-go-helpers.
|
Code generated by protoc-gen-go-helpers. |
|
tests/gen/testspb/v1
Code generated by protoc-gen-go-helpers.
|
Code generated by protoc-gen-go-helpers. |
|
workflow/gen/workflowpb/v1
Code generated by protoc-gen-go-helpers.
|
Code generated by protoc-gen-go-helpers. |