Documentation
¶
Index ¶
- Constants
- type Actor
- type ActorFactory
- type ActorHandler
- func (h *ActorHandler) GetActor() Actor
- func (h *ActorHandler) GetAddress() string
- func (h *ActorHandler) GetID() uuid.UUID
- func (h *ActorHandler) GetKind() string
- func (h *ActorHandler) Persist(ctx context.Context) error
- func (h *ActorHandler) Persist_(ctx context.Context, db Persister) error
- func (h *ActorHandler) Restore(ctx context.Context) error
- func (h *ActorHandler) SendMessage(ctx context.Context, msg *Message)
- func (h *ActorHandler) Start(ctx context.Context)
- func (h *ActorHandler) Stop()
- func (h *ActorHandler) WaitForTermination()
- type Bus
- func (b *Bus) GetSubscriptionGroups() map[uuid.UUID]*SubscriptionGroup
- func (b *Bus) Inbox() chan any
- func (b *Bus) Publish(ctx context.Context, sender uuid.UUID, recipient Recipient, payload any) error
- func (b *Bus) Request(ctx context.Context, sender uuid.UUID, recipient Recipient, payload any) (any, error)
- func (b *Bus) Route(ctx context.Context, msg *Message) error
- func (b *Bus) SetRouteFunction(routeFn func(actorID uuid.UUID, msg *Message) error)
- func (b *Bus) Start()
- func (b *Bus) Stop()
- func (b *Bus) Subscribe(pattern string, actorID uuid.UUID) (uuid.UUID, error)
- func (b *Bus) Unsubscribe(subscriptionID uuid.UUID, actorID uuid.UUID) error
- func (b *Bus) UpdateSubscriptionGroup(group *SubscriptionGroup)
- type Factory
- type HandleError
- type HandlerOpt
- type Hook
- type HookCollection
- type HookOpt
- type Message
- type MessageConsumer
- type MessageQueue
- type Persister
- type Publisher
- type Recipient
- type RecipientKind
- type Registry
- type Replayer
- type Restorer
- type SenderFunc
- type Subscription
- type SubscriptionGroup
- type System
- func (s *System) AttemptRestoreActor(ctx context.Context, kind string, params model.IDParam, opts ...HandlerOpt) (*ActorHandler, error)
- func (s *System) GetName() string
- func (s *System) GetSystemID() uuid.UUID
- func (s *System) IsActorSpawned(ctx context.Context, actorID uuid.UUID) model.ActorState
- func (s *System) Publish(ctx context.Context, sender uuid.UUID, recipient Recipient, payload any) error
- func (s *System) Request(ctx context.Context, sender uuid.UUID, recipient Recipient, payload any) (any, error)
- func (s *System) Route(ctx context.Context, msg *Message) error
- func (s *System) Send(ctx context.Context, msg *Message)
- func (s *System) Shutdown(ctx context.Context) error
- func (s *System) Spawn(ctx context.Context, kind string, opts ...HandlerOpt) (*ActorHandler, error)
- func (s *System) SpawnWithParams(ctx context.Context, kind string, params any, opts ...HandlerOpt) (*ActorHandler, error)
- func (s *System) Subscribe(pattern string, actorID uuid.UUID) (uuid.UUID, error)
- func (s *System) Unsubscribe(subscriptionID uuid.UUID, actorID uuid.UUID) error
Constants ¶
View Source
const ( HookPreStart = "preStart" HookPostStart = "postStart" HookPoisoned = "poisoned" HookTerminated = "terminated" HookCrash = "crash" )
View Source
const (
PersistIntervalSeconds = 10
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor interface {
GetID() uuid.UUID
GetKind() string
Start(context.Context)
Stop(context.Context) error
HandleMessage(context.Context, *Message) HandleError
Snapshot(context.Context) (database.Snapshot, error)
RestoreFromSnapshot(context.Context, database.Snapshot) error
Persist(context.Context, database.Store) error
Restore(context.Context, database.Store) error
}
type ActorFactory ¶
type ActorHandler ¶
type ActorHandler struct {
// contains filtered or unexported fields
}
func NewActorHandler ¶
func NewActorHandler(sys *System, actor Actor, opts ...HandlerOpt) *ActorHandler
func (*ActorHandler) GetActor ¶
func (h *ActorHandler) GetActor() Actor
func (*ActorHandler) GetAddress ¶
func (h *ActorHandler) GetAddress() string
func (*ActorHandler) GetID ¶
func (h *ActorHandler) GetID() uuid.UUID
func (*ActorHandler) GetKind ¶
func (h *ActorHandler) GetKind() string
func (*ActorHandler) Persist_ ¶
func (h *ActorHandler) Persist_(ctx context.Context, db Persister) error
func (*ActorHandler) SendMessage ¶
func (h *ActorHandler) SendMessage(ctx context.Context, msg *Message)
func (*ActorHandler) Start ¶
func (h *ActorHandler) Start(ctx context.Context)
func (*ActorHandler) Stop ¶
func (h *ActorHandler) Stop()
func (*ActorHandler) WaitForTermination ¶
func (h *ActorHandler) WaitForTermination()
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
func (*Bus) GetSubscriptionGroups ¶
func (b *Bus) GetSubscriptionGroups() map[uuid.UUID]*SubscriptionGroup
func (*Bus) SetRouteFunction ¶
func (*Bus) Unsubscribe ¶
func (*Bus) UpdateSubscriptionGroup ¶
func (b *Bus) UpdateSubscriptionGroup(group *SubscriptionGroup)
type Factory ¶
type Factory struct {
Fn ActorFactory
Hooks []HookOpt
}
type HandleError ¶
type HandlerOpt ¶
type HandlerOpt func(*ActorHandler, *System)
func WithSubscription ¶
func WithSubscription(pattern string) HandlerOpt
type HookCollection ¶
type HookCollection struct {
// contains filtered or unexported fields
}
func NewHookCollection ¶
func NewHookCollection(name string, hooks ...Hook) *HookCollection
func (*HookCollection) Add ¶
func (hc *HookCollection) Add(hook Hook)
type HookOpt ¶
type HookOpt func(h *ActorHandler, sys *System)
func WithCrashHook ¶
func WithPoisonedHook ¶
func WithPostStartHook ¶
func WithPreStartHook ¶
func WithTerminatedHook ¶
type Message ¶
type Message struct {
ID uuid.UUID
Sender uuid.UUID
Payload any
Recipient Recipient
ResponseTo uuid.UUID
ResponseChannel chan *Message
}
Message represents a message that can be sent between actors.
func (*Message) GetRecipient ¶
func (*Message) GetResponseTo ¶
type MessageConsumer ¶
type MessageQueue ¶
type MessageQueue struct {
// contains filtered or unexported fields
}
func NewMessageQueue ¶
func NewMessageQueue() *MessageQueue
func (*MessageQueue) IsEmpty ¶
func (q *MessageQueue) IsEmpty() bool
func (*MessageQueue) Len ¶
func (q *MessageQueue) Len() int
func (*MessageQueue) Pop ¶
func (q *MessageQueue) Pop() any
func (*MessageQueue) Push ¶
func (q *MessageQueue) Push(msg any)
type Recipient ¶
type Recipient struct {
Kind RecipientKind
Subject string
}
type RecipientKind ¶
type RecipientKind string
const ( RecipientKindTopic RecipientKind = "topic" RecipientKindActor RecipientKind = "actor" )
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) DeregisterFactory ¶
func (*Registry) RegisterFactory ¶
func (r *Registry) RegisterFactory(kind string, factory ActorFactory, opts ...HookOpt)
type SenderFunc ¶
type Subscription ¶
func NewSubscription ¶
func NewSubscription(pattern string, actorID uuid.UUID) (*Subscription, error)
func (*Subscription) GetPattern ¶
func (s *Subscription) GetPattern() *regexp.Regexp
type SubscriptionGroup ¶
type SubscriptionGroup struct {
// contains filtered or unexported fields
}
func NewSubscriptionGroup ¶
func NewSubscriptionGroup(pattern string) (*SubscriptionGroup, error)
func (*SubscriptionGroup) AddActor ¶
func (g *SubscriptionGroup) AddActor(actorID uuid.UUID)
func (*SubscriptionGroup) GetActors ¶
func (g *SubscriptionGroup) GetActors() map[uuid.UUID]struct{}
func (*SubscriptionGroup) GetID ¶
func (g *SubscriptionGroup) GetID() uuid.UUID
func (*SubscriptionGroup) GetPattern ¶
func (g *SubscriptionGroup) GetPattern() *regexp.Regexp
type System ¶
type System struct {
// contains filtered or unexported fields
}
func MustNewSystem ¶
func (*System) AttemptRestoreActor ¶
func (s *System) AttemptRestoreActor(ctx context.Context, kind string, params model.IDParam, opts ...HandlerOpt) (*ActorHandler, error)
func (*System) GetSystemID ¶
func (*System) IsActorSpawned ¶
func (*System) Spawn ¶
func (s *System) Spawn(ctx context.Context, kind string, opts ...HandlerOpt) (*ActorHandler, error)
TODO Unexpose this method once we have better communication options.
func (*System) SpawnWithParams ¶
func (s *System) SpawnWithParams(ctx context.Context, kind string, params any, opts ...HandlerOpt) (*ActorHandler, error)
Click to show internal directories.
Click to hide internal directories.