chasm

package
v1.31.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 46 Imported by: 0

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

View Source
const (
	CallbackLibraryName   = "callback"
	CallbackComponentName = "callback"
)
View Source
const (
	SchedulerLibraryName   = "scheduler"
	SchedulerComponentName = "scheduler"
)
View Source
const (
	UserMemoKey  = "__user__"
	ChasmMemoKey = "__chasm__"
)
View Source
const (
	WorkflowLibraryName   = "workflow"
	WorkflowComponentName = "workflow"
)
View Source
const NexusCompletionHandlerURL = "temporal://internal"

NexusCompletionHandlerURL is the user-visible URL for Nexus->CHASM callbacks.

Variables

View Source
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)

	SearchAttributeTaskQueue                            = newSearchAttributeKeywordByField(sadefs.TaskQueue)
	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))

View Source
var ErrInvalidComponentRef = serviceerror.NewInvalidArgument("invalid component ref")

ErrInvalidComponentRef is returned when component ref bytes deserialize to an invalid component ref.

View Source
var ErrInvalidTransition = serviceerror.NewFailedPrecondition("invalid transition")

ErrInvalidTransition is returned from Transition.Apply on an invalid state transition.

View Source
var ErrMalformedComponentRef = serviceerror.NewInvalidArgument("malformed component ref")

ErrMalformedComponentRef is returned when component ref bytes cannot be deserialized.

View Source
var ErrTaskDiscarded = errors.New("standby task pending for too long")

ErrTaskDiscarded is the error returned by the default SideEffectTaskHandlerBase Discard implementation, indicating that a side-effect task on a standby cluster has been pending past the discard delay.

View Source
var Module = fx.Module(
	"chasm",
	fx.Provide(NewRegistry),
	fx.Invoke(func(registry *Registry) error {
		return registry.Register(&CoreLibrary{})
	}),
)
View Source
var TaskScheduledTimeImmediate = time.Time{}

TaskScheduledTimeImmediate is the zero time value used to indicate that a task should execute immediately.

View Source
var UnimplementedComponentT = reflect.TypeFor[UnimplementedComponent]()

Functions

func ContextWithValue added in v1.31.0

func ContextWithValue[C Context](c C, key any, value any) C

ContextWithValue returns a new Context with the given key-value pair added. Added key-value pairs will be accessible via the Value() method on the returned Context, and the behavior of the key-value pair is the same as context.Context.WithValue().

func DeleteExecution added in v1.31.0

func DeleteExecution[C RootComponent](
	ctx context.Context,
	key ExecutionKey,
	request DeleteExecutionRequest,
) error

DeleteExecution deletes the execution identified by the supplied execution key. If the execution is still running, it is terminated first. A DeleteExecutionTask is then queued to remove all execution data from persistence.

func ExecutionStateChanged added in v1.30.0

func ExecutionStateChanged(c Component, ctx Context, refBytes []byte) (bool, error)

ExecutionStateChanged returns true if execution state has advanced beyond the state encoded in refBytes. It may return ErrInvalidComponentRef or ErrMalformedComponentRef. Callers should consider converting these to serviceerror.NewInvalidArgument.

func FullyQualifiedName added in v1.31.0

func FullyQualifiedName(libName, name string) string

FullyQualifiedName creates a fully qualified name (FQN) by combining a library name and a component or task name. The FQN is used to uniquely identify components and tasks within the CHASM framework. The format of the returned FQN is: "libName.name"

func GenerateNexusCallback added in v1.30.0

func GenerateNexusCallback(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 GenerateTypeID added in v1.31.0

func GenerateTypeID(fqn string) uint32

GenerateTypeID generates a unique 32-bit identifier from a fully qualified name (FQN). The generated ID is used to uniquely identify components and tasks within the CHASM framework. The same FQN will always produce the same ID.

func NewEngineContext added in v1.29.0

func NewEngineContext(
	ctx context.Context,
	engine Engine,
) context.Context

this will be done by the nexus handler? alternatively the engine can be a global variable, but not a good practice in fx.

func NewVisibilityManagerContext added in v1.30.0

func NewVisibilityManagerContext(
	ctx context.Context,
	engine VisibilityManager,
) context.Context

func PollComponent

func PollComponent[C any, R []byte | ComponentRef, I any, O any](
	ctx context.Context,
	r R,
	monotonicPredicate func(C, Context, I) (O, bool, error),
	input I,
	opts ...TransitionOption,
) (O, []byte, error)

PollComponent waits until the predicate is true when evaluated against the component identified by the supplied component reference. If this times out due to a server-imposed long-poll timeout then it returns (nil, nil, nil), as an indication that the caller should continue long-polling. Otherwise it returns (output, ref, err), where output is the output of the predicate function, and ref is a component reference identifying the state at which the predicate was satisfied. The predicate must be monotonic: if it returns true at execution state transition s then it must return true at all transitions t > s. If the predicate is true at the outset then PollComponent returns immediately. opts are currently ignored.

func ReadComponent

func ReadComponent[C any, R []byte | ComponentRef, I any, O any](
	ctx context.Context,
	r R,
	readFn func(C, Context, I) (O, error),
	input I,
	opts ...TransitionOption,
) (O, error)

ReadComponent returns the result of evaluating readFn against the component identified by the component reference. opts are currently ignored.

func SearchAttributeValue added in v1.31.0

func SearchAttributeValue[T any](m SearchAttributesMap, sa typedSearchAttribute[T]) (val T, ok bool)

SearchAttributeValue returns the value for a given SearchAttribute with compile-time type safety. The return type T is inferred from the SearchAttribute's type parameter. For example, SearchAttributeBool will return a bool value. If the value is not found or the type does not match, the zero value for the type T is returned and the second return value is false.

func 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 ChasmEngineInterceptorProvider(
	engine Engine,
	logger log.Logger,
	metricsHandler metrics.Handler,
) *ChasmEngineInterceptor

func (*ChasmEngineInterceptor) Intercept added in v1.30.0

func (i *ChasmEngineInterceptor) Intercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (resp any, retError error)

type ChasmVisibilityInterceptor added in v1.30.0

type ChasmVisibilityInterceptor struct {
	// contains filtered or unexported fields
}

ChasmVisibilityInterceptor intercepts RPC requests and adds the CHASM VisibilityManager to their context.

func ChasmVisibilityInterceptorProvider added in v1.30.0

func ChasmVisibilityInterceptorProvider(visibilityMgr VisibilityManager) *ChasmVisibilityInterceptor

func (*ChasmVisibilityInterceptor) Intercept added in v1.30.0

func (i *ChasmVisibilityInterceptor) Intercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (resp any, retError error)

type Component

type Component interface {
	LifecycleState(Context) LifecycleState
	// contains filtered or unexported methods
}

type ComponentFieldOption

type ComponentFieldOption func(*componentFieldOptions)

func ComponentFieldDetached

func ComponentFieldDetached() ComponentFieldOption

type ComponentRef

type ComponentRef struct {
	ExecutionKey
	// contains filtered or unexported fields
}

func DeserializeComponentRef

func DeserializeComponentRef(data []byte) (ComponentRef, error)

DeserializeComponentRef deserializes a byte slice into a ComponentRef. Provides caller the access to information including ExecutionKey, Archetype, and ShardingKey.

func NewComponentRef

func NewComponentRef[C Component](
	executionKey ExecutionKey,
) ComponentRef

NewComponentRef creates a new ComponentRef with a registered root component go type.

In V1, if you don't have a ref, then you can only interact with the (top level) execution.

func NewComponentRefByArchetypeID added in v1.31.0

func NewComponentRefByArchetypeID(
	executionKey ExecutionKey,
	archetypeID ArchetypeID,
) ComponentRef

NewComponentRefByArchetypeID creates a new ComponentRef with a known archetype ID. This should only be used by CHASM framework internals. CHASM library developers should use NewComponentRef instead.

func ProtoRefToComponentRef added in v1.30.0

func ProtoRefToComponentRef(pRef *persistencespb.ChasmComponentRef) ComponentRef

ProtoRefToComponentRef converts a persistence ChasmComponentRef reference to a ComponentRef. This is useful for situations where the protobuf ComponentRef has already been deserialized as part of an enclosing message.

func (*ComponentRef) ArchetypeID added in v1.30.0

func (r *ComponentRef) ArchetypeID(
	registry *Registry,
) (ArchetypeID, error)

func (*ComponentRef) Serialize

func (r *ComponentRef) Serialize(
	registry *Registry,
) ([]byte, error)

type Context

type Context interface {

	// NOTE: component created in the current transaction won't have a ref
	// this is a Ref to the component state at the start of the transition
	Ref(Component) ([]byte, error)
	// Now returns the current time in the context of the given component.
	// In a context of a transaction, this time must be used to allow for framework support of pause and time skipping.
	Now(Component) time.Time
	// ExecutionKey returns the execution key for the execution the context is operating on.
	ExecutionKey() ExecutionKey
	// ExecutionInfo returns metadata information about the execution.
	ExecutionInfo() ExecutionInfo
	// Logger returns a logger tagged with execution key and other chasm framework internal information.
	Logger() log.Logger
	// MetricsHandler returns a metrics handler with namespace tag.
	MetricsHandler() metrics.Handler
	// Value returns the value associated with this context for key. The behavior is the same as context.Context.Value().
	// Use WithContextValues RegistrableComponentOption to set key values pair for a component upon registration.
	// Registered key-value pairs will automatically be added to the Context whenever framework accesses the component.
	// Alternatively, use ContextWithValue() to manually set values on Context which will take precedence over registered ones.
	Value(key any) any
	// contains filtered or unexported methods
}

func NewContext added in v1.28.0

func NewContext(
	ctx context.Context,
	node *Node,
) Context

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 CountExecutionsRequest struct {
	NamespaceName string
	Query         string
}

type CountExecutionsResponse added in v1.30.0

type CountExecutionsResponse struct {
	Count  int64
	Groups []Group
}

func CountExecutions added in v1.30.0

func CountExecutions[C Component](
	ctx context.Context,
	request *CountExecutionsRequest,
) (*CountExecutionsResponse, error)

CountExecutions counts the executions of a CHASM archetype given an initial query. The generic parameter C is the CHASM component type used for executions and search attribute filtering. The query string can specify any combination of CHASM, custom, and predefined/system search attributes. Note: For CHASM executions, TemporalNamespaceDivision is the predefined search attribute that is used to identify the archetype of the execution. If the query string does not specify TemporalNamespaceDivision, the archetype C of the request will be used to count the executions. If the initial query already specifies TemporalNamespaceDivision, the archetype C of the request will only be used to get the registered SearchAttributes.

type DeleteExecutionRequest added in v1.31.0

type DeleteExecutionRequest struct {
	TerminateComponentRequest
}

DeleteExecutionRequest is the request for DeleteExecution. TerminateComponentRequest will only be used if the execution is still running. The actual deletion of the execution is async, and will return after creating the DeleteExecutionTask.

type Engine added in v1.29.0

type Engine interface {
	StartExecution(
		context.Context,
		ComponentRef,
		func(MutableContext) (RootComponent, error),
		...TransitionOption,
	) (StartExecutionResult, error)
	UpdateWithStartExecution(
		context.Context,
		ComponentRef,
		func(MutableContext) (RootComponent, error),
		func(MutableContext, Component) error,
		...TransitionOption,
	) (EngineUpdateWithStartExecutionResult, error)

	UpdateComponent(
		context.Context,
		ComponentRef,
		func(MutableContext, Component) error,
		...TransitionOption,
	) ([]byte, error)
	ReadComponent(
		context.Context,
		ComponentRef,
		func(Context, Component) error,
		...TransitionOption,
	) error

	PollComponent(
		context.Context,
		ComponentRef,
		func(Context, Component) (bool, error),
		...TransitionOption,
	) ([]byte, error)

	DeleteExecution(
		context.Context,
		ComponentRef,
		DeleteExecutionRequest,
	) error

	// NotifyExecution notifies any PollComponent callers waiting on the execution.
	NotifyExecution(ExecutionKey)
}

type EngineUpdateWithStartExecutionResult added in v1.31.0

type EngineUpdateWithStartExecutionResult = UpdateWithStartExecutionResult[struct{}]

EngineUpdateWithStartExecutionResult is a type alias for the result type returned by the UpdateWithStart Engine implementation.

type ExecutionAlreadyStartedError added in v1.30.0

type ExecutionAlreadyStartedError struct {
	Message          string
	CurrentRequestID string
	CurrentRunID     string
}

func NewExecutionAlreadyStartedErr added in v1.30.0

func NewExecutionAlreadyStartedErr(
	message, currentRequestID, currentRunID string,
) *ExecutionAlreadyStartedError

func (*ExecutionAlreadyStartedError) Error added in v1.30.0

type ExecutionInfo added in v1.30.0

type ExecutionInfo struct {
	// StateTransitionCount is the number of create/update transactions in the history of this execution.
	StateTransitionCount int64
	// ApproximateStateSize is the approximate size in bytes of the persisted execution state of this execution.
	ApproximateStateSize int
	// CloseTime is the time when the execution was closed.
	// An execution is closed when its root component reaches a terminal state in its lifecycle.
	// If the component is still running (not yet closed), it returns a zero time.Time value.
	CloseTime time.Time
}

type ExecutionKey added in v1.30.0

type ExecutionKey struct {
	NamespaceID string
	BusinessID  string
	RunID       string
}

ExecutionKey uniquely identifies a CHASM execution in the system.

type Field

type Field[T any] struct {
	// This struct needs to be created via reflection, but reflection can't set private fields.
	Internal fieldInternal
}

func ComponentPointerTo added in v1.29.0

func ComponentPointerTo[C Component](
	ctx MutableContext,
	c C,
) Field[C]

ComponentPointerTo returns a CHASM field populated with a pointer to the given component. 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 NewEmptyField[T any]() Field[T]

func (Field[T]) Get

func (f Field[T]) Get(chasmContext Context) T

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

func (f Field[T]) TryGet(chasmContext Context) (T, bool)

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 Group added in v1.30.0

type Group struct {
	Values []*commonpb.Payload
	Count  int64
}

type Library

type Library interface {
	Name() string
	Components() []*RegistrableComponent
	Tasks() []*RegistrableTask
	RegisterServices(server *grpc.Server)
	// NexusServices returns a list of nexus.Service instances to register with the __temporal_system Nexus endpoint.
	NexusServices() []*nexus.Service
	// NexusServiceProcessors returns a list of NexusServiceProcessor instances to register with the __temporal_system
	// Nexus endpoint.
	NexusServiceProcessors() []*NexusServiceProcessor
	// contains filtered or unexported methods
}

type LifecycleState

type LifecycleState int

Shall it be named ComponentLifecycleState?

const (
	// Lifecycle states that are considered OPEN
	//
	// LifecycleStateCreated LifecycleState = 1 << iota
	LifecycleStateRunning LifecycleState = 2 << iota

	// 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 ListExecutionsRequest struct {
	NamespaceName string
	Query         string
	PageSize      int
	NextPageToken []byte
}

type ListExecutionsResponse added in v1.30.0

type ListExecutionsResponse[M proto.Message] struct {
	Executions    []*VisibilityExecutionInfo[M]
	NextPageToken []byte
}

func ListExecutions added in v1.30.0

func ListExecutions[C Component, M proto.Message](
	ctx context.Context,
	request *ListExecutionsRequest,
) (*ListExecutionsResponse[M], error)

ListExecutions lists the executions of a CHASM archetype given an initial query. The query string can specify any combination of CHASM, custom, and predefined/system search attributes. The generic parameter C is the CHASM component type used for executions and search attribute filtering. The generic parameter M is the type of the memo payload to be unmarshaled from the execution. PageSize is required, must be greater than 0. NextPageToken is optional, set on subsequent requests to continue listing the next page of executions. Note: For CHASM executions, TemporalNamespaceDivision is the predefined search attribute that is used to identify the archetype of the execution. If the query string does not specify TemporalNamespaceDivision, the archetype C of the request will be used to filter the executions. If the initial query already specifies TemporalNamespaceDivision, the archetype C of the request will only be used to get the registered SearchAttributes.

type MSPointer added in v1.30.0

type MSPointer struct {
	// contains filtered or unexported fields
}

MSPointer is a special CHASM type which components can use to access their Node's underlying backend (i.e. mutable state). It is used to expose methods needed from the mutable state without polluting the chasm.Context interface. When deserializing components with fields of this type, the CHASM engine will set the value to its NodeBackend. This should only be used by the Workflow component.

func NewMSPointer added in v1.30.0

func NewMSPointer(backend NodeBackend) MSPointer

NewMSPointer creates a new MSPointer instance.

func (MSPointer) GetNexusCompletion added in v1.30.0

func (m MSPointer) GetNexusCompletion(ctx Context, requestID string) (nexusrpc.CompleteOperationOptions, error)

GetNexusCompletion retrieves the Nexus operation completion data for the given request ID from the underlying mutable state.

type Map added in v1.28.0

type Map[K string | int | int8 | int32 | int64 | uint | uint8 | uint32 | uint64 | bool, T any] map[K]Field[T]

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

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockComponent) LifecycleState

func (m *MockComponent) LifecycleState(arg0 Context) LifecycleState

LifecycleState mocks base method.

type MockComponentMockRecorder

type MockComponentMockRecorder struct {
	// contains filtered or unexported fields
}

MockComponentMockRecorder is the mock recorder for MockComponent.

func (*MockComponentMockRecorder) LifecycleState

func (mr *MockComponentMockRecorder) LifecycleState(arg0 any) *gomock.Call

LifecycleState indicates an expected call of LifecycleState.

type MockContext added in v1.29.0

type MockContext struct {
	HandleExecutionKey   func() ExecutionKey
	HandleNow            func(component Component) time.Time
	HandleRef            func(component Component) ([]byte, error)
	HandleExecutionInfo  func() ExecutionInfo
	HandleMetricsHandler func() metrics.Handler

	// GoCtx is the underlying context.Context used for context value lookups.
	// Any values set on it will be available via the CHASM mock context's Value method,
	// and take precedence over any registered context values.
	// Defaults to context.Background() if nil.
	GoCtx context.Context
	// contains filtered or unexported fields
}

MockContext is a mock implementation of Context.

func (*MockContext) ExecutionInfo added in v1.31.0

func (c *MockContext) ExecutionInfo() ExecutionInfo

func (*MockContext) ExecutionKey added in v1.30.0

func (c *MockContext) ExecutionKey() ExecutionKey

func (*MockContext) Logger added in v1.31.0

func (c *MockContext) Logger() log.Logger

func (*MockContext) MetricsHandler added in v1.31.0

func (c *MockContext) MetricsHandler() metrics.Handler

func (*MockContext) Now added in v1.29.0

func (c *MockContext) Now(cmp Component) time.Time

func (*MockContext) Ref added in v1.29.0

func (c *MockContext) Ref(cmp Component) ([]byte, error)

func (*MockContext) RegisterComponentContextValues added in v1.31.0

func (c *MockContext) RegisterComponentContextValues(
	keyValues map[any]any,
)

func (*MockContext) Value added in v1.31.0

func (c *MockContext) Value(key any) any

type MockEngine added in v1.29.0

type MockEngine struct {
	// contains filtered or unexported fields
}

MockEngine is a mock of Engine interface.

func NewMockEngine added in v1.29.0

func NewMockEngine(ctrl *gomock.Controller) *MockEngine

NewMockEngine creates a new mock instance.

func (*MockEngine) DeleteExecution added in v1.31.0

func (m *MockEngine) DeleteExecution(arg0 context.Context, arg1 ComponentRef, arg2 DeleteExecutionRequest) error

DeleteExecution mocks base method.

func (*MockEngine) EXPECT added in v1.29.0

func (m *MockEngine) EXPECT() *MockEngineMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockEngine) NotifyExecution added in v1.30.0

func (m *MockEngine) NotifyExecution(arg0 ExecutionKey)

NotifyExecution mocks base method.

func (*MockEngine) PollComponent added in v1.29.0

func (m *MockEngine) PollComponent(arg0 context.Context, arg1 ComponentRef, arg2 func(Context, Component) (bool, error), arg3 ...TransitionOption) ([]byte, error)

PollComponent mocks base method.

func (*MockEngine) ReadComponent added in v1.29.0

func (m *MockEngine) ReadComponent(arg0 context.Context, arg1 ComponentRef, arg2 func(Context, Component) error, arg3 ...TransitionOption) error

ReadComponent mocks base method.

func (*MockEngine) StartExecution added in v1.31.0

func (m *MockEngine) StartExecution(arg0 context.Context, arg1 ComponentRef, arg2 func(MutableContext) (RootComponent, error), arg3 ...TransitionOption) (StartExecutionResult, error)

StartExecution mocks base method.

func (*MockEngine) UpdateComponent added in v1.29.0

func (m *MockEngine) UpdateComponent(arg0 context.Context, arg1 ComponentRef, arg2 func(MutableContext, Component) error, arg3 ...TransitionOption) ([]byte, error)

UpdateComponent mocks base method.

func (*MockEngine) UpdateWithStartExecution added in v1.31.0

UpdateWithStartExecution mocks base method.

type MockEngineMockRecorder added in v1.29.0

type MockEngineMockRecorder struct {
	// contains filtered or unexported fields
}

MockEngineMockRecorder is the mock recorder for MockEngine.

func (*MockEngineMockRecorder) DeleteExecution added in v1.31.0

func (mr *MockEngineMockRecorder) DeleteExecution(arg0, arg1, arg2 any) *gomock.Call

DeleteExecution indicates an expected call of DeleteExecution.

func (*MockEngineMockRecorder) NotifyExecution added in v1.30.0

func (mr *MockEngineMockRecorder) NotifyExecution(arg0 any) *gomock.Call

NotifyExecution indicates an expected call of NotifyExecution.

func (*MockEngineMockRecorder) PollComponent added in v1.29.0

func (mr *MockEngineMockRecorder) PollComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call

PollComponent indicates an expected call of PollComponent.

func (*MockEngineMockRecorder) ReadComponent added in v1.29.0

func (mr *MockEngineMockRecorder) ReadComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call

ReadComponent indicates an expected call of ReadComponent.

func (*MockEngineMockRecorder) StartExecution added in v1.31.0

func (mr *MockEngineMockRecorder) StartExecution(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call

StartExecution indicates an expected call of StartExecution.

func (*MockEngineMockRecorder) UpdateComponent added in v1.29.0

func (mr *MockEngineMockRecorder) UpdateComponent(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call

UpdateComponent indicates an expected call of UpdateComponent.

func (*MockEngineMockRecorder) UpdateWithStartExecution added in v1.31.0

func (mr *MockEngineMockRecorder) UpdateWithStartExecution(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call

UpdateWithStartExecution indicates an expected call of UpdateWithStartExecution.

type MockLibrary

type MockLibrary struct {
	// contains filtered or unexported fields
}

MockLibrary is a mock of Library interface.

func NewMockLibrary

func NewMockLibrary(ctrl *gomock.Controller) *MockLibrary

NewMockLibrary creates a new mock instance.

func (*MockLibrary) Components

func (m *MockLibrary) Components() []*RegistrableComponent

Components mocks base method.

func (*MockLibrary) EXPECT

func (m *MockLibrary) EXPECT() *MockLibraryMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLibrary) Name

func (m *MockLibrary) Name() string

Name mocks base method.

func (*MockLibrary) NexusServiceProcessors added in v1.31.0

func (m *MockLibrary) NexusServiceProcessors() []*NexusServiceProcessor

NexusServiceProcessors mocks base method.

func (*MockLibrary) NexusServices added in v1.31.0

func (m *MockLibrary) NexusServices() []*nexus.Service

NexusServices mocks base method.

func (*MockLibrary) RegisterServices added in v1.30.0

func (m *MockLibrary) RegisterServices(server *grpc.Server)

RegisterServices mocks base method.

func (*MockLibrary) Tasks

func (m *MockLibrary) Tasks() []*RegistrableTask

Tasks mocks base method.

type MockLibraryMockRecorder

type MockLibraryMockRecorder struct {
	// contains filtered or unexported fields
}

MockLibraryMockRecorder is the mock recorder for MockLibrary.

func (*MockLibraryMockRecorder) Components

func (mr *MockLibraryMockRecorder) Components() *gomock.Call

Components indicates an expected call of Components.

func (*MockLibraryMockRecorder) Name

func (mr *MockLibraryMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name.

func (*MockLibraryMockRecorder) NexusServiceProcessors added in v1.31.0

func (mr *MockLibraryMockRecorder) NexusServiceProcessors() *gomock.Call

NexusServiceProcessors indicates an expected call of NexusServiceProcessors.

func (*MockLibraryMockRecorder) NexusServices added in v1.31.0

func (mr *MockLibraryMockRecorder) NexusServices() *gomock.Call

NexusServices indicates an expected call of NexusServices.

func (*MockLibraryMockRecorder) RegisterServices added in v1.30.0

func (mr *MockLibraryMockRecorder) RegisterServices(server any) *gomock.Call

RegisterServices indicates an expected call of RegisterServices.

func (*MockLibraryMockRecorder) Tasks

func (mr *MockLibraryMockRecorder) Tasks() *gomock.Call

Tasks indicates an expected call of Tasks.

type MockMutableContext added in v1.29.0

type MockMutableContext struct {
	MockContext

	Tasks []MockTask
	// 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
	HandleGetApproximatePersistedSize func() int
	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.CompleteOperationOptions, 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) GetApproximatePersistedSize added in v1.31.0

func (m *MockNodeBackend) GetApproximatePersistedSize() int

func (*MockNodeBackend) GetCurrentVersion added in v1.28.0

func (m *MockNodeBackend) GetCurrentVersion() int64

func (*MockNodeBackend) GetExecutionInfo added in v1.28.0

func (m *MockNodeBackend) GetExecutionInfo() *persistencespb.WorkflowExecutionInfo

func (*MockNodeBackend) GetExecutionState added in v1.29.0

func (m *MockNodeBackend) GetExecutionState() *persistencespb.WorkflowExecutionState

func (*MockNodeBackend) GetNexusCompletion added in v1.30.0

func (m *MockNodeBackend) GetNexusCompletion(
	ctx context.Context,
	requestID string,
) (nexusrpc.CompleteOperationOptions, 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 MockPureTaskHandler added in v1.31.0

type MockPureTaskHandler[C any, T any] struct {
	// contains filtered or unexported fields
}

MockPureTaskHandler is a mock of PureTaskHandler interface.

func NewMockPureTaskHandler added in v1.31.0

func NewMockPureTaskHandler[C any, T any](ctrl *gomock.Controller) *MockPureTaskHandler[C, T]

NewMockPureTaskHandler creates a new mock instance.

func (*MockPureTaskHandler[C, T]) EXPECT added in v1.31.0

func (m *MockPureTaskHandler[C, T]) EXPECT() *MockPureTaskHandlerMockRecorder[C, T]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPureTaskHandler[C, T]) Execute added in v1.31.0

func (m *MockPureTaskHandler[C, T]) Execute(arg0 MutableContext, arg1 C, arg2 TaskAttributes, arg3 T) error

Execute mocks base method.

func (*MockPureTaskHandler[C, T]) Validate added in v1.31.0

func (m *MockPureTaskHandler[C, T]) Validate(arg0 Context, arg1 C, arg2 TaskAttributes, arg3 T) (bool, error)

Validate mocks base method.

type MockPureTaskHandlerMockRecorder added in v1.31.0

type MockPureTaskHandlerMockRecorder[C any, T any] struct {
	// contains filtered or unexported fields
}

MockPureTaskHandlerMockRecorder is the mock recorder for MockPureTaskHandler.

func (*MockPureTaskHandlerMockRecorder[C, T]) Execute added in v1.31.0

func (mr *MockPureTaskHandlerMockRecorder[C, T]) Execute(arg0, arg1, arg2, arg3 any) *gomock.Call

Execute indicates an expected call of Execute.

func (*MockPureTaskHandlerMockRecorder[C, T]) Validate added in v1.31.0

func (mr *MockPureTaskHandlerMockRecorder[C, T]) Validate(arg0, arg1, arg2, arg3 any) *gomock.Call

Validate indicates an expected call of Validate.

type MockRootComponent added in v1.31.0

type MockRootComponent struct {
	// contains filtered or unexported fields
}

MockRootComponent is a mock of RootComponent interface.

func NewMockRootComponent added in v1.31.0

func NewMockRootComponent(ctrl *gomock.Controller) *MockRootComponent

NewMockRootComponent creates a new mock instance.

func (*MockRootComponent) ContextMetadata added in v1.31.0

func (m *MockRootComponent) ContextMetadata(arg0 Context) map[string]string

ContextMetadata mocks base method.

func (*MockRootComponent) EXPECT added in v1.31.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRootComponent) LifecycleState added in v1.31.0

func (m *MockRootComponent) LifecycleState(arg0 Context) LifecycleState

LifecycleState mocks base method.

func (*MockRootComponent) Terminate added in v1.31.0

Terminate mocks base method.

type MockRootComponentMockRecorder added in v1.31.0

type MockRootComponentMockRecorder struct {
	// contains filtered or unexported fields
}

MockRootComponentMockRecorder is the mock recorder for MockRootComponent.

func (*MockRootComponentMockRecorder) ContextMetadata added in v1.31.0

func (mr *MockRootComponentMockRecorder) ContextMetadata(arg0 any) *gomock.Call

ContextMetadata indicates an expected call of ContextMetadata.

func (*MockRootComponentMockRecorder) LifecycleState added in v1.31.0

func (mr *MockRootComponentMockRecorder) LifecycleState(arg0 any) *gomock.Call

LifecycleState indicates an expected call of LifecycleState.

func (*MockRootComponentMockRecorder) Terminate added in v1.31.0

func (mr *MockRootComponentMockRecorder) Terminate(arg0, arg1 any) *gomock.Call

Terminate indicates an expected call of Terminate.

type MockSideEffectTaskHandler added in v1.31.0

type MockSideEffectTaskHandler[C any, T any] struct {
	// contains filtered or unexported fields
}

MockSideEffectTaskHandler is a mock of SideEffectTaskHandler interface.

func NewMockSideEffectTaskHandler added in v1.31.0

func NewMockSideEffectTaskHandler[C any, T any](ctrl *gomock.Controller) *MockSideEffectTaskHandler[C, T]

NewMockSideEffectTaskHandler creates a new mock instance.

func (*MockSideEffectTaskHandler[C, T]) Discard added in v1.31.0

func (m *MockSideEffectTaskHandler[C, T]) Discard(arg0 context.Context, arg1 ComponentRef, arg2 TaskAttributes, arg3 T) error

Discard mocks base method.

func (*MockSideEffectTaskHandler[C, T]) EXPECT added in v1.31.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSideEffectTaskHandler[C, T]) Execute added in v1.31.0

func (m *MockSideEffectTaskHandler[C, T]) Execute(arg0 context.Context, arg1 ComponentRef, arg2 TaskAttributes, arg3 T) error

Execute mocks base method.

func (*MockSideEffectTaskHandler[C, T]) Validate added in v1.31.0

func (m *MockSideEffectTaskHandler[C, T]) Validate(arg0 Context, arg1 C, arg2 TaskAttributes, arg3 T) (bool, error)

Validate mocks base method.

type MockSideEffectTaskHandlerMockRecorder added in v1.31.0

type MockSideEffectTaskHandlerMockRecorder[C any, T any] struct {
	// contains filtered or unexported fields
}

MockSideEffectTaskHandlerMockRecorder is the mock recorder for MockSideEffectTaskHandler.

func (*MockSideEffectTaskHandlerMockRecorder[C, T]) Discard added in v1.31.0

func (mr *MockSideEffectTaskHandlerMockRecorder[C, T]) Discard(arg0, arg1, arg2, arg3 any) *gomock.Call

Discard indicates an expected call of Discard.

func (*MockSideEffectTaskHandlerMockRecorder[C, T]) Execute added in v1.31.0

func (mr *MockSideEffectTaskHandlerMockRecorder[C, T]) Execute(arg0, arg1, arg2, arg3 any) *gomock.Call

Execute indicates an expected call of Execute.

func (*MockSideEffectTaskHandlerMockRecorder[C, T]) Validate added in v1.31.0

func (mr *MockSideEffectTaskHandlerMockRecorder[C, T]) Validate(arg0, arg1, arg2, arg3 any) *gomock.Call

Validate indicates an expected call of Validate.

type MockTask added in v1.30.0

type MockTask struct {
	Component  Component
	Attributes TaskAttributes
	Payload    any
}

type MockTaskValidator added in v1.28.0

type MockTaskValidator[C any, T any] struct {
	// contains filtered or unexported fields
}

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.

func (*MockTaskValidatorMockRecorder[C, T]) Validate added in v1.28.0

func (mr *MockTaskValidatorMockRecorder[C, T]) Validate(arg0, arg1, arg2, arg3 any) *gomock.Call

Validate indicates an expected call of Validate.

type MockTerminableComponent added in v1.31.0

type MockTerminableComponent struct {
	// contains filtered or unexported fields
}

MockTerminableComponent is a mock of TerminableComponent interface.

func NewMockTerminableComponent added in v1.31.0

func NewMockTerminableComponent(ctrl *gomock.Controller) *MockTerminableComponent

NewMockTerminableComponent creates a new mock instance.

func (*MockTerminableComponent) EXPECT added in v1.31.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTerminableComponent) LifecycleState added in v1.31.0

func (m *MockTerminableComponent) LifecycleState(arg0 Context) LifecycleState

LifecycleState mocks base method.

func (*MockTerminableComponent) Terminate added in v1.31.0

Terminate mocks base method.

type MockTerminableComponentMockRecorder added in v1.31.0

type MockTerminableComponentMockRecorder struct {
	// contains filtered or unexported fields
}

MockTerminableComponentMockRecorder is the mock recorder for MockTerminableComponent.

func (*MockTerminableComponentMockRecorder) LifecycleState added in v1.31.0

func (mr *MockTerminableComponentMockRecorder) LifecycleState(arg0 any) *gomock.Call

LifecycleState indicates an expected call of LifecycleState.

func (*MockTerminableComponentMockRecorder) Terminate added in v1.31.0

func (mr *MockTerminableComponentMockRecorder) Terminate(arg0, arg1 any) *gomock.Call

Terminate indicates an expected call of Terminate.

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

CountExecutions mocks base method.

func (*MockVisibilityManager) EXPECT added in v1.30.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockVisibilityManager) ListExecutions added in v1.30.0

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.

func (*Mocknamer) Name added in v1.28.0

func (m *Mocknamer) Name() string

Name mocks base method.

type MocknamerMockRecorder added in v1.28.0

type MocknamerMockRecorder struct {
	// contains filtered or unexported fields
}

MocknamerMockRecorder is the mock recorder for Mocknamer.

func (*MocknamerMockRecorder) Name added in v1.28.0

func (mr *MocknamerMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name.

type MutableContext

type MutableContext interface {
	Context

	// AddTask adds a task to be emitted as part of the current transaction.
	// The task is associated with the given component and will be invoked via the registered handler for the given task
	// referencing the component.
	AddTask(Component, TaskAttributes, any)
}

func NewMutableContext added in v1.28.0

func NewMutableContext(
	ctx context.Context,
	node *Node,
) MutableContext

NewMutableContext creates a new MutableContext from an existing Context and root Node.

NOTE: Library authors should not invoke this constructor directly, and instead use the UpdateComponent, UpdateWithStartExecution, or StartExecution APIs.

type NexusCompletionHandler added in v1.30.0

type NexusCompletionHandler interface {
	HandleNexusCompletion(ctx MutableContext, completion *persistencespb.ChasmNexusCompletion) error
}

NexusCompletionHandler is implemented by CHASM components that want to handle Nexus operation completion callbacks.

type NexusCompletionHandlerComponent added in v1.30.0

type NexusCompletionHandlerComponent interface {
	Component
	NexusCompletionHandler
}

NexusCompletionHandlerComponent is a CHASM Component that also implements NexusCompletionHandler.

type NexusEndpointProcessor added in v1.31.0

type NexusEndpointProcessor struct {
	// contains filtered or unexported fields
}

NexusEndpointProcessor handles input processing for Nexus operations across multiple services within a Nexus endpoint. It routes requests to the appropriate service processor based on the service name.

func NewNexusEndpointProcessor added in v1.31.0

func NewNexusEndpointProcessor() *NexusEndpointProcessor

NewNexusEndpointProcessor creates a new NexusEndpointProcessor.

func (*NexusEndpointProcessor) MustRegisterServiceProcessor added in v1.31.0

func (p *NexusEndpointProcessor) MustRegisterServiceProcessor(processor *NexusServiceProcessor)

MustRegisterServiceProcessor registers the service processor and panics if registration fails.

func (*NexusEndpointProcessor) ProcessInput added in v1.31.0

ProcessInput routes the input processing request to the appropriate service processor and returns routing information for the operation.

Returns a nexus.HandlerError if the service is not found or if input processing fails.

func (*NexusEndpointProcessor) RegisterServiceProcessor added in v1.31.0

func (p *NexusEndpointProcessor) RegisterServiceProcessor(processor *NexusServiceProcessor) error

RegisterServiceProcessor adds a service-level processor to the endpoint keyed by its name. Returns an error if a processor with the same name is already registered.

type NexusOperationProcessor added in v1.31.0

type NexusOperationProcessor[I any] interface {
	// ProcessInput validates the input, and returns routing information for processing this operation. The
	// method may mutate the input to set default values.
	ProcessInput(ctx NexusOperationProcessorContext, input I) (*NexusOperationProcessorResult, error)
}

NexusOperationProcessor is an interface that can be implemented per operation to validate and determine routing for the operation.

type NexusOperationProcessorContext added in v1.31.0

type NexusOperationProcessorContext struct {
	// Namespace is the target namespace used for routing and validation of Nexus operations.
	Namespace *namespace.Namespace
	// RequestID is a unique identifier for the incoming operation request, used for correlation and idempotency
	// across retries.
	RequestID string
	Links     []nexus.Link
	// A boolean indicating whether the operation processor framework should re-serialize the input and store it in the
	// [NexusOperationProcessorResult.ReserializedInputPayload] field. Processor implementations may mutate the input regardless.
	ReserializeInputPayload bool
}

NexusOperationProcessorContext contains context for processing a Nexus operation's input, including the target namespace and a request identifier used for tracing and idempotency.

type NexusOperationProcessorResult added in v1.31.0

type NexusOperationProcessorResult struct {
	// RoutingKey determines which history shard should process the operation.
	RoutingKey NexusOperationRoutingKey
	// A field set by the framework to containing the re-serialized input payload if requested in the given context.
	ReserializedInputPayload *commonpb.Payload
}

NexusOperationProcessorResult contains the result of processing a Nexus operation input, including the routing key that determines which shard should handle the operation.

type NexusOperationRoutingKey added in v1.31.0

type NexusOperationRoutingKey interface {
	// ShardID returns the target shard ID for this routing key given the total number of shards.
	ShardID(numShards int32) int32
}

NexusOperationRoutingKey determines which history shard should process a Nexus operation. Different implementations provide different routing strategies (e.g., by execution, random).

type NexusOperationRoutingKeyExecution added in v1.31.0

type NexusOperationRoutingKeyExecution struct {
	// NamespaceID is the ID of the namespace containing the execution whose shard should be targeted.
	NamespaceID string
	// BusinessID is the business identifier (e.g., workflow ID) of the execution.
	BusinessID string
}

NexusOperationRoutingKeyExecution routes operations to a specific shard based on an execution key. This ensures that operations related to the same execution are processed on the same shard.

func (NexusOperationRoutingKeyExecution) ShardID added in v1.31.0

func (r NexusOperationRoutingKeyExecution) ShardID(numShards int32) int32

ShardID returns the shard that owns the execution identified by the namespace and business IDs.

type NexusOperationRoutingKeyRandom added in v1.31.0

type NexusOperationRoutingKeyRandom struct {
}

NexusOperationRoutingKeyRandom routes operations to a random shard. The ShardID method returns a randomly selected valid shard ID.

func (NexusOperationRoutingKeyRandom) ShardID added in v1.31.0

func (NexusOperationRoutingKeyRandom) ShardID(numShards int32) int32

ShardID returns a randomly selected shard ID in the range [1, numShards].

type NexusServiceProcessor added in v1.31.0

type NexusServiceProcessor struct {
	// contains filtered or unexported fields
}

NexusServiceProcessor handles input processing for operations within a specific Nexus service. It uses reflection to dynamically invoke the ProcessInput method on operations that implement it.

func NewNexusServiceProcessor added in v1.31.0

func NewNexusServiceProcessor(name string) *NexusServiceProcessor

NewNexusServiceProcessor constructs a processor for a single Nexus service that can register and invoke operation processors by name.

func (*NexusServiceProcessor) MustRegisterOperation added in v1.31.0

func (p *NexusServiceProcessor) MustRegisterOperation(name string, op RegisterableNexusOperationProcessor)

MustRegisterOperation registers a named operation and panics if registration fails.

func (*NexusServiceProcessor) ProcessInput added in v1.31.0

ProcessInput routes the input processing request to the appropriate operation processor and returns routing information for the operation.

Returns a nexus.HandlerError if the operation is not found or if input processing fails.

func (*NexusServiceProcessor) RegisterOperation added in v1.31.0

RegisterOperation registers a named operation with this service processor. Returns an error if an operation with the same name is already registered.

type NoValue added in v1.30.0

type NoValue = *struct{}

NoValue is a sentinel type representing no value. Useful for accessing components using the engine methods (e.g., [GetComponent]) with a function that does not need to return any information.

type Node added in v1.28.0

type Node struct {
	// contains filtered or unexported fields
}

Node is the in-memory representation of a persisted CHASM node.

Node and all its methods are NOT meant to be used by CHASM component authors. They are exported for use by the CHASM engine and underlying MutableState implementation only.

func NewEmptyTree added in v1.28.0

func NewEmptyTree(
	registry *Registry,
	timeSource clock.TimeSource,
	backend NodeBackend,
	pathEncoder NodePathEncoder,
	logger log.Logger,
	metricsHandler metrics.Handler,
) *Node

NewEmptyTree creates a new empty in-memory CHASM tree.

func NewTreeFromDB added in v1.30.0

func NewTreeFromDB(
	serializedNodes map[string]*persistencespb.ChasmNode,
	registry *Registry,
	timeSource clock.TimeSource,
	backend NodeBackend,
	pathEncoder NodePathEncoder,
	logger log.Logger,
	metricsHandler metrics.Handler,
) (*Node, error)

NewTreeFromDB creates a new in-memory CHASM tree from a collection of flattened persistence CHASM nodes. This method should only be used when loading an existing CHASM tree from database. If serializedNodes is empty, the tree will be considered as a legacy Workflow execution without any CHASM nodes.

func (*Node) AddTask added in v1.28.0

func (n *Node) AddTask(
	component Component,
	taskAttributes TaskAttributes,
	task any,
)

AddTask implements the CHASM MutableContext interface

func (*Node) ApplyMutation added in v1.28.0

func (n *Node) ApplyMutation(
	mutation NodesMutation,
) error

ApplyMutation is used by replication stack to apply node mutations from the source cluster.

NOTE: It will be an error if UpdatedNodes and DeletedNodes have overlapping keys, as the CHASM tree does not have enough information to tell if the deletion happens before or after the update.

func (*Node) ApplySnapshot added in v1.28.0

func (n *Node) ApplySnapshot(
	incomingSnapshot NodesSnapshot,
) error

ApplySnapshot is used by replication stack to apply node snapshot from the source cluster.

If we simply substituting the entire CHASM tree, we will be forced to close the transaction as snapshot and potentially write extra data to persistence. This method will instead figure out the mutations needed to bring the current tree to the be the same as the snapshot, thus allowing us to close the transaction as mutation.

func (*Node) ApplySystemMutation added in v1.31.0

func (n *Node) ApplySystemMutation(
	mutation NodesMutation,
) error

ApplySystemMutation should only used by internal persistence layer logic to force apply cluster specific chasm tree changes. DO NOT USE if you don't know why this method is introduced.

func (*Node) Archetype added in v1.28.0

func (n *Node) Archetype() (Archetype, error)

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 (n *Node) ComponentByPath(
	chasmContext Context,
	path []string,
) (Component, error)

func (*Node) EachPureTask added in v1.28.0

func (n *Node) EachPureTask(
	referenceTime time.Time,
	callback func(handler NodePureTask, taskAttributes TaskAttributes, taskInstance any) (bool, error),
) error

EachPureTask runs the callback for all expired/runnable pure tasks within the CHASM tree (including invalid tasks). The CHASM tree is left untouched, even if invalid tasks are detected (these are cleaned up as part of transaction close).

func (*Node) ExecutePureTask added in v1.28.0

func (n *Node) ExecutePureTask(
	baseCtx context.Context,
	taskAttributes TaskAttributes,
	taskInstance any,
) (_ bool, retErr error)

ExecutePureTask validates and then executes the given taskInstance against the node's component. Executing an invalid task is a no-op (no error returned).

func (*Node) ExecuteSideEffectDiscardTask added in v1.31.0

func (n *Node) ExecuteSideEffectDiscardTask(
	ctx context.Context,
	executionKey ExecutionKey,
	chasmTask *tasks.ChasmTask,
	validate func(NodeBackend, Context, Component) error,
) error

ExecuteSideEffectDiscardTask executes the discard handler for the given ChasmTask. This is called on standby clusters when a side effect task has been pending past the discard delay, allowing custom discard behavior (e.g., spilling activity tasks to matching).

func (*Node) ExecuteSideEffectTask added in v1.29.0

func (n *Node) ExecuteSideEffectTask(
	ctx context.Context,
	executionKey ExecutionKey,
	chasmTask *tasks.ChasmTask,
	validate func(NodeBackend, Context, Component) error,
) error

ExecuteSideEffectTask executes the given ChasmTask on its associated node without holding the execution lock.

WARNING: This method *must not* access the node's properties without first locking the execution.

ctx should have a CHASM engine already set.

func (*Node) IsDirty added in v1.28.0

func (n *Node) IsDirty() bool

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

func (n *Node) IsStateDirty() bool

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) Now added in v1.28.0

func (n *Node) Now(
	_ Component,
) time.Time

Now implements the CHASM Context interface

func (*Node) Ref added in v1.28.0

func (n *Node) Ref(
	component Component,
) ([]byte, error)

Ref implements the CHASM Context interface

func (*Node) RefreshTasks added in v1.29.0

func (n *Node) RefreshTasks() error

func (*Node) SetDeleteAfterClose added in v1.31.0

func (n *Node) SetDeleteAfterClose(deleteAfterClose bool)

SetDeleteAfterClose suppresses the close visibility task when an execution is being terminated as part of a delete operation. Must be called before a [Terminate] call, like in DeleteExecution.

func (*Node) SetRootComponent added in v1.29.0

func (n *Node) SetRootComponent(
	rootComponent RootComponent,
) error

func (*Node) Snapshot added in v1.28.0

func (n *Node) Snapshot(
	exclusiveMinVT *persistencespb.VersionedTransition,
) NodesSnapshot

Snapshot returns all nodes in the tree that have been modified after the given min versioned transition. A nil exclusiveMinVT will be treated as the same as the zero versioned transition and returns all nodes in the tree. This method should only be invoked on root CHASM node when IsDirty() is false.

func (*Node) Terminate added in v1.28.0

func (n *Node) Terminate(
	request TerminateComponentRequest,
) error

func (*Node) 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 handlers 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 handlers.

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
	GetApproximatePersistedSize() int
	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.CompleteOperationOptions, 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

func (p ParentPtr[T]) Get(chasmContext Context) T

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.

func (ParentPtr[T]) TryGet added in v1.30.0

func (p ParentPtr[T]) TryGet(chasmContext Context) (T, bool)

TryGet returns the parent component 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.

type PureTaskHandler added in v1.31.0

type PureTaskHandler[C any, T any] interface {
	TaskValidator[C, T]
	Execute(MutableContext, C, TaskAttributes, T) error
	// contains filtered or unexported methods
}

PureTaskHandler handles pure tasks that run while holding execution state write lock and should not do I/O. Implementations must embed PureTaskHandlerBase.

type PureTaskHandlerBase added in v1.31.0

type PureTaskHandlerBase struct{}

PureTaskHandlerBase must be embedded in all pure task handler implementations.

type RegisterableNexusOperationProcessor added in v1.31.0

type RegisterableNexusOperationProcessor struct {
	// contains filtered or unexported fields
}

RegisterableNexusOperationProcessor adapts a typed Nexus operation processor for dynamic registration and invocation within a service processor.

func NewRegisterableNexusOperationProcessor added in v1.31.0

func NewRegisterableNexusOperationProcessor[I any](op NexusOperationProcessor[I]) RegisterableNexusOperationProcessor

NewRegisterableNexusOperationProcessor wraps a typed NexusOperationProcessor and returns a registerable adapter.

type RegistrableComponent

type RegistrableComponent struct {
	// contains filtered or unexported fields
}

func NewRegistrableComponent

func NewRegistrableComponent[C Component](
	componentType string,
	opts ...RegistrableComponentOption,
) *RegistrableComponent

func (*RegistrableComponent) GoType added in v1.31.0

func (rc *RegistrableComponent) GoType() reflect.Type

GoType returns the reflect.Type of the component's Go struct.

func (*RegistrableComponent) IsDetached added in v1.31.0

func (rc *RegistrableComponent) IsDetached() bool

IsDetached returns true if the component type is registered as detached.

func (*RegistrableComponent) SearchAttributesMapper added in v1.30.0

func (rc *RegistrableComponent) SearchAttributesMapper() *VisibilitySearchAttributesMapper

SearchAttributesMapper returns the search attributes mapper for this component.

type RegistrableComponentOption

type RegistrableComponentOption func(*RegistrableComponent)

func WithBusinessIDAlias added in v1.30.0

func WithBusinessIDAlias(
	alias string,
) RegistrableComponentOption

WithBusinessIDAlias allows specifying the business ID alias of the component. This option must be specified if the archetype uses the Visibility component.

func WithContextValues added in v1.31.0

func WithContextValues(
	keyVals map[any]any,
) RegistrableComponentOption

WithContextValues allows specifying key-value pairs that will be available in the Context via the Value() method whenever the chasm framework starts, updates, reads, polls, executes or validates tasks on a component.

This is useful for propagating values needed for those processing logic but are not avaiable via the component's struct definition, such as configurations.

Keys need to be globally unique across components. Conflicting keys across will cause component registration to fail.

Manually added key-value pairs via ContextWithValue() will take precedence over registered context values.

func WithDetached added in v1.31.0

func WithDetached() RegistrableComponentOption

WithDetached marks the registrable component as detached. Detached components ignore parent lifecycle validation, allowing them to continue operating when their parent is closed/terminated. If a registrable component is not detached by default, a component definition can specify its child as detached via ComponentFieldDetached() option.

func WithEphemeral

func WithEphemeral() RegistrableComponentOption

func WithSearchAttributes added in v1.30.0

func WithSearchAttributes(
	searchAttributes ...SearchAttribute,
) RegistrableComponentOption

func WithSingleCluster

func WithSingleCluster() RegistrableComponentOption

Is there any use case where we don't want to replicate certain instances of a archetype?

type RegistrableTask

type RegistrableTask struct {
	// contains filtered or unexported fields
}

func NewRegistrablePureTask added in v1.28.0

func NewRegistrablePureTask[C any, T any](
	taskType string,
	handler PureTaskHandler[C, T],
	opts ...RegistrableTaskOption,
) *RegistrableTask

func NewRegistrableSideEffectTask added in v1.28.0

func NewRegistrableSideEffectTask[C any, T any](
	taskType string,
	handler SideEffectTaskHandler[C, T],
	opts ...RegistrableTaskOption,
) *RegistrableTask

NewRegistrableSideEffectTask creates a new registrable side-effect task. NOTE: C is not Component but any. The handler's Discard method is called on standby clusters when a task has been pending past the discard delay.

func (*RegistrableTask) GoType added in v1.31.0

func (rt *RegistrableTask) GoType() reflect.Type

GoType returns the reflect.Type of the task's Go struct.

type RegistrableTaskOption

type RegistrableTaskOption func(*RegistrableTask)

type Registry

type Registry struct {
	NexusEndpointProcessor *NexusEndpointProcessor
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(logger log.Logger) *Registry

func (*Registry) ArchetypeDisplayName added in v1.31.0

func (r *Registry) ArchetypeDisplayName(id ArchetypeID) (string, bool)

ArchetypeDisplayName returns the human-readable name for a given archetype ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.

func (*Registry) ArchetypeIDOf added in v1.30.0

func (r *Registry) ArchetypeIDOf(componentGoType reflect.Type) (ArchetypeID, bool)

ArchetypeIDOf returns the ArchetypeID for the given component Go type. This method should only be used by CHASM framework internal code, NOT CHASM library developers.

func (*Registry) ComponentByID added in v1.30.0

func (r *Registry) ComponentByID(id uint32) (*RegistrableComponent, bool)

ComponentByID returns the registrable component for a given archetype ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.

func (*Registry) ComponentFqnByID added in v1.30.0

func (r *Registry) ComponentFqnByID(id uint32) (string, bool)

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

func (r *Registry) ComponentIDByFqn(fqn string) (uint32, bool)

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

func (r *Registry) ComponentIDFor(componentInstance any) (uint32, bool)

ComponentIDFor converts registered component instance to component type ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.

func (*Registry) NexusServices added in v1.31.0

func (r *Registry) NexusServices() map[string]*nexus.Service

NexusServices returns all registered Nexus services.

func (*Registry) Register

func (r *Registry) Register(lib Library) error

func (*Registry) RegisterServices added in v1.30.0

func (r *Registry) RegisterServices(server *grpc.Server)

RegisterServices registers all gRPC services from all registered libraries.

func (*Registry) TaskByID added in v1.31.0

func (r *Registry) TaskByID(id uint32) (*RegistrableTask, bool)

TaskByID returns the registrable task for a given task type ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.

func (*Registry) TaskFqnByID added in v1.30.0

func (r *Registry) TaskFqnByID(id uint32) (string, bool)

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.

func (*Registry) TaskIDFor added in v1.30.0

func (r *Registry) TaskIDFor(taskInstance any) (uint32, bool)

TaskIDFor converts registered task instance to task type ID. This method should only be used by CHASM framework internal code, NOT CHASM library developers.

type RootComponent added in v1.31.0

type RootComponent interface {
	TerminableComponent

	// ContextMetadata returns execution metadata to propagate to the request context.
	ContextMetadata(Context) map[string]string
}

RootComponent is the interface that must be implemented by the top level component of a chasm execution. When the RootComponent's LifecycleState transitions to a closed state, the entire execution is considered closed, and will be cleaned up by the chasm framework after namespace's retention period. The BusinessID is also available for reuse.

TODO: (not yet true) Visibility record will no longer be updated after RootComponent is closed.

type SearchAttribute added in v1.30.0

type SearchAttribute interface {
	// contains filtered or unexported methods
}

SearchAttribute is a shared interface for all search attribute types. Each type must embed searchAttributeDefinition.

type SearchAttributeBool added in v1.30.0

type SearchAttributeBool struct {
	// contains filtered or unexported fields
}

SearchAttributeBool is a search attribute for a boolean value.

func NewSearchAttributeBool added in v1.30.0

func NewSearchAttributeBool(alias string, boolField SearchAttributeFieldBool) SearchAttributeBool

NewSearchAttributeBool creates a new boolean search attribute given a predefined chasm field

func (SearchAttributeBool) Value added in v1.30.0

func (s SearchAttributeBool) Value(value bool) SearchAttributeKeyValue

Value sets the boolean value of the search attribute.

type SearchAttributeDateTime added in v1.30.0

type SearchAttributeDateTime struct {
	// contains filtered or unexported fields
}

SearchAttributeDateTime is a search attribute for a datetime value.

func NewSearchAttributeDateTime added in v1.30.0

func NewSearchAttributeDateTime(alias string, datetimeField SearchAttributeFieldDateTime) SearchAttributeDateTime

NewSearchAttributeDateTime creates a new date time search attribute given a predefined chasm field

func (SearchAttributeDateTime) Value added in v1.30.0

func (s SearchAttributeDateTime) Value(value time.Time) SearchAttributeKeyValue

Value sets the date time value of the search attribute.

type SearchAttributeDouble added in v1.30.0

type SearchAttributeDouble struct {
	// contains filtered or unexported fields
}

SearchAttributeDouble is a search attribute for a double value.

func NewSearchAttributeDouble added in v1.30.0

func NewSearchAttributeDouble(alias string, doubleField SearchAttributeFieldDouble) SearchAttributeDouble

NewSearchAttributeDouble creates a new double search attribute given a predefined chasm field

func (SearchAttributeDouble) Value added in v1.30.0

func (s SearchAttributeDouble) Value(value float64) SearchAttributeKeyValue

Value sets the double value of the search attribute.

type SearchAttributeFieldBool added in v1.30.0

type SearchAttributeFieldBool struct {
	// contains filtered or unexported fields
}

SearchAttributeFieldBool is a search attribute field for a boolean value.

type SearchAttributeFieldDateTime added in v1.30.0

type SearchAttributeFieldDateTime struct {
	// contains filtered or unexported fields
}

SearchAttributeFieldDateTime is a search attribute field for a datetime value.

type SearchAttributeFieldDouble added in v1.30.0

type SearchAttributeFieldDouble struct {
	// contains filtered or unexported fields
}

SearchAttributeFieldDouble is a search attribute field for a double value.

type SearchAttributeFieldInt added in v1.30.0

type SearchAttributeFieldInt struct {
	// contains filtered or unexported fields
}

SearchAttributeFieldInt is a search attribute field for an integer value.

type SearchAttributeFieldKeyword added in v1.30.0

type SearchAttributeFieldKeyword struct {
	// contains filtered or unexported fields
}

SearchAttributeFieldKeyword is a search attribute field for a keyword value.

type SearchAttributeFieldKeywordList added in v1.30.0

type SearchAttributeFieldKeywordList struct {
	// contains filtered or unexported fields
}

SearchAttributeFieldKeywordList is a search attribute field for a keyword list value.

type 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 SideEffectTaskHandler added in v1.31.0

type SideEffectTaskHandler[C any, T any] interface {
	TaskValidator[C, T]
	Execute(context.Context, ComponentRef, TaskAttributes, T) error
	// Discard implements custom discard behavior on standby clusters. When a side-effect task has been
	// pending on standby past the discard delay, the framework calls Discard instead of silently dropping
	// the task. For example, the activity dispatch handler implements this to spill tasks to matching.
	// The ctx carries engine access, but implementations must avoid mutating component state on standby
	// clusters.
	Discard(context.Context, ComponentRef, TaskAttributes, T) error
	// contains filtered or unexported methods
}

SideEffectTaskHandler handles side effect tasks that run outside of the state lock and have access to a Go context to perform I/O and access chasm engine methods such as UpdateComponent. Implementations must embed SideEffectTaskHandlerBase.

type SideEffectTaskHandlerBase added in v1.31.0

type SideEffectTaskHandlerBase[T any] struct{}

SideEffectTaskHandlerBase provides a default Discard implementation that returns ErrTaskDiscarded. Embed this in side-effect task handler structs to satisfy the SideEffectTaskHandler interface.

func (SideEffectTaskHandlerBase[T]) Discard added in v1.31.0

type StartExecutionResult added in v1.31.0

type StartExecutionResult struct {
	ExecutionKey ExecutionKey
	ExecutionRef []byte
	Created      bool
}

StartExecutionResult contains the outcome of creating a new execution via StartExecution.

This struct provides information about whether a new execution was actually created, along with identifiers needed to reference the execution in subsequent operations.

Fields:

func StartExecution added in v1.31.0

func StartExecution[C RootComponent, I any](
	ctx context.Context,
	key ExecutionKey,
	startFn func(MutableContext, I) (C, error),
	input I,
	opts ...TransitionOption,
) (StartExecutionResult, error)

StartExecution creates a new execution with a component initialized by the provided factory function.

This is the primary entry point for starting a new execution in the CHASM engine. It handles the lifecycle of creating and persisting a new component within an execution context.

Type Parameters:

  • C: The component type to create, must implement RootComponent
  • I: The input type passed to the factory function
  • O: The output type returned by the factory function

Parameters:

  • ctx: Context containing the CHASM engine (must be created via NewEngineContext)
  • key: Unique identifier for the execution, used for deduplication and lookup
  • startFn: Factory function that creates the component and produces output. Receives a MutableContext for accessing engine capabilities and the input value.
  • input: Application-specific data passed to startFn
  • opts: Optional TransitionOption functions to configure creation behavior:
  • WithBusinessIDPolicy: Controls duplicate handling and conflict resolution
  • WithRequestID: Sets a request ID for idempotency
  • WithSpeculative: Defers persistence until the next non-speculative transition

Returns:

  • O: The output value produced by startFn
  • [NewExecutionResult]: Contains the execution key, serialized ref, and whether a new execution was created
  • error: Non-nil if creation failed or policy constraints were violated

type StateMachine added in v1.30.0

type StateMachine[S comparable] interface {
	StateMachineState() S
	SetStateMachineState(S)
}

A StateMachine is anything that can get and set a comparable state S and re-generate tasks based on current state. It is meant to be used with Transition objects to safely transition their state on a given event.

type TaskAttributes

type TaskAttributes struct {
	// ScheduledTime is when the task should fire. Use [TaskScheduledTimeImmediate] (zero value)
	// for tasks that should execute as soon as possible.
	ScheduledTime time.Time
	// Destination is an optional routing key for outbound tasks (e.g., a URL host for HTTP
	// callbacks). When non-empty, the task is categorized as outbound; when empty, it is
	// categorized as a transfer task. Destination must only be set on immediate tasks.
	Destination string
}

TaskAttributes specifies scheduling metadata for a task.

func (*TaskAttributes) IsImmediate added in v1.30.0

func (a *TaskAttributes) IsImmediate() bool

IsImmediate reports whether the task is scheduled for immediate execution (zero or unset scheduled time).

func (*TaskAttributes) IsValid added in v1.30.0

func (a *TaskAttributes) IsValid() bool

IsValid reports whether the task attributes are well-formed. A Destination may only be set on immediate tasks; deferred tasks with a Destination are invalid.

type 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)
}

TaskValidator is implemented by both SideEffectTaskHandler and PureTaskHandler to gate whether a task should proceed with execution.

type TerminableComponent added in v1.31.0

type TerminableComponent interface {
	Component

	// Terminate method is invoked by the chasm framework on an execution's root component when the execution
	// needs to be forcefully terminated.
	// Some examples include:
	// - Execution state becomes too large.
	// - Two running executions with the same businessID when namespace performs a force failover.
	Terminate(MutableContext, TerminateComponentRequest) (TerminateComponentResponse, error)
}

type TerminateComponentRequest added in v1.28.0

type TerminateComponentRequest struct {
	Identity  string
	Reason    string
	Details   *commonpb.Payloads
	RequestID string
}

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 StartExecution() and UpdateWithStartExecution().

func WithRequestID added in v1.29.0

func WithRequestID(
	requestID string,
) TransitionOption

WithRequestID sets the requestID used when creating a new execution. This option only applies to StartExecution() and UpdateWithStartExecution().

func WithSpeculative

func WithSpeculative() TransitionOption

(only) this transition will not be persisted The next non-speculative transition will persist this transition as well. Compared to the ExecutionEphemeral() operation on RegistrableComponent, the scope of this operation is limited to a certain transition, while the ExecutionEphemeral() applies to all transitions. TODO: we need to figure out a way to run the tasks generated in a speculative transition

type TransitionOptions added in v1.29.0

type TransitionOptions struct {
	ReusePolicy    BusinessIDReusePolicy
	ConflictPolicy BusinessIDConflictPolicy
	RequestID      string
	Speculative    bool
}

type UnimplementedComponent

type UnimplementedComponent struct{}

Embed UnimplementedComponent to get forward compatibility

type UnimplementedLibrary

type UnimplementedLibrary struct{}

func (UnimplementedLibrary) Components

func (UnimplementedLibrary) NexusServiceProcessors added in v1.31.0

func (UnimplementedLibrary) NexusServiceProcessors() []*NexusServiceProcessor

func (UnimplementedLibrary) NexusServices added in v1.31.0

func (UnimplementedLibrary) NexusServices() []*nexus.Service

func (UnimplementedLibrary) RegisterServices added in v1.30.0

func (UnimplementedLibrary) RegisterServices(_ *grpc.Server)

RegisterServices Registers the gRPC calls to the handlers of the library.

func (UnimplementedLibrary) Tasks

type UpdateWithStartExecutionResult added in v1.31.0

type UpdateWithStartExecutionResult[O any] struct {
	ExecutionKey ExecutionKey
	ExecutionRef []byte
	Created      bool
	UpdateOutput O
}

UpdateWithStartExecutionResult is the result of a UpdateWithStartExecution operation.

Fields:

  • ExecutionKey: The unique identifier for the execution. This key can be used to look up or reference the execution in future operations.
  • ExecutionRef: A serialized reference to the newly created root component. This can be passed to UpdateComponent, ReadComponent, or PollComponent to interact with the component. Use DeserializeComponentRef to convert this back to a ComponentRef if needed.
  • Created: Indicates whether a new execution was actually created. When false, the execution already existed (based on the BusinessIDReusePolicy and BusinessIDConflictPolicy configured via WithBusinessIDPolicy), and the existing execution was returned instead.
  • UpdateOutput: The output value returned by the update function.

func UpdateWithStartExecution added in v1.31.0

func UpdateWithStartExecution[C RootComponent, I any, O any](
	ctx context.Context,
	key ExecutionKey,
	startFn func(MutableContext, I) (C, error),
	updateFn func(C, MutableContext, I) (O, error),
	input I,
	opts ...TransitionOption,
) (UpdateWithStartExecutionResult[O], error)

type Visibility added in v1.29.0

type Visibility struct {
	UnimplementedComponent

	Data *persistencespb.ChasmVisibilityData

	// Do NOT access those fields directly.
	// Use the provided getters and setters instead.
	SA   Field[*commonpb.SearchAttributes]
	Memo Field[*commonpb.Memo]
}

func NewVisibility added in v1.29.0

func NewVisibility(
	mutableContext MutableContext,
) *Visibility

func NewVisibilityWithData added in v1.30.0

func NewVisibilityWithData(
	mutableContext MutableContext,
	customSearchAttributes map[string]*commonpb.Payload,
	customMemo map[string]*commonpb.Payload,
) *Visibility

func (*Visibility) CustomMemo added in v1.30.0

func (v *Visibility) CustomMemo(
	chasmContext Context,
) map[string]*commonpb.Payload

CustomMemo returns the stored custom memo fields. Nil is returned if there are none.

Returned map is 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. Nil/empty payload values are filtered. If `customSearchAttributes` is empty or all values are nil after filtering, the underlying search attributes node is deleted.

type VisibilityExecutionInfo added in v1.31.0

type VisibilityExecutionInfo[M proto.Message] struct {
	BusinessID             string
	RunID                  string
	StartTime              time.Time
	CloseTime              time.Time
	HistoryLength          int64
	HistorySizeBytes       int64
	StateTransitionCount   int64
	ChasmSearchAttributes  SearchAttributesMap
	CustomSearchAttributes map[string]*commonpb.Payload
	Memo                   *commonpb.Memo
	ChasmMemo              M
}

type VisibilityMemoProvider added in v1.30.0

type VisibilityMemoProvider interface {
	Memo(Context) proto.Message
}

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

Alias returns the alias for a given field.

func (*VisibilitySearchAttributesMapper) Field added in v1.30.0

Field returns the field for a given alias.

func (*VisibilitySearchAttributesMapper) SATypeMap added in v1.30.0

SATypeMap returns the type map for the CHASM search attributes.

func (*VisibilitySearchAttributesMapper) ValueType added in v1.30.0

ValueType returns the type of a CHASM search attribute field. Returns an error if the field is not found in the type map.

type VisibilitySearchAttributesProvider added in v1.30.0

type VisibilitySearchAttributesProvider interface {
	SearchAttributes(Context) []SearchAttributeKeyValue
}

VisibilitySearchAttributesProvider if implemented by the root Component, allows the CHASM framework to automatically determine, at the end of a transaction, if a visibility task needs to be generated to update the visibility record with the returned search attributes.

type VisibilityValue added in v1.30.0

type VisibilityValue interface {
	MustEncode() *commonpb.Payload
	Equal(VisibilityValue) bool
	Value() any
}

type VisibilityValueBool added in v1.30.0

type VisibilityValueBool bool

func (VisibilityValueBool) Equal added in v1.30.0

func (v VisibilityValueBool) Equal(other VisibilityValue) bool

func (VisibilityValueBool) MustEncode added in v1.30.0

func (v VisibilityValueBool) MustEncode() *commonpb.Payload

func (VisibilityValueBool) Value added in v1.30.0

func (v VisibilityValueBool) Value() any

type VisibilityValueFloat64 added in v1.30.0

type VisibilityValueFloat64 float64

func (VisibilityValueFloat64) Equal added in v1.30.0

func (VisibilityValueFloat64) MustEncode added in v1.30.0

func (v VisibilityValueFloat64) MustEncode() *commonpb.Payload

func (VisibilityValueFloat64) Value added in v1.30.0

func (v VisibilityValueFloat64) Value() any

type VisibilityValueInt64 added in v1.30.0

type VisibilityValueInt64 int64

func (VisibilityValueInt64) Equal added in v1.30.0

func (v VisibilityValueInt64) Equal(other VisibilityValue) bool

func (VisibilityValueInt64) MustEncode added in v1.30.0

func (v VisibilityValueInt64) MustEncode() *commonpb.Payload

func (VisibilityValueInt64) Value added in v1.30.0

func (v VisibilityValueInt64) Value() any

type VisibilityValueKeyword added in v1.31.0

type VisibilityValueKeyword string

func (VisibilityValueKeyword) Equal added in v1.31.0

func (VisibilityValueKeyword) MustEncode added in v1.31.0

func (v VisibilityValueKeyword) MustEncode() *commonpb.Payload

func (VisibilityValueKeyword) Value added in v1.31.0

func (v VisibilityValueKeyword) Value() any

type VisibilityValueStringSlice added in v1.30.0

type VisibilityValueStringSlice []string

func (VisibilityValueStringSlice) Equal added in v1.30.0

func (VisibilityValueStringSlice) MustEncode added in v1.30.0

func (VisibilityValueStringSlice) Value added in v1.30.0

func (v VisibilityValueStringSlice) Value() any

type VisibilityValueTime added in v1.30.0

type VisibilityValueTime time.Time

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

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.
nexusoperation/gen/nexusoperationpb/v1
Code generated by protoc-gen-go-helpers.
Code generated by protoc-gen-go-helpers.
scheduler
Package scheduler is a generated GoMock package.
Package scheduler is a generated GoMock package.
scheduler/gen/schedulerpb/v1
Code generated by protoc-gen-go-helpers.
Code generated by protoc-gen-go-helpers.
tests/gen/testspb/v1
Code generated by protoc-gen-go-helpers.
Code generated by protoc-gen-go-helpers.

Jump to

Keyboard shortcuts

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