Documentation ¶
Overview ¶
Package actor is a generated protocol buffer package.
It is generated from these files:
protos.proto
It has these top-level messages:
PID PoisonPill Watch Unwatch Terminated Stop
Index ¶
- Variables
- func SetLogLevel(level log.Level)
- func SetOptions(opts ...optionFn)
- func UnwrapEnvelope(message interface{}) (ReadonlyMessageHeader, interface{}, *PID)
- func UnwrapEnvelopeMessage(message interface{}) interface{}
- func WithDeadLetterSubscriber(fn func(evt interface{})) optionFn
- func WithSupervisorSubscriber(fn func(evt interface{})) optionFn
- type Actor
- type ActorFunc
- type ActorProcess
- type AddressResolver
- type AutoReceiveMessage
- type Behavior
- type Context
- type ContextDecorator
- type ContextDecoratorFunc
- type DeadLetterEvent
- type DeciderFunc
- type Directive
- type Failure
- type Future
- type InboundMiddlewaredeprecated
- type MessageEnvelope
- type NotInfluenceReceiveTimeout
- type OutboundMiddlewaredeprecated
- type PID
- func (*PID) Descriptor() ([]byte, []int)
- func (this *PID) Equal(that interface{}) bool
- func (m *PID) GetAddress() string
- func (m *PID) GetId() string
- func (pid *PID) GracefulPoison()deprecated
- func (pid *PID) GracefulStop()deprecated
- func (m *PID) Marshal() (dAtA []byte, err error)
- func (m *PID) MarshalTo(dAtA []byte) (int, error)
- func (pid *PID) Poison()deprecated
- func (pid *PID) PoisonFuture() *Futuredeprecated
- func (*PID) ProtoMessage()
- func (pid *PID) Request(message interface{}, respondTo *PID)deprecated
- func (pid *PID) RequestFuture(message interface{}, timeout time.Duration) *Futuredeprecated
- func (m *PID) Reset()
- func (m *PID) Size() (n int)
- func (pid *PID) Stop()deprecated
- func (pid *PID) StopFuture() *Futuredeprecated
- func (pid *PID) String() string
- func (pid *PID) Tell(message interface{})deprecated
- func (m *PID) Unmarshal(dAtA []byte) error
- type PIDSet
- func (p *PIDSet) Add(v *PID)
- func (p *PIDSet) Clear()
- func (p *PIDSet) Clone() *PIDSet
- func (p *PIDSet) Contains(v *PID) bool
- func (p *PIDSet) Empty() bool
- func (p *PIDSet) ForEach(f func(i int, pid PID))
- func (p *PIDSet) Len() int
- func (p *PIDSet) Remove(v *PID) bool
- func (p *PIDSet) Values() []PID
- type PoisonPill
- func (*PoisonPill) AutoReceiveMessage()
- func (*PoisonPill) Descriptor() ([]byte, []int)
- func (this *PoisonPill) Equal(that interface{}) bool
- func (m *PoisonPill) Marshal() (dAtA []byte, err error)
- func (m *PoisonPill) MarshalTo(dAtA []byte) (int, error)
- func (*PoisonPill) ProtoMessage()
- func (m *PoisonPill) Reset()
- func (m *PoisonPill) Size() (n int)
- func (this *PoisonPill) String() string
- func (m *PoisonPill) Unmarshal(dAtA []byte) error
- type Process
- type ProcessRegistryValue
- func (pr *ProcessRegistryValue) Add(process Process, id string) (*PID, bool)
- func (pr *ProcessRegistryValue) Get(pid *PID) (Process, bool)
- func (pr *ProcessRegistryValue) GetLocal(id string) (Process, bool)
- func (pr *ProcessRegistryValue) NextId() string
- func (pr *ProcessRegistryValue) RegisterAddressResolver(handler AddressResolver)
- func (pr *ProcessRegistryValue) Remove(pid *PID)
- type Producer
- type Props
- func (props *Props) WithContextDecorator(contextDecorator ...ContextDecorator) *Props
- func (props *Props) WithDispatcher(dispatcher mailbox.Dispatcher) *Props
- func (props *Props) WithFunc(f ActorFunc) *Props
- func (props *Props) WithGuardian(guardian SupervisorStrategy) *Props
- func (props *Props) WithMailbox(mailbox mailbox.Producer) *Props
- func (props *Props) WithMiddleware(middleware ...InboundMiddleware) *Propsdeprecated
- func (props *Props) WithOutboundMiddleware(middleware ...OutboundMiddleware) *Propsdeprecated
- func (props *Props) WithProducer(p Producer) *Props
- func (props *Props) WithReceiverMiddleware(middleware ...ReceiverMiddleware) *Props
- func (props *Props) WithSenderMiddleware(middleware ...SenderMiddleware) *Props
- func (props *Props) WithSpawnFunc(spawn SpawnFunc) *Props
- func (props *Props) WithSpawnMiddleware(middleware ...SpawnMiddleware) *Props
- func (props *Props) WithSupervisor(supervisor SupervisorStrategy) *Props
- type ReadonlyMessageHeader
- type ReceiveTimeout
- type ReceiverContext
- type ReceiverFunc
- type ReceiverMiddleware
- type Restart
- type RestartStatistics
- type Restarting
- type RootContext
- func (rc *RootContext) Actor() Actor
- func (rc RootContext) Copy() *RootContext
- func (rc *RootContext) Message() interface{}
- func (rc *RootContext) MessageHeader() ReadonlyMessageHeader
- func (rc *RootContext) Parent() *PID
- func (rc *RootContext) Poison(pid *PID)
- func (rc *RootContext) PoisonFuture(pid *PID) *Future
- func (rc *RootContext) Request(pid *PID, message interface{})
- func (rc *RootContext) RequestFuture(pid *PID, message interface{}, timeout time.Duration) *Future
- func (rc *RootContext) RequestWithCustomSender(pid *PID, message interface{}, sender *PID)
- func (rc *RootContext) Self() *PID
- func (rc *RootContext) Send(pid *PID, message interface{})
- func (rc *RootContext) Sender() *PID
- func (rc *RootContext) Spawn(props *Props) *PID
- func (rc *RootContext) SpawnNamed(props *Props, name string) (*PID, error)
- func (rc *RootContext) SpawnPrefix(props *Props, prefix string) *PID
- func (rc *RootContext) Stop(pid *PID)
- func (rc *RootContext) StopFuture(pid *PID) *Future
- func (rc *RootContext) WithGuardian(guardian SupervisorStrategy) *RootContext
- func (rc *RootContext) WithHeaders(headers map[string]string) *RootContext
- func (rc *RootContext) WithSenderMiddleware(middleware ...SenderMiddleware) *RootContext
- func (rc *RootContext) WithSpawnMiddleware(middleware ...SpawnMiddleware) *RootContext
- type SenderContext
- type SenderFunc
- type SenderMiddleware
- type SpawnFunc
- type SpawnMiddleware
- type SpawnerContext
- type Started
- type Stop
- func (*Stop) Descriptor() ([]byte, []int)
- func (this *Stop) Equal(that interface{}) bool
- func (m *Stop) Marshal() (dAtA []byte, err error)
- func (m *Stop) MarshalTo(dAtA []byte) (int, error)
- func (*Stop) ProtoMessage()
- func (m *Stop) Reset()
- func (m *Stop) Size() (n int)
- func (this *Stop) String() string
- func (*Stop) SystemMessage()
- func (m *Stop) Unmarshal(dAtA []byte) error
- type Stopped
- type Stopping
- type Supervisor
- type SupervisorEvent
- type SupervisorStrategy
- func DefaultSupervisorStrategy() SupervisorStrategy
- func NewAllForOneStrategy(maxNrOfRetries int, withinDuration time.Duration, decider DeciderFunc) SupervisorStrategy
- func NewExponentialBackoffStrategy(backoffWindow time.Duration, initialBackoff time.Duration) SupervisorStrategy
- func NewOneForOneStrategy(maxNrOfRetries int, withinDuration time.Duration, decider DeciderFunc) SupervisorStrategy
- func NewRestartingStrategy() SupervisorStrategy
- func RestartingSupervisorStrategy() SupervisorStrategy
- type SystemMessage
- type Terminated
- func (*Terminated) Descriptor() ([]byte, []int)
- func (this *Terminated) Equal(that interface{}) bool
- func (m *Terminated) GetAddressTerminated() bool
- func (m *Terminated) GetWho() *PID
- func (m *Terminated) Marshal() (dAtA []byte, err error)
- func (m *Terminated) MarshalTo(dAtA []byte) (int, error)
- func (*Terminated) ProtoMessage()
- func (m *Terminated) Reset()
- func (m *Terminated) Size() (n int)
- func (this *Terminated) String() string
- func (*Terminated) SystemMessage()
- func (m *Terminated) Unmarshal(dAtA []byte) error
- type Unwatch
- func (*Unwatch) Descriptor() ([]byte, []int)
- func (this *Unwatch) Equal(that interface{}) bool
- func (m *Unwatch) GetWatcher() *PID
- func (m *Unwatch) Marshal() (dAtA []byte, err error)
- func (m *Unwatch) MarshalTo(dAtA []byte) (int, error)
- func (*Unwatch) ProtoMessage()
- func (m *Unwatch) Reset()
- func (m *Unwatch) Size() (n int)
- func (this *Unwatch) String() string
- func (*Unwatch) SystemMessage()
- func (m *Unwatch) Unmarshal(dAtA []byte) error
- type Watch
- func (*Watch) Descriptor() ([]byte, []int)
- func (this *Watch) Equal(that interface{}) bool
- func (m *Watch) GetWatcher() *PID
- func (m *Watch) Marshal() (dAtA []byte, err error)
- func (m *Watch) MarshalTo(dAtA []byte) (int, error)
- func (*Watch) ProtoMessage()
- func (m *Watch) Reset()
- func (m *Watch) Size() (n int)
- func (this *Watch) String() string
- func (*Watch) SystemMessage()
- func (m *Watch) Unmarshal(dAtA []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthProtos = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowProtos = fmt.Errorf("proto: integer overflow") )
var (
EmptyMessageHeader = make(messageHeader)
)
var EmptyRootContext = &RootContext{ senderMiddleware: nil, spawnMiddleware: nil, headers: EmptyMessageHeader, guardianStrategy: nil, }
var ErrNameExists = errors.New("spawn: name exists")
ErrNameExists is the error used when an existing name is used for spawning an actor.
var ErrTimeout = errors.New("future: timeout")
ErrTimeout is the error used when a future times out before receiving a result.
var ProcessRegistry = &ProcessRegistryValue{ Address: localAddress, LocalPIDs: cmap.New(), }
ProcessRegistry is a registry of all active processes.
NOTE: This should only be used for advanced scenarios
Functions ¶
func SetLogLevel ¶
func SetOptions ¶
func SetOptions(opts ...optionFn)
SetOptions is used to configure the actor system
func UnwrapEnvelope ¶
func UnwrapEnvelope(message interface{}) (ReadonlyMessageHeader, interface{}, *PID)
func UnwrapEnvelopeMessage ¶
func UnwrapEnvelopeMessage(message interface{}) interface{}
func WithDeadLetterSubscriber ¶
func WithDeadLetterSubscriber(fn func(evt interface{})) optionFn
WithDeadLetterSubscriber option replaces the default DeadLetterEvent event subscriber with fn.
fn will only receive *DeadLetterEvent messages
Specifying nil will clear the existing.
func WithSupervisorSubscriber ¶
func WithSupervisorSubscriber(fn func(evt interface{})) optionFn
WithSupervisorSubscriber option replaces the default SupervisorEvent event subscriber with fn.
fn will only receive *SupervisorEvent messages
Specifying nil will clear the existing.
Types ¶
type Actor ¶
type Actor interface {
Receive(c Context)
}
Actor is the interface that defines the Receive method.
Receive is sent messages to be processed from the mailbox associated with the instance of the actor
type ActorFunc ¶
type ActorFunc func(c Context)
The ActorFunc type is an adapter to allow the use of ordinary functions as actors to process messages
type ActorProcess ¶
type ActorProcess struct {
// contains filtered or unexported fields
}
func NewActorProcess ¶
func NewActorProcess(mailbox mailbox.Mailbox) *ActorProcess
func (*ActorProcess) SendSystemMessage ¶
func (ref *ActorProcess) SendSystemMessage(pid *PID, message interface{})
func (*ActorProcess) SendUserMessage ¶
func (ref *ActorProcess) SendUserMessage(pid *PID, message interface{})
func (*ActorProcess) Stop ¶
func (ref *ActorProcess) Stop(pid *PID)
type AddressResolver ¶
An AddressResolver is used to resolve remote actors
type AutoReceiveMessage ¶
type AutoReceiveMessage interface {
AutoReceiveMessage()
}
An AutoReceiveMessage is a special kind of user message that will be handled in some way automatially by the actor
type Behavior ¶
type Behavior []ActorFunc
func NewBehavior ¶
func NewBehavior() Behavior
func (*Behavior) BecomeStacked ¶
func (*Behavior) UnbecomeStacked ¶
func (b *Behavior) UnbecomeStacked()
type Context ¶
type Context interface {
// contains filtered or unexported methods
}
Context contains contextual information for actors
type ContextDecorator ¶
type ContextDecorator func(next ContextDecoratorFunc) ContextDecoratorFunc
type ContextDecoratorFunc ¶
type DeadLetterEvent ¶
type DeadLetterEvent struct { PID *PID // The invalid process, to which the message was sent Message interface{} // The message that could not be delivered Sender *PID // the process that sent the Message }
A DeadLetterEvent is published via event.Publish when a message is sent to a nonexistent PID
type DeciderFunc ¶
type DeciderFunc func(reason interface{}) Directive
DeciderFunc is a function which is called by a SupervisorStrategy
type Directive ¶
type Directive int
Directive is an enum for supervision actions
const ( // ResumeDirective instructs the supervisor to resume the actor and continue processing messages ResumeDirective Directive = iota // RestartDirective instructs the supervisor to discard the actor, replacing it with a new instance, // before processing additional messages RestartDirective // StopDirective instructs the supervisor to stop the actor StopDirective // EscalateDirective instructs the supervisor to escalate handling of the failure to the actor's parent supervisor EscalateDirective )
Directive determines how a supervisor should handle a faulting actor
func DefaultDecider ¶
func DefaultDecider(_ interface{}) Directive
DefaultDecider is a decider that will always restart the failing child actor
type Failure ¶
type Failure struct { Who *PID Reason interface{} RestartStats *RestartStatistics Message interface{} }
func (*Failure) SystemMessage ¶
func (*Failure) SystemMessage()
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
type InboundMiddleware
deprecated
type MessageEnvelope ¶
type MessageEnvelope struct { Header messageHeader Message interface{} Sender *PID }
func WrapEnvelope ¶
func WrapEnvelope(message interface{}) *MessageEnvelope
func (*MessageEnvelope) GetHeader ¶
func (me *MessageEnvelope) GetHeader(key string) string
func (*MessageEnvelope) SetHeader ¶
func (me *MessageEnvelope) SetHeader(key string, value string)
type NotInfluenceReceiveTimeout ¶
type NotInfluenceReceiveTimeout interface {
NotInfluenceReceiveTimeout()
}
NotInfluenceReceiveTimeout messages will not reset the ReceiveTimeout timer of an actor that receives the message
type OutboundMiddleware
deprecated
type OutboundMiddleware func(next SenderFunc) SenderFunc
Deprecated: Use SenderMiddleware instead
type PID ¶
type PID struct { Address string `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address,omitempty"` Id string `protobuf:"bytes,2,opt,name=Id,proto3" json:"Id,omitempty"` // contains filtered or unexported fields }
func NewLocalPID ¶
NewLocalPID returns a new instance of the PID struct with the address preset
func Spawn ¶
Spawn starts a new actor based on props and named with a unique id Deprecated: Use context.Spawn instead.
func SpawnNamed ¶
SpawnNamed starts a new actor based on props and named using the specified name
If name exists, error will be ErrNameExists Deprecated: Use context.SpawnNamed instead.
func SpawnPrefix ¶
SpawnPrefix starts a new actor based on props and named using a prefix followed by a unique id Deprecated: Use context.SpawnPrefix instead.
func UnwrapEnvelopeSender ¶
func UnwrapEnvelopeSender(message interface{}) *PID
func (*PID) Descriptor ¶
func (*PID) GetAddress ¶
func (*PID) GracefulPoison
deprecated
func (pid *PID) GracefulPoison()
GracefulPoison will tell and wait actor to stop after processing current user messages in mailbox.
Deprecated: Use Context.PoisonFuture(pid).Wait() instead
func (*PID) GracefulStop
deprecated
func (pid *PID) GracefulStop()
GracefulStop will stop actor immediately regardless of existing user messages in mailbox.
Deprecated: Use Context.StopFuture(pid).Wait() instead
func (*PID) PoisonFuture
deprecated
func (*PID) ProtoMessage ¶
func (*PID) ProtoMessage()
func (*PID) RequestFuture
deprecated
func (*PID) StopFuture
deprecated
type PIDSet ¶
type PIDSet struct {
// contains filtered or unexported fields
}
type PoisonPill ¶
type PoisonPill struct { }
user messages
func (*PoisonPill) AutoReceiveMessage ¶
func (*PoisonPill) AutoReceiveMessage()
func (*PoisonPill) Descriptor ¶
func (*PoisonPill) Descriptor() ([]byte, []int)
func (*PoisonPill) Equal ¶
func (this *PoisonPill) Equal(that interface{}) bool
func (*PoisonPill) Marshal ¶
func (m *PoisonPill) Marshal() (dAtA []byte, err error)
func (*PoisonPill) ProtoMessage ¶
func (*PoisonPill) ProtoMessage()
func (*PoisonPill) Reset ¶
func (m *PoisonPill) Reset()
func (*PoisonPill) Size ¶
func (m *PoisonPill) Size() (n int)
func (*PoisonPill) String ¶
func (this *PoisonPill) String() string
func (*PoisonPill) Unmarshal ¶
func (m *PoisonPill) Unmarshal(dAtA []byte) error
type Process ¶
type Process interface { SendUserMessage(pid *PID, message interface{}) SendSystemMessage(pid *PID, message interface{}) Stop(pid *PID) }
A Process is an interface that defines the base contract for interaction of actors
type ProcessRegistryValue ¶
type ProcessRegistryValue struct { SequenceID uint64 Address string LocalPIDs cmap.ConcurrentMap RemoteHandlers []AddressResolver }
func (*ProcessRegistryValue) Add ¶
func (pr *ProcessRegistryValue) Add(process Process, id string) (*PID, bool)
func (*ProcessRegistryValue) GetLocal ¶
func (pr *ProcessRegistryValue) GetLocal(id string) (Process, bool)
func (*ProcessRegistryValue) NextId ¶
func (pr *ProcessRegistryValue) NextId() string
func (*ProcessRegistryValue) RegisterAddressResolver ¶
func (pr *ProcessRegistryValue) RegisterAddressResolver(handler AddressResolver)
func (*ProcessRegistryValue) Remove ¶
func (pr *ProcessRegistryValue) Remove(pid *PID)
type Props ¶
type Props struct {
// contains filtered or unexported fields
}
Props represents configuration to define how an actor should be created
func FromProducer
deprecated
func FromSpawnFunc
deprecated
func PropsFromFunc ¶
PropsFromFunc creates a props with the given receive func assigned as the actor producer
func PropsFromProducer ¶
PropsFromProducer creates a props with the given actor producer assigned
func (*Props) WithContextDecorator ¶
func (props *Props) WithContextDecorator(contextDecorator ...ContextDecorator) *Props
WithContextDecorator assigns context decorator to the props
func (*Props) WithDispatcher ¶
func (props *Props) WithDispatcher(dispatcher mailbox.Dispatcher) *Props
WithDispatcher assigns a dispatcher to the props
func (*Props) WithGuardian ¶
func (props *Props) WithGuardian(guardian SupervisorStrategy) *Props
WithGuardian assigns a guardian strategy to the props
func (*Props) WithMailbox ¶
WithMailbox assigns the desired mailbox producer to the props
func (*Props) WithMiddleware
deprecated
func (props *Props) WithMiddleware(middleware ...InboundMiddleware) *Props
Deprecated: Use WithReceiverMiddleware instead
func (*Props) WithOutboundMiddleware
deprecated
func (props *Props) WithOutboundMiddleware(middleware ...OutboundMiddleware) *Props
Deprecated: Use WithSenderMiddleware instead
func (*Props) WithProducer ¶
WithProducer assigns a actor producer to the props
func (*Props) WithReceiverMiddleware ¶
func (props *Props) WithReceiverMiddleware(middleware ...ReceiverMiddleware) *Props
Assign one or more middlewares to the props
func (*Props) WithSenderMiddleware ¶
func (props *Props) WithSenderMiddleware(middleware ...SenderMiddleware) *Props
func (*Props) WithSpawnFunc ¶
WithSpawnFunc assigns a custom spawn func to the props, this is mainly for internal usage
func (*Props) WithSpawnMiddleware ¶
func (props *Props) WithSpawnMiddleware(middleware ...SpawnMiddleware) *Props
func (*Props) WithSupervisor ¶
func (props *Props) WithSupervisor(supervisor SupervisorStrategy) *Props
WithSupervisor assigns a supervision strategy to the props
type ReadonlyMessageHeader ¶
type ReadonlyMessageHeader interface { Get(key string) string Keys() []string Length() int ToMap() map[string]string }
func UnwrapEnvelopeHeader ¶
func UnwrapEnvelopeHeader(message interface{}) ReadonlyMessageHeader
type ReceiveTimeout ¶
type ReceiveTimeout struct{}
A ReceiveTimeout message is sent to an actor after the Context.ReceiveTimeout duration has expired
type ReceiverContext ¶
type ReceiverContext interface {
// contains filtered or unexported methods
}
type ReceiverFunc ¶
type ReceiverFunc func(c ReceiverContext, envelope *MessageEnvelope)
type ReceiverMiddleware ¶
type ReceiverMiddleware func(next ReceiverFunc) ReceiverFunc
type Restart ¶
type Restart struct{}
Restart is message sent by the actor system to control the lifecycle of an actor
func (*Restart) SystemMessage ¶
func (*Restart) SystemMessage()
type RestartStatistics ¶
type RestartStatistics struct {
// contains filtered or unexported fields
}
RestartStatistics keeps track of how many times an actor have restarted and when
func NewRestartStatistics ¶
func NewRestartStatistics() *RestartStatistics
NewRestartStatistics construct a RestartStatistics
func (*RestartStatistics) Fail ¶
func (rs *RestartStatistics) Fail()
Fail increases the associated actors failure count
func (*RestartStatistics) FailureCount ¶
func (rs *RestartStatistics) FailureCount() int
FailureCount returns failure count
func (*RestartStatistics) NumberOfFailures ¶
func (rs *RestartStatistics) NumberOfFailures(withinDuration time.Duration) int
NumberOfFailures returns number of failures within a given duration
func (*RestartStatistics) Reset ¶
func (rs *RestartStatistics) Reset()
Reset the associated actors failure count
type Restarting ¶
type Restarting struct{}
A Restarting message is sent to an actor when the actor is being restarted by the system due to a failure
func (*Restarting) AutoReceiveMessage ¶
func (*Restarting) AutoReceiveMessage()
type RootContext ¶
type RootContext struct {
// contains filtered or unexported fields
}
func NewRootContext ¶
func NewRootContext(header map[string]string, middleware ...SenderMiddleware) *RootContext
func (*RootContext) Actor ¶
func (rc *RootContext) Actor() Actor
func (RootContext) Copy ¶
func (rc RootContext) Copy() *RootContext
func (*RootContext) Message ¶
func (rc *RootContext) Message() interface{}
func (*RootContext) MessageHeader ¶
func (rc *RootContext) MessageHeader() ReadonlyMessageHeader
func (*RootContext) Parent ¶
func (rc *RootContext) Parent() *PID
func (*RootContext) Poison ¶
func (rc *RootContext) Poison(pid *PID)
Poison will tell actor to stop after processing current user messages in mailbox.
func (*RootContext) PoisonFuture ¶
func (rc *RootContext) PoisonFuture(pid *PID) *Future
PoisonFuture will tell actor to stop after processing current user messages in mailbox, and return its future.
func (*RootContext) Request ¶
func (rc *RootContext) Request(pid *PID, message interface{})
func (*RootContext) RequestFuture ¶
func (rc *RootContext) RequestFuture(pid *PID, message interface{}, timeout time.Duration) *Future
RequestFuture sends a message to a given PID and returns a Future
func (*RootContext) RequestWithCustomSender ¶
func (rc *RootContext) RequestWithCustomSender(pid *PID, message interface{}, sender *PID)
func (*RootContext) Self ¶
func (rc *RootContext) Self() *PID
func (*RootContext) Send ¶
func (rc *RootContext) Send(pid *PID, message interface{})
func (*RootContext) Sender ¶
func (rc *RootContext) Sender() *PID
func (*RootContext) Spawn ¶
func (rc *RootContext) Spawn(props *Props) *PID
Spawn starts a new actor based on props and named with a unique id
func (*RootContext) SpawnNamed ¶
func (rc *RootContext) SpawnNamed(props *Props, name string) (*PID, error)
SpawnNamed starts a new actor based on props and named using the specified name
ErrNameExists will be returned if id already exists ¶
Please do not use name sharing same pattern with system actors, for example "YourPrefix$1", "Remote$1", "future$1"
func (*RootContext) SpawnPrefix ¶
func (rc *RootContext) SpawnPrefix(props *Props, prefix string) *PID
SpawnPrefix starts a new actor based on props and named using a prefix followed by a unique id
func (*RootContext) Stop ¶
func (rc *RootContext) Stop(pid *PID)
Stop will stop actor immediately regardless of existing user messages in mailbox.
func (*RootContext) StopFuture ¶
func (rc *RootContext) StopFuture(pid *PID) *Future
StopFuture will stop actor immediately regardless of existing user messages in mailbox, and return its future.
func (*RootContext) WithGuardian ¶
func (rc *RootContext) WithGuardian(guardian SupervisorStrategy) *RootContext
func (*RootContext) WithHeaders ¶
func (rc *RootContext) WithHeaders(headers map[string]string) *RootContext
func (*RootContext) WithSenderMiddleware ¶
func (rc *RootContext) WithSenderMiddleware(middleware ...SenderMiddleware) *RootContext
func (*RootContext) WithSpawnMiddleware ¶
func (rc *RootContext) WithSpawnMiddleware(middleware ...SpawnMiddleware) *RootContext
type SenderContext ¶
type SenderContext interface {
// contains filtered or unexported methods
}
type SenderFunc ¶
type SenderFunc func(c SenderContext, target *PID, envelope *MessageEnvelope)
type SenderMiddleware ¶
type SenderMiddleware func(next SenderFunc) SenderFunc
type SpawnFunc ¶
type SpawnFunc func(id string, props *Props, parentContext SpawnerContext) (*PID, error)
Props types
var DefaultSpawner SpawnFunc = defaultSpawner
DefaultSpawner this is a hacking way to allow Proto.Router access default spawner func
type SpawnMiddleware ¶
type SpawnerContext ¶
type SpawnerContext interface {
// contains filtered or unexported methods
}
type Started ¶
type Started struct{}
A Started message is sent to an actor once it has been started and ready to begin receiving messages.
func (*Started) SystemMessage ¶
func (*Started) SystemMessage()
type Stop ¶
type Stop struct { }
func (*Stop) Descriptor ¶
func (*Stop) ProtoMessage ¶
func (*Stop) ProtoMessage()
func (*Stop) SystemMessage ¶
func (*Stop) SystemMessage()
type Stopped ¶
type Stopped struct{}
A Stopped message is sent to the actor once it has been stopped. A stopped actor will receive no further messages
func (*Stopped) AutoReceiveMessage ¶
func (*Stopped) AutoReceiveMessage()
type Stopping ¶
type Stopping struct{}
A Stopping message is sent to an actor prior to the actor being stopped
func (*Stopping) AutoReceiveMessage ¶
func (*Stopping) AutoReceiveMessage()
type Supervisor ¶
type Supervisor interface { Children() []*PID EscalateFailure(reason interface{}, message interface{}) RestartChildren(pids ...*PID) StopChildren(pids ...*PID) ResumeChildren(pids ...*PID) }
Supervisor is an interface that is used by the SupervisorStrategy to manage child actor lifecycle
type SupervisorEvent ¶
SupervisorEvent is sent on the EventStream when a supervisor have applied a directive to a failing child actor
type SupervisorStrategy ¶
type SupervisorStrategy interface {
HandleFailure(supervisor Supervisor, child *PID, rs *RestartStatistics, reason interface{}, message interface{})
}
SupervisorStrategy is an interface that decides how to handle failing child actors
func DefaultSupervisorStrategy ¶
func DefaultSupervisorStrategy() SupervisorStrategy
func NewAllForOneStrategy ¶
func NewAllForOneStrategy(maxNrOfRetries int, withinDuration time.Duration, decider DeciderFunc) SupervisorStrategy
NewAllForOneStrategy returns a new SupervisorStrategy which applies the given fault Directive from the decider to the failing child and all its children.
This strategy is appropriate when the children have a strong dependency, such that and any single one failing would place them all into a potentially invalid state.
func NewExponentialBackoffStrategy ¶
func NewExponentialBackoffStrategy(backoffWindow time.Duration, initialBackoff time.Duration) SupervisorStrategy
NewExponentialBackoffStrategy creates a new Supervisor strategy that restarts a faulting child using an exponential back off algorithm:
delay =
func NewOneForOneStrategy ¶
func NewOneForOneStrategy(maxNrOfRetries int, withinDuration time.Duration, decider DeciderFunc) SupervisorStrategy
NewOneForOneStrategy returns a new Supervisor strategy which applies the fault Directive from the decider to the failing child process.
This strategy is applicable if it is safe to handle a single child in isolation from its peers or dependents
func NewRestartingStrategy ¶
func NewRestartingStrategy() SupervisorStrategy
func RestartingSupervisorStrategy ¶
func RestartingSupervisorStrategy() SupervisorStrategy
type SystemMessage ¶
type SystemMessage interface {
SystemMessage()
}
A SystemMessage message is reserved for specific lifecycle messages used by the actor system
type Terminated ¶
type Terminated struct { Who *PID `protobuf:"bytes,1,opt,name=who" json:"who,omitempty"` AddressTerminated bool `protobuf:"varint,2,opt,name=address_terminated,json=addressTerminated,proto3" json:"address_terminated,omitempty"` }
func (*Terminated) Descriptor ¶
func (*Terminated) Descriptor() ([]byte, []int)
func (*Terminated) Equal ¶
func (this *Terminated) Equal(that interface{}) bool
func (*Terminated) GetAddressTerminated ¶
func (m *Terminated) GetAddressTerminated() bool
func (*Terminated) GetWho ¶
func (m *Terminated) GetWho() *PID
func (*Terminated) Marshal ¶
func (m *Terminated) Marshal() (dAtA []byte, err error)
func (*Terminated) ProtoMessage ¶
func (*Terminated) ProtoMessage()
func (*Terminated) Reset ¶
func (m *Terminated) Reset()
func (*Terminated) Size ¶
func (m *Terminated) Size() (n int)
func (*Terminated) String ¶
func (this *Terminated) String() string
func (*Terminated) SystemMessage ¶
func (*Terminated) SystemMessage()
func (*Terminated) Unmarshal ¶
func (m *Terminated) Unmarshal(dAtA []byte) error
type Unwatch ¶
type Unwatch struct {
Watcher *PID `protobuf:"bytes,1,opt,name=watcher" json:"watcher,omitempty"`
}
func (*Unwatch) Descriptor ¶
func (*Unwatch) GetWatcher ¶
func (*Unwatch) ProtoMessage ¶
func (*Unwatch) ProtoMessage()
func (*Unwatch) SystemMessage ¶
func (*Unwatch) SystemMessage()
type Watch ¶
type Watch struct {
Watcher *PID `protobuf:"bytes,1,opt,name=watcher" json:"watcher,omitempty"`
}
system messages
func (*Watch) Descriptor ¶
func (*Watch) GetWatcher ¶
func (*Watch) ProtoMessage ¶
func (*Watch) ProtoMessage()
func (*Watch) SystemMessage ¶
func (*Watch) SystemMessage()
Source Files ¶
- actor.go
- actor_context.go
- actor_process.go
- behavior.go
- child_restart_stats.go
- context.go
- deadletter.go
- directive.go
- directive_string.go
- future.go
- guardian.go
- log.go
- message_envelope.go
- messages.go
- middleware_chain.go
- options.go
- pid.go
- pidset.go
- process.go
- process_registry.go
- props.go
- protos.pb.go
- root_context.go
- spawn.go
- strategy_all_for_one.go
- strategy_exponential_backoff.go
- strategy_one_for_one.go
- strategy_restarting.go
- supervision.go
- supervision_event.go