chasm

package
v1.29.4 Latest Latest
Warning

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

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

Package chasm is a generated GoMock package.

Index

Constants

This section is empty.

Variables

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{}
View Source
var UnimplementedComponentT = reflect.TypeFor[UnimplementedComponent]()

Functions

func GetMemo added in v1.29.0

func GetMemo[T any](
	chasmContext Context,
	visibility *Visibility,
	key string,
) (T, error)

func GetSearchAttribute added in v1.29.0

func GetSearchAttribute[T any](
	chasmContext Context,
	visibility *Visibility,
	key string,
) (T, error)

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 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 UpsertMemo added in v1.29.0

func UpsertMemo[T ~int | ~int32 | ~int64 | ~string | ~bool | ~float64 | ~[]byte](
	chasmContext MutableContext,
	visibility *Visibility,
	name string,
	value T,
)

func UpsertSearchAttribute added in v1.29.0

func UpsertSearchAttribute[T ~int | ~int32 | ~int64 | ~string | ~bool | ~float64 | ~[]byte](
	chasmContext MutableContext,
	visibility *Visibility,
	name string,
	value T,
)

Types

type Archetype added in v1.29.0

type Archetype string
const (
	// ArchetypeAny is a special value that matches any archetype.
	ArchetypeAny Archetype = "__any__"
)

func (Archetype) String added in v1.29.0

func (a Archetype) String() string

type BusinessIDConflictPolicy

type BusinessIDConflictPolicy int
const (
	BusinessIDConflictPolicyFail BusinessIDConflictPolicy = iota
	BusinessIDConflictPolicyTermiateExisting
)

type BusinessIDReusePolicy

type BusinessIDReusePolicy int
const (
	BusinessIDReusePolicyAllowDuplicate BusinessIDReusePolicy = iota
	BusinessIDReusePolicyAllowDuplicateFailedOnly
	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 DeserializeComponentRef

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

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

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) Archetype added in v1.29.0

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

func (*ComponentRef) Serialize

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

func (*ComponentRef) ShardingKey added in v1.28.0

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

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

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(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,
	node *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) ([]byte, error)

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 EntityKey

type EntityKey struct {
	NamespaceID string
	BusinessID  string
	EntityID    string
}

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, EntityKey, []byte, error)

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, EntityKey, []byte, error)

type Field

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

func ComponentPointerTo added in v1.29.0

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

ComponentPointerTo returns a CHASM field populated with a pointer to the given component. Pointers are resolved at the time the transaction is closed, and the transaction will fail if any pointers cannot be resolved.

func DataPointerTo added in v1.29.0

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

DataPointerTo returns a CHASM field populated with a pointer to the given message. Pointers are resolved at the time the transaction is closed, and the transaction will fail if any pointers cannot be resolved.

func NewComponentField

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

func NewDataField

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

re. Data v.s. Component. Components have behavior and has a lifecycle. while Data doesn't and must be attached to a component.

You can define a component just for storing the data, that may contain other information like ref count etc. most importantly, the framework needs to know when it's safe to delete the data. i.e. the lifecycle of that data component reaches completed.

func NewEmptyField added in v1.28.0

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

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 MockContext added in v1.29.0

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

MockContext is a mock of Context interface.

func NewMockContext added in v1.29.0

func NewMockContext(ctrl *gomock.Controller) *MockContext

NewMockContext creates a new mock instance.

func (*MockContext) EXPECT added in v1.29.0

func (m *MockContext) EXPECT() *MockContextMockRecorder

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

func (*MockContext) Now added in v1.29.0

func (m *MockContext) Now(arg0 Component) time.Time

Now mocks base method.

func (*MockContext) Ref added in v1.29.0

func (m *MockContext) Ref(arg0 Component) ([]byte, error)

Ref mocks base method.

type MockContextMockRecorder added in v1.29.0

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

MockContextMockRecorder is the mock recorder for MockContext.

func (*MockContextMockRecorder) Now added in v1.29.0

func (mr *MockContextMockRecorder) Now(arg0 any) *gomock.Call

Now indicates an expected call of Now.

func (*MockContextMockRecorder) Ref added in v1.29.0

func (mr *MockContextMockRecorder) Ref(arg0 any) *gomock.Call

Ref indicates an expected call of Ref.

type MockEngine added in v1.29.0

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

MockEngine is a mock of Engine interface.

func NewMockEngine added in v1.29.0

func NewMockEngine(ctrl *gomock.Controller) *MockEngine

NewMockEngine creates a new mock instance.

func (*MockEngine) EXPECT added in v1.29.0

func (m *MockEngine) EXPECT() *MockEngineMockRecorder

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

func (*MockEngine) NewEntity added in v1.29.0

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

NewEntity mocks base method.

func (*MockEngine) PollComponent added in v1.29.0

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

PollComponent mocks base method.

func (*MockEngine) ReadComponent added in v1.29.0

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

ReadComponent mocks base method.

func (*MockEngine) UpdateComponent added in v1.29.0

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

UpdateComponent mocks base method.

func (*MockEngine) UpdateWithNewEntity added in v1.29.0

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

UpdateWithNewEntity 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) NewEntity added in v1.29.0

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

NewEntity indicates an expected call of NewEntity.

func (*MockEngineMockRecorder) PollComponent added in v1.29.0

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

PollComponent indicates an expected call of PollComponent.

func (*MockEngineMockRecorder) ReadComponent added in v1.29.0

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

ReadComponent indicates an expected call of ReadComponent.

func (*MockEngineMockRecorder) UpdateComponent added in v1.29.0

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

UpdateComponent indicates an expected call of UpdateComponent.

func (*MockEngineMockRecorder) UpdateWithNewEntity added in v1.29.0

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

UpdateWithNewEntity indicates an expected call of UpdateWithNewEntity.

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 MockMutableContext added in v1.29.0

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

MockMutableContext is a mock of MutableContext interface.

func NewMockMutableContext added in v1.29.0

func NewMockMutableContext(ctrl *gomock.Controller) *MockMutableContext

NewMockMutableContext creates a new mock instance.

func (*MockMutableContext) AddTask added in v1.29.0

func (m *MockMutableContext) AddTask(arg0 Component, arg1 TaskAttributes, arg2 any)

AddTask mocks base method.

func (*MockMutableContext) EXPECT added in v1.29.0

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

func (*MockMutableContext) Now added in v1.29.0

func (m *MockMutableContext) Now(arg0 Component) time.Time

Now mocks base method.

func (*MockMutableContext) Ref added in v1.29.0

func (m *MockMutableContext) Ref(arg0 Component) ([]byte, error)

Ref mocks base method.

type MockMutableContextMockRecorder added in v1.29.0

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

MockMutableContextMockRecorder is the mock recorder for MockMutableContext.

func (*MockMutableContextMockRecorder) AddTask added in v1.29.0

func (mr *MockMutableContextMockRecorder) AddTask(arg0, arg1, arg2 any) *gomock.Call

AddTask indicates an expected call of AddTask.

func (*MockMutableContextMockRecorder) Now added in v1.29.0

Now indicates an expected call of Now.

func (*MockMutableContextMockRecorder) Ref added in v1.29.0

Ref indicates an expected call of Ref.

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) CurrentVersionedTransition added in v1.29.0

func (m *MockNodeBackend) CurrentVersionedTransition() *persistence.VersionedTransition

CurrentVersionedTransition 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) GetExecutionState added in v1.29.0

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

GetExecutionState 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) (bool, 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) CurrentVersionedTransition added in v1.29.0

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

CurrentVersionedTransition indicates an expected call of CurrentVersionedTransition.

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) GetExecutionState added in v1.29.0

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

GetExecutionState indicates an expected call of GetExecutionState.

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 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 MockNodePureTask added in v1.29.0

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

MockNodePureTask is a mock of NodePureTask interface.

func NewMockNodePureTask added in v1.29.0

func NewMockNodePureTask(ctrl *gomock.Controller) *MockNodePureTask

NewMockNodePureTask creates a new mock instance.

func (*MockNodePureTask) EXPECT added in v1.29.0

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

func (*MockNodePureTask) ExecutePureTask added in v1.29.0

func (m *MockNodePureTask) ExecutePureTask(baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any) error

ExecutePureTask mocks base method.

func (*MockNodePureTask) ValidatePureTask added in v1.29.0

func (m *MockNodePureTask) ValidatePureTask(baseCtx context.Context, taskAttributes TaskAttributes, taskInstance any) (bool, error)

ValidatePureTask mocks base method.

type MockNodePureTaskMockRecorder added in v1.29.0

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

MockNodePureTaskMockRecorder is the mock recorder for MockNodePureTask.

func (*MockNodePureTaskMockRecorder) ExecutePureTask added in v1.29.0

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

ExecutePureTask indicates an expected call of ExecutePureTask.

func (*MockNodePureTaskMockRecorder) ValidatePureTask added in v1.29.0

func (mr *MockNodePureTaskMockRecorder) ValidatePureTask(baseCtx, taskAttributes, taskInstance any) *gomock.Call

ValidatePureTask indicates an expected call of ValidatePureTask.

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 MutableContext, arg1 C, arg2 TaskAttributes, arg3 T) error

Execute mocks base method.

type MockPureTaskExecutorMockRecorder added in v1.28.0

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

MockPureTaskExecutorMockRecorder is the mock recorder for MockPureTaskExecutor.

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

func (mr *MockPureTaskExecutorMockRecorder[C, T]) Execute(arg0, arg1, arg2, arg3 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 TaskAttributes, arg3 T) error

Execute mocks base method.

type MockSideEffectTaskExecutorMockRecorder added in v1.28.0

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

MockSideEffectTaskExecutorMockRecorder is the mock recorder for MockSideEffectTaskExecutor.

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

func (mr *MockSideEffectTaskExecutorMockRecorder[C, T]) Execute(arg0, arg1, arg2, arg3 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 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 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)
}

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

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

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() Archetype

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,
	encodedPath string,
) (Component, error)

func (*Node) EachPureTask added in v1.28.0

func (n *Node) EachPureTask(
	referenceTime time.Time,
	callback func(executor NodePureTask, taskAttributes TaskAttributes, 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,
	taskAttributes TaskAttributes,
	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) ExecuteSideEffectTask added in v1.29.0

func (n *Node) ExecuteSideEffectTask(
	ctx context.Context,
	registry *Registry,
	entityKey EntityKey,
	taskAttributes TaskAttributes,
	taskInfo *persistencespb.ChasmTaskInfo,
	validate func(NodeBackend, Context, Component) error,
) error

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

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

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) SetRootComponent added in v1.29.0

func (n *Node) SetRootComponent(
	rootComponent Component,
)

func (*Node) Snapshot added in v1.28.0

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

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

func (*Node) Terminate added in v1.28.0

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

func (*Node) ValidatePureTask added in v1.29.0

func (n *Node) ValidatePureTask(
	ctx context.Context,
	taskAttributes TaskAttributes,
	taskInstance any,
) (bool, error)

ValidatePureTask runs a pure task's associated validator, returning true if the task is valid. Intended for use by standby executors as part of EachPureTask's callback. This method assumes the node's value has already been prepared (hydrated).

func (*Node) ValidateSideEffectTask added in v1.29.0

func (n *Node) ValidateSideEffectTask(
	ctx context.Context,
	taskAttributes TaskAttributes,
	taskInfo *persistencespb.ChasmTaskInfo,
) (any, error)

ValidateSideEffectTask runs a side effect task's associated validator, returning the deserialized task instance if the task is valid. Intended for use by standby executors.

If validation succeeds but the task is invalid, nil is returned to signify the task can be skipped/deleted.

If validation fails, that error is returned.

type NodeBackend added in v1.28.0

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

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(MutableContext, C, TaskAttributes, T) error
}

type RegistrableComponent

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

func NewRegistrableComponent

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

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],
	executor PureTaskExecutor[C, T],
	opts ...RegistrableTaskOption,
) *RegistrableTask

func NewRegistrableSideEffectTask added in v1.28.0

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

NOTE: C is not Component but any.

type RegistrableTaskOption

type RegistrableTaskOption func(*RegistrableTask)

type Registry

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

func NewRegistry

func NewRegistry(logger log.Logger) *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, TaskAttributes, 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, TaskAttributes, 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 WithRequestID added in v1.29.0

func WithRequestID(
	requestID string,
) 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 TransitionOptions added in v1.29.0

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

type UnimplementedComponent

type UnimplementedComponent struct{}

Embed UnimplementedComponent to get forward compatibility

func (UnimplementedComponent) Terminate added in v1.28.0

type UnimplementedLibrary

type UnimplementedLibrary struct{}

func (UnimplementedLibrary) Components

func (UnimplementedLibrary) Tasks

type Visibility added in v1.29.0

func NewVisibility added in v1.29.0

func NewVisibility(
	mutableContext MutableContext,
) *Visibility

func (*Visibility) GenerateTask added in v1.29.0

func (v *Visibility) GenerateTask(
	mutableContext MutableContext,
)

func (*Visibility) GetMemo added in v1.29.0

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

func (*Visibility) GetSearchAttributes added in v1.29.0

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

func (*Visibility) LifecycleState added in v1.29.0

func (v *Visibility) LifecycleState(_ Context) LifecycleState

func (*Visibility) RemoveMemo added in v1.29.0

func (v *Visibility) RemoveMemo(
	mutableContext MutableContext,
	keys ...string,
)

func (*Visibility) RemoveSearchAttributes added in v1.29.0

func (v *Visibility) RemoveSearchAttributes(
	mutableContext MutableContext,
	keys ...string,
)

func (*Visibility) UpsertMemo added in v1.29.0

func (v *Visibility) UpsertMemo(
	mutableContext MutableContext,
	updates map[string]any,
) error

func (*Visibility) UpsertSearchAttributes added in v1.29.0

func (v *Visibility) UpsertSearchAttributes(
	mutableContext MutableContext,
	updates map[string]any,
) error

Directories

Path Synopsis
lib
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