actor

package
v0.0.0-...-2a7ec10 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Type defines the type of the actor server to be invoke
	Type() string
	// ID should be unique, the actor server with target ID would be created before server processing the invocation.
	ID() string
}

Client is the interface that should be impl by user's actor client.

type Factory

type Factory func() Server

type FactoryContext

type FactoryContext func() ServerContext

type ReminderCallee

type ReminderCallee interface {
	ReminderCall(string, []byte, string, string)
}

type Server deprecated

type Server interface {
	// ID is impl by ServerImplBase. It can be called by user defined actor function to get the actor ID of it's instance.
	ID() string
	// SetID is impl by ServerImplBase. It is called by actor container to inject actor ID of the instance, and should
	// not called by user
	SetID(string)
	// Type is defined by user
	Type() string
	// SetStateManager is impl by ServerImplBase to inject StateManager to this actor instance
	// Deprecated: SetStateManager is deprecated in favour of SetStateManagerContext.
	SetStateManager(StateManager)
	// SaveState is impl by ServerImplBase, It saves the state cache of this actor instance to state store component by calling api of daprd.
	// Save state is called at two places: 1. On invocation of this actor instance. 2. When new actor starts.
	SaveState() error

	WithContext() ServerContext
}

Deprecated: Server is deprecated in favour of ServerContext.

type ServerContext

type ServerContext interface {
	// ID is impl by ServerImplBase. It can be called by user defined actor function to get the actor ID of it's instance.
	ID() string
	// SetID is impl by ServerImplBase. It is called by actor container to inject actor ID of the instance, and should
	// not called by user
	SetID(string)
	// Type is defined by user
	Type() string
	// SetStateManager is impl by ServerImplBase to inject StateManager to this actor instance
	SetStateManager(StateManagerContext)
	// SaveState is impl by ServerImplBase, It saves the state cache of this actor instance to state store component by calling api of daprd.
	// Save state is called at two places: 1. On invocation of this actor instance. 2. When new actor starts.
	SaveState(context.Context) error
}

ServerContext is the interface that would be impl by user's actor server with ServerImplBaseCtx

Actor user should only impls func Type() string, and his user-defined-method, Other function could be impl by combining ServerImplBaseCtx.

type ServerImplBase deprecated

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

Deprecated: ServerImplBase is deprecated in favour of ServerImplBaseCtx.

func (*ServerImplBase) GetStateManager

func (b *ServerImplBase) GetStateManager() StateManager

GetStateManager can be called by user-defined-method, to get state manager of this actor instance. Deprecated: Use ServerImplBaseCtx instead.

func (*ServerImplBase) ID deprecated

func (b *ServerImplBase) ID() string

Deprecated: Use ServerImplBaseCtx instead.

func (*ServerImplBase) SaveState

func (b *ServerImplBase) SaveState() error

SaveState is to saves the state cache of this actor instance to state store component by calling api of daprd. Deprecated: Use ServerImplBaseCtx instead.

func (*ServerImplBase) SetID deprecated

func (b *ServerImplBase) SetID(id string)

Deprecated: Use ServerImplBaseCtx instead.

func (*ServerImplBase) SetStateManager deprecated

func (b *ServerImplBase) SetStateManager(stateManager StateManager)

Deprecated: Use ServerImplBaseCtx instead.

func (*ServerImplBase) WithContext deprecated

func (b *ServerImplBase) WithContext() *ServerImplBaseCtx

Deprecated: Use ServerImplBaseCtx instead.

type ServerImplBaseCtx

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

func (*ServerImplBaseCtx) GetStateManager

func (b *ServerImplBaseCtx) GetStateManager() StateManagerContext

GetStateManager can be called by user-defined-method, to get state manager of this actor instance.

func (*ServerImplBaseCtx) ID

func (b *ServerImplBaseCtx) ID() string

func (*ServerImplBaseCtx) SaveState

func (b *ServerImplBaseCtx) SaveState(ctx context.Context) error

SaveState is to saves the state cache of this actor instance to state store component by calling api of daprd.

func (*ServerImplBaseCtx) SetID

func (b *ServerImplBaseCtx) SetID(id string)

func (*ServerImplBaseCtx) SetStateManager

func (b *ServerImplBaseCtx) SetStateManager(stateManager StateManagerContext)

type StateManager deprecated

type StateManager interface {
	// Add is to add new state store with @stateName and @value
	Add(stateName string, value any) error
	// Get is to get state store of @stateName with type @reply
	Get(stateName string, reply any) error
	// Set is to set new state store with @stateName and @value
	Set(stateName string, value any) error
	// Remove is to remove state store with @stateName
	Remove(stateName string) error
	// Force Remove is to remove state store with @stateName
	ForceRemove(stateName string) error
	// Contains is to check if state store contains @stateName
	Contains(stateName string) (bool, error)
	// Save is to saves the state cache of this actor instance to state store component by calling api of daprd.
	Save() error
	// Flush is called by StateManager after Save
	Flush()

	// Returns a new StateManagerContext with the same state as this StateManager
	// but uses context.
	WithContext() StateManagerContext
}

Deprecated: StateManager is deprecated in favour of StateManagerContext.

type StateManagerContext

type StateManagerContext interface {
	// Add is to add new state store with @stateName and @value
	Add(ctx context.Context, stateName string, value any) error
	// Get is to get state store of @stateName with type @reply
	Get(ctx context.Context, stateName string, reply any) error
	// Set sets a state store with @stateName and @value.
	Set(ctx context.Context, stateName string, value any) error
	// SetWithTTL sets a state store with @stateName and @value, for the given
	// TTL. After the TTL has passed, the value will no longer be available with
	// `Get`. Always preferred over `Set`.
	// NOTE: SetWithTTL is in feature preview as of v1.11, and only available
	// with the `ActorStateTTL` feature enabled in Dapr.
	SetWithTTL(ctx context.Context, stateName string, value any, ttl time.Duration) error
	// Remove is to remove state store with @stateName
	Remove(ctx context.Context, stateName string) error
	// Force Remove is to remove state store with @stateName
	ForceRemove(ctx context.Context, stateName string) error
	// Contains is to check if state store contains @stateName
	Contains(ctx context.Context, stateName string) (bool, error)
	// Save is to saves the state cache of this actor instance to state store component by calling api of daprd.
	Save(ctx context.Context) error
	// Flush is called by StateManager after Save
	Flush(ctx context.Context)
}

Directories

Path Synopsis
Package actor is a generated GoMock package.
Package actor is a generated GoMock package.

Jump to

Keyboard shortcuts

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