chasm

package
v1.28.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 28 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.

Index

Constants

This section is empty.

Variables

View Source
var (
	RootPath []string
)
View Source
var TaskScheduledTimeImmediate = time.Time{}
View Source
var UnimplementedComponentT = reflect.TypeFor[UnimplementedComponent]()

Functions

func NewEntity

func NewEntity[C Component, I any, O any](
	ctx context.Context,
	key EntityKey,
	newFn func(MutableContext, I) (C, O, error),
	input I,
	opts ...TransitionOption,
) (O, []byte, error)

func PollComponent

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

func ReadComponent

func ReadComponent[C Component, 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)

func UpdateComponent

func UpdateComponent[C Component, 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.

func UpdateWithNewEntity

func UpdateWithNewEntity[C Component, I any, O1 any, O2 any](
	ctx context.Context,
	key EntityKey,
	newFn func(MutableContext, I) (C, O1, error),
	updateFn func(C, MutableContext, I) (O2, error),
	input I,
	opts ...TransitionOption,
) (O1, O2, []byte, error)

Types

type BusinessIDConflictPolicy

type BusinessIDConflictPolicy int
const (
	BusinessIDConflictPolicyFail BusinessIDConflictPolicy = iota
	BusinessIDConflictPolicyTermiateExisting
	BusinessIDConflictPolicyUseExisting
)

type BusinessIDReusePolicy

type BusinessIDReusePolicy int
const (
	BusinessIDReusePolicyAllowDuplicate BusinessIDReusePolicy = iota
	BusinessIDReusePolicyRejectDuplicate
)

type Component

type Component interface {
	LifecycleState(Context) LifecycleState

	Terminate(MutableContext, TerminateComponentRequest) (TerminateComponentResponse, error)
	// contains filtered or unexported methods
}

type ComponentFieldOption

type ComponentFieldOption func(*componentFieldOptions)

func ComponentFieldDetached

func ComponentFieldDetached() ComponentFieldOption

type ComponentRef

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

func NewComponentRef

func NewComponentRef[C Component](
	entityKey EntityKey,
) 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) entity.

func (*ComponentRef) ShardID added in v1.28.0

func (r *ComponentRef) ShardID(
	registry *Registry,
	numberOfShards int32,
) (int32, error)

ShardID returns the shardID of the run that contains the referenced component given the total number of shards in the system.

func (*ComponentRef) ShardingKey added in v1.28.0

func (r *ComponentRef) ShardingKey(
	registry *Registry,
) (string, error)

ShardingKey returns the sharding key used for determining the shardID of the run that contains the referenced component.

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) (ComponentRef, bool)
	Now(Component) time.Time
	// contains filtered or unexported methods
}

type ContextImpl added in v1.28.0

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

func NewContext added in v1.28.0

func NewContext(
	ctx context.Context,
	root *Node,
) *ContextImpl

func (*ContextImpl) Now added in v1.28.0

func (c *ContextImpl) Now(component Component) time.Time

func (*ContextImpl) Ref added in v1.28.0

func (c *ContextImpl) Ref(component Component) (ComponentRef, bool)

type EntityKey

type EntityKey struct {
	NamespaceID string
	BusinessID  string
	EntityID    string
}

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 NewComponentField

func NewComponentField[C Component](
	ctx MutableContext,
	c C,
	options ...ComponentFieldOption,
) Field[C]

func NewComponentPointerField

func NewComponentPointerField[C Component](
	ctx MutableContext,
	c C,
) 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 NewDataPointerField

func NewDataPointerField[D proto.Message](
	ctx MutableContext,
	d D,
) Field[D]

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, error)

type Library

type Library interface {
	Name() string
	Components() []*RegistrableComponent
	Tasks() []*RegistrableTask
	// 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

	LifecycleStateUnspecified = LifecycleState(0)
)

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 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.

func (*MockComponent) Terminate added in v1.28.0

Terminate mocks base method.

type MockComponentMockRecorder

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

MockComponentMockRecorder is the mock recorder for MockComponent.

func (*MockComponentMockRecorder) LifecycleState

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

LifecycleState indicates an expected call of LifecycleState.

func (*MockComponentMockRecorder) Terminate added in v1.28.0

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

Terminate indicates an expected call of Terminate.

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) 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) Tasks

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

Tasks indicates an expected call of Tasks.

type MockNodeBackend added in v1.28.0

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

MockNodeBackend is a mock of NodeBackend interface.

func NewMockNodeBackend added in v1.28.0

func NewMockNodeBackend(ctrl *gomock.Controller) *MockNodeBackend

NewMockNodeBackend creates a new mock instance.

func (*MockNodeBackend) AddTasks added in v1.28.0

func (m *MockNodeBackend) AddTasks(arg0 ...tasks.Task)

AddTasks mocks base method.

func (*MockNodeBackend) EXPECT added in v1.28.0

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

func (*MockNodeBackend) GetCurrentVersion added in v1.28.0

func (m *MockNodeBackend) GetCurrentVersion() int64

GetCurrentVersion mocks base method.

func (*MockNodeBackend) GetExecutionInfo added in v1.28.0

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

GetExecutionInfo mocks base method.

func (*MockNodeBackend) GetWorkflowKey added in v1.28.0

func (m *MockNodeBackend) GetWorkflowKey() definition.WorkflowKey

GetWorkflowKey mocks base method.

func (*MockNodeBackend) NextTransitionCount added in v1.28.0

func (m *MockNodeBackend) NextTransitionCount() int64

NextTransitionCount mocks base method.

func (*MockNodeBackend) UpdateWorkflowStateStatus added in v1.28.0

func (m *MockNodeBackend) UpdateWorkflowStateStatus(state enums0.WorkflowExecutionState, status enums.WorkflowExecutionStatus) error

UpdateWorkflowStateStatus mocks base method.

type MockNodeBackendMockRecorder added in v1.28.0

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

MockNodeBackendMockRecorder is the mock recorder for MockNodeBackend.

func (*MockNodeBackendMockRecorder) AddTasks added in v1.28.0

func (mr *MockNodeBackendMockRecorder) AddTasks(arg0 ...any) *gomock.Call

AddTasks indicates an expected call of AddTasks.

func (*MockNodeBackendMockRecorder) GetCurrentVersion added in v1.28.0

func (mr *MockNodeBackendMockRecorder) GetCurrentVersion() *gomock.Call

GetCurrentVersion indicates an expected call of GetCurrentVersion.

func (*MockNodeBackendMockRecorder) GetExecutionInfo added in v1.28.0

func (mr *MockNodeBackendMockRecorder) GetExecutionInfo() *gomock.Call

GetExecutionInfo indicates an expected call of GetExecutionInfo.

func (*MockNodeBackendMockRecorder) GetWorkflowKey added in v1.28.0

func (mr *MockNodeBackendMockRecorder) GetWorkflowKey() *gomock.Call

GetWorkflowKey indicates an expected call of GetWorkflowKey.

func (*MockNodeBackendMockRecorder) NextTransitionCount added in v1.28.0

func (mr *MockNodeBackendMockRecorder) NextTransitionCount() *gomock.Call

NextTransitionCount indicates an expected call of NextTransitionCount.

func (*MockNodeBackendMockRecorder) UpdateWorkflowStateStatus added in v1.28.0

func (mr *MockNodeBackendMockRecorder) UpdateWorkflowStateStatus(state, status any) *gomock.Call

UpdateWorkflowStateStatus indicates an expected call of UpdateWorkflowStateStatus.

type MockNodeExecutePureTask added in v1.28.0

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

MockNodeExecutePureTask is a mock of NodeExecutePureTask interface.

func NewMockNodeExecutePureTask added in v1.28.0

func NewMockNodeExecutePureTask(ctrl *gomock.Controller) *MockNodeExecutePureTask

NewMockNodeExecutePureTask creates a new mock instance.

func (*MockNodeExecutePureTask) EXPECT added in v1.28.0

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

func (*MockNodeExecutePureTask) ExecutePureTask added in v1.28.0

func (m *MockNodeExecutePureTask) ExecutePureTask(baseCtx context.Context, taskInstance any) error

ExecutePureTask mocks base method.

type MockNodeExecutePureTaskMockRecorder added in v1.28.0

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

MockNodeExecutePureTaskMockRecorder is the mock recorder for MockNodeExecutePureTask.

func (*MockNodeExecutePureTaskMockRecorder) ExecutePureTask added in v1.28.0

func (mr *MockNodeExecutePureTaskMockRecorder) ExecutePureTask(baseCtx, taskInstance any) *gomock.Call

ExecutePureTask indicates an expected call of ExecutePureTask.

type MockNodePathEncoder added in v1.28.0

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

MockNodePathEncoder is a mock of NodePathEncoder interface.

func NewMockNodePathEncoder added in v1.28.0

func NewMockNodePathEncoder(ctrl *gomock.Controller) *MockNodePathEncoder

NewMockNodePathEncoder creates a new mock instance.

func (*MockNodePathEncoder) Decode added in v1.28.0

func (m *MockNodePathEncoder) Decode(encodedPath string) ([]string, error)

Decode mocks base method.

func (*MockNodePathEncoder) EXPECT added in v1.28.0

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

func (*MockNodePathEncoder) Encode added in v1.28.0

func (m *MockNodePathEncoder) Encode(node *Node, path []string) (string, error)

Encode mocks base method.

type MockNodePathEncoderMockRecorder added in v1.28.0

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

MockNodePathEncoderMockRecorder is the mock recorder for MockNodePathEncoder.

func (*MockNodePathEncoderMockRecorder) Decode added in v1.28.0

func (mr *MockNodePathEncoderMockRecorder) Decode(encodedPath any) *gomock.Call

Decode indicates an expected call of Decode.

func (*MockNodePathEncoderMockRecorder) Encode added in v1.28.0

func (mr *MockNodePathEncoderMockRecorder) Encode(node, path any) *gomock.Call

Encode indicates an expected call of Encode.

type MockPureTaskExecutor added in v1.28.0

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

MockPureTaskExecutor is a mock of PureTaskExecutor interface.

func NewMockPureTaskExecutor added in v1.28.0

func NewMockPureTaskExecutor[C any, T any](ctrl *gomock.Controller) *MockPureTaskExecutor[C, T]

NewMockPureTaskExecutor creates a new mock instance.

func (*MockPureTaskExecutor[C, T]) EXPECT added in v1.28.0

func (m *MockPureTaskExecutor[C, T]) EXPECT() *MockPureTaskExecutorMockRecorder[C, T]

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

func (*MockPureTaskExecutor[C, T]) Execute added in v1.28.0

func (m *MockPureTaskExecutor[C, T]) Execute(arg0 Context, arg1 C, arg2 T) error

Execute mocks base method.

type MockPureTaskExecutorMockRecorder added in v1.28.0

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

MockPureTaskExecutorMockRecorder is the mock recorder for MockPureTaskExecutor.

func (*MockPureTaskExecutorMockRecorder[C, T]) Execute added in v1.28.0

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

Execute indicates an expected call of Execute.

type MockSideEffectTaskExecutor added in v1.28.0

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

MockSideEffectTaskExecutor is a mock of SideEffectTaskExecutor interface.

func NewMockSideEffectTaskExecutor added in v1.28.0

func NewMockSideEffectTaskExecutor[C any, T any](ctrl *gomock.Controller) *MockSideEffectTaskExecutor[C, T]

NewMockSideEffectTaskExecutor creates a new mock instance.

func (*MockSideEffectTaskExecutor[C, T]) EXPECT added in v1.28.0

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

func (*MockSideEffectTaskExecutor[C, T]) Execute added in v1.28.0

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

Execute mocks base method.

type MockSideEffectTaskExecutorMockRecorder added in v1.28.0

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

MockSideEffectTaskExecutorMockRecorder is the mock recorder for MockSideEffectTaskExecutor.

func (*MockSideEffectTaskExecutorMockRecorder[C, T]) Execute added in v1.28.0

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

Execute indicates an expected call of Execute.

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 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 any) *gomock.Call

Validate indicates an expected call of Validate.

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(Component, TaskAttributes, any) error
}

type MutableContextImpl added in v1.28.0

type MutableContextImpl struct {
	*ContextImpl
}

func NewMutableContext added in v1.28.0

func NewMutableContext(
	ctx context.Context,
	root *Node,
) *MutableContextImpl

func (*MutableContextImpl) AddTask added in v1.28.0

func (c *MutableContextImpl) AddTask(
	component Component,
	attributes TaskAttributes,
	payload any,
) error

type Node added in v1.28.0

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

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

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

func NewEmptyTree added in v1.28.0

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

NewEmptyTree creates a new empty in-memory CHASM tree.

func NewTree added in v1.28.0

func NewTree(
	serializedNodes map[string]*persistencespb.ChasmNode,

	registry *Registry,
	timeSource clock.TimeSource,
	backend NodeBackend,
	pathEncoder NodePathEncoder,
	logger log.Logger,
) (*Node, error)

NewTree creates a new in-memory CHASM tree from a collection of flattened persistence CHASM nodes.

func (*Node) AddTask added in v1.28.0

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

AddTask implements the CHASM MutableContext interface

func (*Node) ApplyMutation added in v1.28.0

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

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

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

func (*Node) ApplySnapshot added in v1.28.0

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

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

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

func (*Node) Archetype added in v1.28.0

func (n *Node) Archetype() string

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

func (n *Node) EachPureTask(
	referenceTime time.Time,
	callback func(executor NodeExecutePureTask, task any) 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, taskInstance any) 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) IsDirty added in v1.28.0

func (n *Node) IsDirty() bool

IsDirty returns true if any node rooted at Node n has been modified, and different from the state 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) 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,
) (ComponentRef, bool)

Ref implements the CHASM Context interface

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

type NodeBackend added in v1.28.0

type NodeBackend interface {
	// TODO: Add methods needed from MutateState here.
	GetExecutionInfo() *persistencespb.WorkflowExecutionInfo
	GetCurrentVersion() int64
	NextTransitionCount() int64
	GetWorkflowKey() definition.WorkflowKey
	AddTasks(...tasks.Task)
	UpdateWorkflowStateStatus(
		state enumsspb.WorkflowExecutionState,
		status enumspb.WorkflowExecutionStatus,
	) 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 NodeExecutePureTask added in v1.28.0

type NodeExecutePureTask interface {
	ExecutePureTask(baseCtx context.Context, taskInstance any) error
}

NodeExecutePureTask is intended to be implemented and used within the CHASM framework only.

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 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.

TODO: Return tree size changes in NodesMutation as well. MutateState needs to track the overall size of itself and terminate workflow if it exceeds the limit.

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 PollComponentRequest

type PollComponentRequest[C Component, I any, O any] struct {
	Ref         ComponentRef
	PredicateFn func(C, Context, I) bool
	OperationFn func(C, MutableContext, I) (O, error)
	Input       I
}

type PureTaskExecutor added in v1.28.0

type PureTaskExecutor[C any, T any] interface {
	Execute(Context, C, T) error
}

type RegistrableComponent

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

func NewRegistrableComponent

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

type RegistrableComponentOption

type RegistrableComponentOption func(*RegistrableComponent)

func WithEphemeral

func WithEphemeral() RegistrableComponentOption

func WithShardingFn

func WithShardingFn(
	shardingFn func(EntityKey) string,
) 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,
	validator TaskValidator[C, T],
	handler PureTaskExecutor[C, T],
	opts ...RegistrableTaskOption,
) *RegistrableTask

func NewRegistrableSideEffectTask added in v1.28.0

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

NOTE: C is not Component but any.

type RegistrableTaskOption

type RegistrableTaskOption func(*RegistrableTask)

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Register

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

type SideEffectTaskExecutor added in v1.28.0

type SideEffectTaskExecutor[C any, T any] interface {
	Execute(context.Context, ComponentRef, T) error
}

type TaskAttributes

type TaskAttributes struct {
	ScheduledTime time.Time
	Destination   string
}

type TaskValidator added in v1.28.0

type TaskValidator[C any, T any] interface {
	Validate(Context, C, T) (bool, error)
}

type TerminateComponentRequest added in v1.28.0

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

type TerminateComponentResponse added in v1.28.0

type TerminateComponentResponse struct{}

type TransitionOption

type TransitionOption func(*transitionOptions)

func WithBusinessIDPolicy

func WithBusinessIDPolicy(
	reusePolicy BusinessIDReusePolicy,
	conflictPolicy BusinessIDConflictPolicy,
) TransitionOption

this only applies to NewEntity and UpdateWithNewEntity

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 EntityEphemeral() operation on RegistrableComponent, the scope of this operation is limited to a certain transition, while the EntityEphemeral() applies to all transitions. TODO: we need to figure out a way to run the tasks generated in a speculative transition

type UnimplementedComponent

type UnimplementedComponent struct{}

Embed UnimplementedComponent to get forward compatibility

func (UnimplementedComponent) LifecycleState

func (UnimplementedComponent) Terminate added in v1.28.0

type UnimplementedLibrary

type UnimplementedLibrary struct{}

func (UnimplementedLibrary) Components

func (UnimplementedLibrary) Tasks

Jump to

Keyboard shortcuts

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