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 ExecutionStateChanged(c Component, ctx Context, refBytes []byte) (bool, error)
- func GenerateNexusCallback(ctx Context, component NexusCompletionHandlerComponent) (*commonpb.Callback, error)
- func GetValue[T any](m SearchAttributesMap, sa typedSearchAttribute[T]) (val T, ok bool)
- 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 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 Component
- type ComponentFieldOption
- type ComponentRef
- type Context
- type CoreLibrary
- type CountExecutionsRequest
- type CountExecutionsResponse
- type Engine
- type EngineNewExecutionResult
- 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
- type Map
- type MockComponent
- type MockComponentMockRecorder
- type MockContext
- type MockEngine
- func (m *MockEngine) EXPECT() *MockEngineMockRecorder
- func (m *MockEngine) NewExecution(arg0 context.Context, arg1 ComponentRef, ...) (EngineNewExecutionResult, error)
- 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) UpdateComponent(arg0 context.Context, arg1 ComponentRef, ...) ([]byte, error)
- func (m *MockEngine) UpdateWithNewExecution(arg0 context.Context, arg1 ComponentRef, ...) (ExecutionKey, []byte, error)
- type MockEngineMockRecorder
- func (mr *MockEngineMockRecorder) NewExecution(arg0, arg1, arg2 any, arg3 ...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) UpdateComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
- func (mr *MockEngineMockRecorder) UpdateWithNewExecution(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call
- type MockLibrary
- type MockLibraryMockRecorder
- type MockMutableContext
- type MockNodeBackend
- func (m *MockNodeBackend) AddTasks(ts ...tasks.Task)
- func (m *MockNodeBackend) CurrentVersionedTransition() *persistencespb.VersionedTransition
- func (m *MockNodeBackend) DeleteCHASMPureTasks(maxScheduledTime time.Time)
- func (m *MockNodeBackend) GetCurrentVersion() int64
- func (m *MockNodeBackend) GetExecutionInfo() *persistencespb.WorkflowExecutionInfo
- func (m *MockNodeBackend) GetExecutionState() *persistencespb.WorkflowExecutionState
- func (m *MockNodeBackend) GetNexusCompletion(ctx context.Context, requestID string) (nexusrpc.OperationCompletion, error)
- func (m *MockNodeBackend) GetWorkflowKey() definition.WorkflowKey
- 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) NextTransitionCount() int64
- func (m *MockNodeBackend) NumTasksAdded() int
- func (m *MockNodeBackend) UpdateWorkflowStateStatus(state enumsspb.WorkflowExecutionState, status enumspb.WorkflowExecutionStatus) (bool, error)
- type MockNodePureTask
- type MockPureTaskExecutor
- type MockPureTaskExecutorMockRecorder
- type MockSideEffectTaskExecutor
- type MockSideEffectTaskExecutorMockRecorder
- type MockTask
- type MockTaskValidator
- type MockTaskValidatorMockRecorder
- type MockVisibilityManager
- func (m *MockVisibilityManager) CountExecutions(arg0 context.Context, arg1 reflect.Type, arg2 *CountExecutionsRequest) (*CountExecutionsResponse, error)
- func (m *MockVisibilityManager) EXPECT() *MockVisibilityManagerMockRecorder
- func (m *MockVisibilityManager) ListExecutions(arg0 context.Context, arg1 reflect.Type, arg2 *ListExecutionsRequest) (*ListExecutionsResponse[*common.Payload], error)
- type MockVisibilityManagerMockRecorder
- type Mocknamer
- type MocknamerMockRecorder
- type MutableContext
- type NewExecutionResult
- type NexusCompletionHandler
- type NexusCompletionHandlerComponent
- 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) 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, error)
- func (n *Node) ExecuteSideEffectTask(ctx context.Context, registry *Registry, executionKey ExecutionKey, ...) (retErr 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) Ref(component Component) ([]byte, error)
- func (n *Node) RefreshTasks() error
- func (n *Node) SetRootComponent(rootComponent Component)
- func (n *Node) Snapshot(exclusiveMinVT *persistencespb.VersionedTransition) NodesSnapshot
- func (n *Node) Terminate(request TerminateComponentRequest) error
- func (n *Node) ValidatePureTask(ctx context.Context, taskAttributes TaskAttributes, taskInstance any) (bool, error)
- func (n *Node) ValidateSideEffectTask(ctx context.Context, chasmTask *tasks.ChasmTask) (isValid bool, retErr error)
- type NodeBackend
- type NodePathEncoder
- type NodePureTask
- type NodesMutation
- type NodesSnapshot
- type OperationIntent
- type ParentPtr
- type PureTaskExecutor
- type RegistrableComponent
- type RegistrableComponentOption
- func WithBusinessIDAlias(alias string) RegistrableComponentOption
- func WithEphemeral() RegistrableComponentOption
- func WithSearchAttributes(searchAttributes ...SearchAttribute) RegistrableComponentOption
- func WithShardingFn(shardingFn func(ExecutionKey) string) RegistrableComponentOption
- func WithSingleCluster() RegistrableComponentOption
- type RegistrableTask
- type RegistrableTaskOption
- type Registry
- 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) Register(lib Library) error
- func (r *Registry) RegisterServices(server *grpc.Server)
- func (r *Registry) TaskFqnByID(id uint32) (string, bool)
- func (r *Registry) TaskIDFor(taskInstance any) (uint32, bool)
- type SearchAttribute
- type SearchAttributeBool
- type SearchAttributeDateTime
- type SearchAttributeDouble
- type SearchAttributeFieldBool
- type SearchAttributeFieldDateTime
- type SearchAttributeFieldDouble
- type SearchAttributeFieldInt
- type SearchAttributeFieldKeyword
- type SearchAttributeFieldKeywordList
- type SearchAttributeInt
- type SearchAttributeKeyValue
- type SearchAttributeKeyword
- type SearchAttributeKeywordList
- type SearchAttributesMap
- type SideEffectTaskExecutor
- type StateMachine
- type TaskAttributes
- type TaskValidator
- type TerminateComponentRequest
- type TerminateComponentResponse
- type Transition
- type TransitionOption
- type TransitionOptions
- type UnimplementedComponent
- type UnimplementedLibrary
- 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 VisibilityManager
- type VisibilityMemoProvider
- type VisibilitySearchAttributesMapper
- func (v *VisibilitySearchAttributesMapper) Alias(field string) (string, error)
- func (v *VisibilitySearchAttributesMapper) Field(alias string) (string, error)
- func (v *VisibilitySearchAttributesMapper) SATypeMap() map[string]enumspb.IndexedValueType
- func (v *VisibilitySearchAttributesMapper) ValueType(fieldName string) (enumspb.IndexedValueType, error)
- type VisibilitySearchAttributesProvider
- type VisibilityValue
- type VisibilityValueBool
- type VisibilityValueByteSlice
- type VisibilityValueFloat64
- type VisibilityValueInt
- type VisibilityValueInt32
- type VisibilityValueInt64
- type VisibilityValueString
- type VisibilityValueStringSlice
- type VisibilityValueTime
Constants ¶
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) 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 = Archetype(fullyQualifiedName(WorkflowLibraryName, WorkflowComponentName)) WorkflowArchetypeID = ArchetypeID(generateTypeID(WorkflowArchetype)) )
var ErrInvalidComponentRef = serviceerror.NewInvalidArgument("invalid component ref")
ErrInvalidComponentRef is returned when component ref bytes deserialize to an invalid component ref.
var ErrInvalidTransition = errors.New("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 Module = fx.Module( "chasm", fx.Provide(NewRegistry), fx.Invoke(func(registry *Registry) error { return registry.Register(&CoreLibrary{}) }), )
var TaskScheduledTimeImmediate = time.Time{}
var UnimplementedComponentT = reflect.TypeFor[UnimplementedComponent]()
Functions ¶
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 GenerateNexusCallback ¶ added in v1.30.0
func GenerateNexusCallback(ctx Context, component NexusCompletionHandlerComponent) (*commonpb.Callback, error)
GenerateNexusCallback generates a Callback message indicating a CHASM component to receive Nexus operation completion callbacks. Particularly useful for components that want to track a workflow start with StartWorkflowExecution.
func GetValue ¶ added in v1.30.0
func GetValue[T any](m SearchAttributesMap, sa typedSearchAttribute[T]) (val T, ok bool)
GetValue 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 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 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. It returns the result, along with the new component reference. opts are currently ignored.
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 interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (resp interface{}, 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 interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (resp interface{}, retError error)
type Component ¶
type Component interface {
LifecycleState(Context) LifecycleState
Terminate(MutableContext, TerminateComponentRequest) (TerminateComponentResponse, error)
// 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 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)
func (*ComponentRef) Serialize ¶
func (r *ComponentRef) Serialize( registry *Registry, ) ([]byte, error)
func (*ComponentRef) ShardingKey ¶ added in v1.28.0
func (r *ComponentRef) ShardingKey( registry *Registry, ) (string, error)
ShardingKey returns the sharding key used for determining the shardID of the run that contains the referenced component. TODO: remove this method and ShardingKey concept, we don't need this functionality.
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
// ExecutionCloseTime returns 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.
ExecutionCloseTime() time.Time
// 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 Engine ¶ added in v1.29.0
type Engine interface {
NewExecution(
context.Context,
ComponentRef,
func(MutableContext) (Component, error),
...TransitionOption,
) (EngineNewExecutionResult, error)
UpdateWithNewExecution(
context.Context,
ComponentRef,
func(MutableContext) (Component, error),
func(MutableContext, Component) error,
...TransitionOption,
) (ExecutionKey, []byte, 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)
// NotifyExecution notifies any PollComponent callers waiting on the execution.
NotifyExecution(ExecutionKey)
}
type EngineNewExecutionResult ¶ added in v1.30.0
type EngineNewExecutionResult = NewExecutionResult[struct{}]
EngineNewExecutionResult is a type alias for the result type returned by the Engine implementation. This avoids repeating [struct{}] everywhere in the 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[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 ExecutionKey ¶ added in v1.30.0
ExecutionKey uniquely identifies a CHASM execution in the system.
func UpdateWithNewExecution ¶ added in v1.30.0
func UpdateWithNewExecution[C Component, I any, O1 any, O2 any]( ctx context.Context, key ExecutionKey, newFn func(MutableContext, I) (C, O1, error), updateFn func(C, MutableContext, I) (O2, error), input I, opts ...TransitionOption, ) (O1, O2, ExecutionKey, []byte, error)
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. Pointers are resolved at the time the transaction is closed, and the transaction will fail if any pointers cannot be resolved.
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)
// 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 // Lifecycle states that are considered CLOSED // LifecycleStateCompleted LifecycleStateFailed )
func (LifecycleState) IsClosed ¶ added in v1.28.0
func (s LifecycleState) IsClosed() 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 []*ExecutionInfo[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) GetNexusCompletion ¶ added in v1.30.0
func (m MSPointer) GetNexusCompletion(ctx Context, requestID string) (nexusrpc.OperationCompletion, error)
GetNexusCompletion retrieves the Nexus operation completion data for the given request ID from the underlying mutable state.
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.
func (*MockComponent) Terminate ¶ added in v1.28.0
func (m *MockComponent) Terminate(arg0 MutableContext, arg1 TerminateComponentRequest) (TerminateComponentResponse, error)
Terminate 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
}
MockContext is a mock implementation of Context.
func (*MockContext) ExecutionCloseTime ¶ added in v1.30.0
func (c *MockContext) ExecutionCloseTime() time.Time
func (*MockContext) ExecutionKey ¶ added in v1.30.0
func (c *MockContext) ExecutionKey() ExecutionKey
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) 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) NewExecution ¶ added in v1.30.0
func (m *MockEngine) NewExecution(arg0 context.Context, arg1 ComponentRef, arg2 func(MutableContext) (Component, error), arg3 ...TransitionOption) (EngineNewExecutionResult, error)
NewExecution mocks base method.
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) 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) UpdateWithNewExecution ¶ added in v1.30.0
func (m *MockEngine) UpdateWithNewExecution(arg0 context.Context, arg1 ComponentRef, arg2 func(MutableContext) (Component, error), arg3 func(MutableContext, Component) error, arg4 ...TransitionOption) (ExecutionKey, []byte, error)
UpdateWithNewExecution 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) NewExecution ¶ added in v1.30.0
func (mr *MockEngineMockRecorder) NewExecution(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call
NewExecution indicates an expected call of NewExecution.
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) 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) UpdateWithNewExecution ¶ added in v1.30.0
func (mr *MockEngineMockRecorder) UpdateWithNewExecution(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call
UpdateWithNewExecution indicates an expected call of UpdateWithNewExecution.
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) 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) 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
// 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)
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
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.OperationCompletion, error)
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) AddTasks ¶ added in v1.28.0
func (m *MockNodeBackend) AddTasks(ts ...tasks.Task)
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) 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) GetNexusCompletion ¶ added in v1.30.0
func (m *MockNodeBackend) GetNexusCompletion( ctx context.Context, requestID string, ) (nexusrpc.OperationCompletion, error)
func (*MockNodeBackend) GetWorkflowKey ¶ added in v1.28.0
func (m *MockNodeBackend) GetWorkflowKey() definition.WorkflowKey
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) 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)
HandleValidatePureTask func(baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any) (bool, error)
ExecuteCalls []struct {
BaseCtx context.Context
Attributes TaskAttributes
Task any
}
ValidateCalls []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)
func (*MockNodePureTask) ValidatePureTask ¶ added in v1.29.0
func (m *MockNodePureTask) ValidatePureTask( baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any, ) (bool, error)
type MockPureTaskExecutor ¶ added in v1.28.0
MockPureTaskExecutor is a mock of PureTaskExecutor interface.
func NewMockPureTaskExecutor ¶ added in v1.28.0
func NewMockPureTaskExecutor[C any, T any](ctrl *gomock.Controller) *MockPureTaskExecutor[C, T]
NewMockPureTaskExecutor creates a new mock instance.
func (*MockPureTaskExecutor[C, T]) EXPECT ¶ added in v1.28.0
func (m *MockPureTaskExecutor[C, T]) EXPECT() *MockPureTaskExecutorMockRecorder[C, T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPureTaskExecutor[C, T]) Execute ¶ added in v1.28.0
func (m *MockPureTaskExecutor[C, T]) Execute(arg0 MutableContext, arg1 C, arg2 TaskAttributes, arg3 T) error
Execute mocks base method.
type MockPureTaskExecutorMockRecorder ¶ added in v1.28.0
type MockPureTaskExecutorMockRecorder[C any, T any] struct { // contains filtered or unexported fields }
MockPureTaskExecutorMockRecorder is the mock recorder for MockPureTaskExecutor.
type MockSideEffectTaskExecutor ¶ added in v1.28.0
MockSideEffectTaskExecutor is a mock of SideEffectTaskExecutor interface.
func NewMockSideEffectTaskExecutor ¶ added in v1.28.0
func NewMockSideEffectTaskExecutor[C any, T any](ctrl *gomock.Controller) *MockSideEffectTaskExecutor[C, T]
NewMockSideEffectTaskExecutor creates a new mock instance.
func (*MockSideEffectTaskExecutor[C, T]) EXPECT ¶ added in v1.28.0
func (m *MockSideEffectTaskExecutor[C, T]) EXPECT() *MockSideEffectTaskExecutorMockRecorder[C, T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSideEffectTaskExecutor[C, T]) Execute ¶ added in v1.28.0
func (m *MockSideEffectTaskExecutor[C, T]) Execute(arg0 context.Context, arg1 ComponentRef, arg2 TaskAttributes, arg3 T) error
Execute mocks base method.
type MockSideEffectTaskExecutorMockRecorder ¶ added in v1.28.0
type MockSideEffectTaskExecutorMockRecorder[C any, T any] struct { // contains filtered or unexported fields }
MockSideEffectTaskExecutorMockRecorder is the mock recorder for MockSideEffectTaskExecutor.
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 TaskAttributes, 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 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) (*CountExecutionsResponse, 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) (*ListExecutionsResponse[*common.Payload], 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 executor for the given task
// referencing the component.
AddTask(Component, TaskAttributes, any)
}
func NewMutableContext ¶ added in v1.28.0
func NewMutableContext( ctx context.Context, root *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, UpdateWithNewExecution, or NewExecution APIs.
type NewExecutionResult ¶ added in v1.30.0
type NewExecutionResult[O any] struct { ExecutionKey ExecutionKey NewExecutionRef []byte Created bool Output O }
NewExecutionResult contains the outcome of creating a new execution via NewExecution or UpdateWithNewExecution.
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.
- NewExecutionRef: 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.
- Output: The output value returned by the factory function.
func NewExecution ¶ added in v1.30.0
func NewExecution[C Component, I any, O any]( ctx context.Context, key ExecutionKey, newFn func(MutableContext, I) (C, O, error), input I, opts ...TransitionOption, ) (NewExecutionResult[O], error)
NewExecution 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 Component
- 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
- newFn: 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 newFn
- 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 newFn
- 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 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 NexusCompletionHandlerComponent ¶ added in v1.30.0
type NexusCompletionHandlerComponent interface {
Component
NexusCompletionHandler
}
NexusCompletionHandlerComponent is a CHASM Component that also implements NexusCompletionHandler.
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, ) *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, ) (*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) 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(executor 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, 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) ExecuteSideEffectTask ¶ added in v1.29.0
func (n *Node) ExecuteSideEffectTask( ctx context.Context, registry *Registry, executionKey ExecutionKey, chasmTask *tasks.ChasmTask, validate func(NodeBackend, Context, Component) error, ) (retErr 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) RefreshTasks ¶ added in v1.29.0
func (*Node) SetRootComponent ¶ added in v1.29.0
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) ValidatePureTask ¶ added in v1.29.0
func (n *Node) ValidatePureTask( ctx context.Context, taskAttributes TaskAttributes, taskInstance any, ) (bool, error)
ValidatePureTask runs a pure task's associated validator, returning true if the task is valid. Intended for use by standby executors as part of EachPureTask's callback. This method assumes the node's value has already been prepared (hydrated).
func (*Node) ValidateSideEffectTask ¶ added in v1.29.0
func (n *Node) ValidateSideEffectTask( ctx context.Context, chasmTask *tasks.ChasmTask, ) (isValid bool, retErr error)
ValidateSideEffectTask runs a side effect task's associated validator, returning the deserialized task instance if the task is valid. Intended for use by standby executors.
If validation succeeds but the task is invalid, nil is returned to signify the task can be skipped/deleted.
If validation fails, that error is returned.
type NodeBackend ¶ added in v1.28.0
type NodeBackend interface {
// TODO: Add methods needed from MutateState here.
GetExecutionState() *persistencespb.WorkflowExecutionState
GetExecutionInfo() *persistencespb.WorkflowExecutionInfo
GetCurrentVersion() int64
NextTransitionCount() int64
CurrentVersionedTransition() *persistencespb.VersionedTransition
GetWorkflowKey() definition.WorkflowKey
AddTasks(...tasks.Task)
DeleteCHASMPureTasks(maxScheduledTime time.Time)
UpdateWorkflowStateStatus(
state enumsspb.WorkflowExecutionState,
status enumspb.WorkflowExecutionStatus,
) (bool, error)
IsWorkflow() bool
GetNexusCompletion(
ctx context.Context,
requestID string,
) (nexusrpc.OperationCompletion, error)
}
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)
ValidatePureTask(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.
type OperationIntent ¶
type OperationIntent int
const ( OperationIntentProgress OperationIntent = 1 << iota OperationIntentObserve 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 (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 PureTaskExecutor ¶ added in v1.28.0
type PureTaskExecutor[C any, T any] interface { Execute(MutableContext, C, TaskAttributes, T) error }
type RegistrableComponent ¶
type RegistrableComponent struct {
// contains filtered or unexported fields
}
func NewRegistrableComponent ¶
func NewRegistrableComponent[C Component]( componentType string, opts ...RegistrableComponentOption, ) *RegistrableComponent
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 WithEphemeral ¶
func WithEphemeral() RegistrableComponentOption
func WithSearchAttributes ¶ added in v1.30.0
func WithSearchAttributes( searchAttributes ...SearchAttribute, ) RegistrableComponentOption
func WithShardingFn ¶
func WithShardingFn( shardingFn func(ExecutionKey) string, ) RegistrableComponentOption
WithShardingFn allows specifying a custom sharding key function for the component. TODO: remove WithShardingFn, we don't need this functionality.
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, validator TaskValidator[C, T], executor PureTaskExecutor[C, T], opts ...RegistrableTaskOption, ) *RegistrableTask
func NewRegistrableSideEffectTask ¶ added in v1.28.0
func NewRegistrableSideEffectTask[C any, T any]( taskType string, validator TaskValidator[C, T], executor SideEffectTaskExecutor[C, T], opts ...RegistrableTaskOption, ) *RegistrableTask
NOTE: C is not Component but any.
type RegistrableTaskOption ¶
type RegistrableTaskOption func(*RegistrableTask)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
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, 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.
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) RegisterServices ¶ added in v1.30.0
RegisterServices registers all gRPC services from all registered libraries.
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 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 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 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 SideEffectTaskExecutor ¶ added in v1.28.0
type SideEffectTaskExecutor[C any, T any] interface { Execute(context.Context, ComponentRef, TaskAttributes, T) error }
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 ¶
func (*TaskAttributes) IsImmediate ¶ added in v1.30.0
func (a *TaskAttributes) IsImmediate() bool
func (*TaskAttributes) IsValid ¶ added in v1.30.0
func (a *TaskAttributes) IsValid() bool
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, TaskAttributes, T) (bool, 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 and setting the destination 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) error
Apply applies a transition event to the given state machine changing the state machine's state to the transition's Destination on success.
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 NewExecution() and UpdateWithNewExecution().
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 NewExecution() and UpdateWithNewExecution().
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
RequestID string
Speculative bool
}
type UnimplementedComponent ¶
type UnimplementedComponent struct{}
Embed UnimplementedComponent to get forward compatibility
func (UnimplementedComponent) Terminate ¶ added in v1.28.0
func (UnimplementedComponent) Terminate(MutableContext, TerminateComponentRequest) (TerminateComponentResponse, error)
type UnimplementedLibrary ¶
type UnimplementedLibrary struct{}
func (UnimplementedLibrary) Components ¶
func (UnimplementedLibrary) Components() []*RegistrableComponent
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 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 NOT a deep copy of the underlying data, so do NOT modify it directly, use Merge/ReplaceCustomMemo methods instead.
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 NOT a deep copy of the underlying data, so do NOT modify it directly, use Merge/ReplaceCustomSearchAttributes methods instead.
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. If `customSearchAttributes` is empty, the underlying search attributes node is deleted.
type VisibilityManager ¶ added in v1.30.0
type VisibilityManager interface {
ListExecutions(
context.Context,
reflect.Type,
*ListExecutionsRequest,
) (*ListExecutionsResponse[*commonpb.Payload], error)
CountExecutions(
context.Context,
reflect.Type,
*CountExecutionsRequest,
) (*CountExecutionsResponse, 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) 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 VisibilityValueByteSlice ¶ added in v1.30.0
type VisibilityValueByteSlice []byte
func (VisibilityValueByteSlice) Equal ¶ added in v1.30.0
func (v VisibilityValueByteSlice) Equal(other VisibilityValue) bool
func (VisibilityValueByteSlice) MustEncode ¶ added in v1.30.0
func (v VisibilityValueByteSlice) MustEncode() *commonpb.Payload
func (VisibilityValueByteSlice) Value ¶ added in v1.30.0
func (v VisibilityValueByteSlice) 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 VisibilityValueInt ¶ added in v1.30.0
type VisibilityValueInt int
func (VisibilityValueInt) Equal ¶ added in v1.30.0
func (v VisibilityValueInt) Equal(other VisibilityValue) bool
func (VisibilityValueInt) MustEncode ¶ added in v1.30.0
func (v VisibilityValueInt) MustEncode() *commonpb.Payload
func (VisibilityValueInt) Value ¶ added in v1.30.0
func (v VisibilityValueInt) Value() any
type VisibilityValueInt32 ¶ added in v1.30.0
type VisibilityValueInt32 int32
func (VisibilityValueInt32) Equal ¶ added in v1.30.0
func (v VisibilityValueInt32) Equal(other VisibilityValue) bool
func (VisibilityValueInt32) MustEncode ¶ added in v1.30.0
func (v VisibilityValueInt32) MustEncode() *commonpb.Payload
func (VisibilityValueInt32) Value ¶ added in v1.30.0
func (v VisibilityValueInt32) 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 VisibilityValueString ¶ added in v1.30.0
type VisibilityValueString string
func (VisibilityValueString) Equal ¶ added in v1.30.0
func (v VisibilityValueString) Equal(other VisibilityValue) bool
func (VisibilityValueString) MustEncode ¶ added in v1.30.0
func (v VisibilityValueString) MustEncode() *commonpb.Payload
func (VisibilityValueString) Value ¶ added in v1.30.0
func (v VisibilityValueString) 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 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
- 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
- node_backend_mock.go
- node_pure_task_mock.go
- parent_pointer.go
- path_encoder.go
- ref.go
- registrable_component.go
- registrable_task.go
- registry.go
- scheduler.go
- search_attribute.go
- statemachine.go
- task.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. |
|
callback/gen/callbackpb/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. |