Documentation
¶
Overview ¶
Package chasm is a generated GoMock package.
Package chasm is a generated GoMock package.
Package chasm is a generated GoMock package.
Index ¶
- func NewEntity[C Component, I any, O any](ctx context.Context, key EntityKey, ...) (O, []byte, error)
- 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), ...) (O, []byte, error)
- 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, ...) (O, error)
- func UpdateComponent[C Component, R []byte | ComponentRef, I any, O any](ctx context.Context, r R, updateFn func(C, MutableContext, I) (O, error), ...) (O, []byte, error)
- func UpdateWithNewEntity[C Component, I any, O1 any, O2 any](ctx context.Context, key EntityKey, ...) (O1, O2, []byte, error)
- type BusinessIDConflictPolicy
- type BusinessIDReusePolicy
- type Collection
- type Component
- type ComponentFieldOption
- type ComponentRef
- type Context
- type EntityKey
- type Field
- func NewComponentField[C Component](ctx MutableContext, c C, options ...ComponentFieldOption) *Field[C]
- func NewComponentPointerField[C Component](ctx MutableContext, c C) *Field[C]
- func NewDataField[D proto.Message](ctx MutableContext, d D) *Field[D]
- func NewDataPointerField[D proto.Message](ctx MutableContext, d D) *Field[D]
- type Library
- type LifecycleState
- type MockComponent
- type MockComponentMockRecorder
- type MockLibrary
- type MockLibraryMockRecorder
- type MockTaskHandler
- type MockTaskHandlerMockRecorder
- type MutableContext
- type OperationIntent
- type PollComponentRequest
- type RegistrableComponent
- type RegistrableComponentOption
- type RegistrableTask
- type RegistrableTaskOption
- type Registry
- type TaskAttributes
- type TaskHandler
- type TransitionOption
- type UnimplementedComponent
- type UnimplementedLibrary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PollComponent ¶
func ReadComponent ¶
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 Collection ¶
type Component ¶
type Component interface { LifecycleState() LifecycleState // 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)
func NewComponentRef ¶
func NewComponentRef( entityKey EntityKey, rootComponentType string, ) ComponentRef
In V1, if you don't have a ref, then you can only interact with the top level entity.
func (*ComponentRef) Serialize ¶
func (r *ComponentRef) Serialize() []byte
type Field ¶
type Field[T any] struct { Internal fieldInternal }
This struct needs to be create via reflection but reflection can't set prviate fields...
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]
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 ( LifecycleStateCreated LifecycleState = 1 << iota LifecycleStateRunning // LifecycleStatePaused // <- this can also be a method of the engine: PauseComponent LifecycleStateCompleted LifecycleStateFailed LifecycleStateUnspecified = LifecycleState(0) )
type MockComponent ¶
type MockComponent struct {
// contains filtered or unexported fields
}
MockComponent is a mock of Component interface.
func NewMockComponent ¶
func NewMockComponent(ctrl *gomock.Controller) *MockComponent
NewMockComponent creates a new mock instance.
func (*MockComponent) EXPECT ¶
func (m *MockComponent) EXPECT() *MockComponentMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockComponent) LifecycleState ¶
func (m *MockComponent) LifecycleState() 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() *gomock.Call
LifecycleState indicates an expected call of LifecycleState.
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) 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 MockTaskHandler ¶
MockTaskHandler is a mock of TaskHandler interface.
func NewMockTaskHandler ¶
func NewMockTaskHandler[C any, T any](ctrl *gomock.Controller) *MockTaskHandler[C, T]
NewMockTaskHandler creates a new mock instance.
func (*MockTaskHandler[C, T]) EXPECT ¶
func (m *MockTaskHandler[C, T]) EXPECT() *MockTaskHandlerMockRecorder[C, T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTaskHandler[C, T]) Execute ¶
func (m *MockTaskHandler[C, T]) Execute(arg0 context.Context, arg1 ComponentRef, arg2 T) error
Execute mocks base method.
func (*MockTaskHandler[C, T]) Validate ¶
func (m *MockTaskHandler[C, T]) Validate(arg0 Context, arg1 C, arg2 T) error
Validate mocks base method.
type MockTaskHandlerMockRecorder ¶
MockTaskHandlerMockRecorder is the mock recorder for MockTaskHandler.
type MutableContext ¶
type MutableContext interface { Context AddTask(Component, TaskAttributes, any) error }
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 RegistrableComponent ¶
type RegistrableComponent struct {
// contains filtered or unexported fields
}
func NewRegistrableComponent ¶
func NewRegistrableComponent[C Component]( componentType string, opts ...RegistrableComponentOption, ) *RegistrableComponent
func (RegistrableComponent) Type ¶
func (rc RegistrableComponent) Type() string
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 NewRegistrableTask ¶
func NewRegistrableTask[C any, T any]( taskType string, handler TaskHandler[C, T], opts ...RegistrableTaskOption, ) *RegistrableTask
NOTE: C is not Component but any.
func (RegistrableTask) Type ¶
func (rt RegistrableTask) Type() string
type RegistrableTaskOption ¶
type RegistrableTaskOption func(*RegistrableTask)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
type TaskAttributes ¶
type TaskHandler ¶
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) LifecycleState() LifecycleState
type UnimplementedLibrary ¶
type UnimplementedLibrary struct{}
func (UnimplementedLibrary) Components ¶
func (UnimplementedLibrary) Components() []*RegistrableComponent
func (UnimplementedLibrary) Tasks ¶
func (UnimplementedLibrary) Tasks() []*RegistrableTask