Documentation ¶
Index ¶
- Variables
- func Catch(f func())
- func Close()
- func Go(run GoRun, onRet OnReturn)
- func Post(ctx context.Context, receiver def.ActorID, message def.Message)
- func RegisterActorCreator(actorType def.ActorType, creator ActorCreator) bool
- func RegisterApplication(name string, creator def.NewApplication)
- func StartApplication(v *viper.Viper, name string) error
- func StartApplications(v *viper.Viper, apps []string) error
- func Wait()
- type Actor
- type ActorCreator
- type DefaultImplement
- type ExitChan
- type GoRun
- type Handler
- type Manager
- func (m *Manager) Close()
- func (m *Manager) Get(id def.ActorID) Actor
- func (m *Manager) Go(run GoRun, onRet OnReturn)
- func (m *Manager) NewActor(actorType def.ActorType, id def.ActorID) Actor
- func (m *Manager) Post(ctx context.Context, receiver def.ActorID, message def.Message)
- func (m *Manager) Wait()
- type OnReturn
- type Receiver
- type SimpleActor
- func (a *SimpleActor) Handle(ctx context.Context, message def.Message, args ...interface{}) error
- func (a *SimpleActor) ID() def.ActorID
- func (a *SimpleActor) Initialize() error
- func (a *SimpleActor) MessageQueue() def.MessageQueue
- func (a *SimpleActor) Post(ctx context.Context, message def.Message)
- func (a *SimpleActor) Terminate()
- func (a *SimpleActor) Type() def.ActorType
- type Supervisor
- type TwoWayMap
- func (m *TwoWayMap) Delete(key interface{})
- func (m *TwoWayMap) Load(key interface{}) (value interface{}, ok bool)
- func (m *TwoWayMap) LoadAndDelete(key interface{}) (value interface{}, loaded bool)
- func (m *TwoWayMap) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)
- func (m *TwoWayMap) Range(f func(key, value interface{}) bool)
- func (m *TwoWayMap) Store(key, value interface{})
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoSuchApplication = errors.New("no such application")
)
Functions ¶
func RegisterActorCreator ¶
func RegisterActorCreator(actorType def.ActorType, creator ActorCreator) bool
func RegisterApplication ¶
func RegisterApplication(name string, creator def.NewApplication)
Types ¶
type Actor ¶
type Actor interface { Initialize(v *viper.Viper) error // will be called by supervisor Terminate() // will be called in actor's goroutine DefaultImplement }
type ActorCreator ¶
type ActorCreator func() Actor
type DefaultImplement ¶
type Manager ¶
type Manager struct { ExitChan // contains filtered or unexported fields }
func NewManager ¶
func NewManager() *Manager
type SimpleActor ¶
type SimpleActor struct { sc.SimpleState // contains filtered or unexported fields }
func (*SimpleActor) ID ¶
func (a *SimpleActor) ID() def.ActorID
func (*SimpleActor) Initialize ¶
func (a *SimpleActor) Initialize() error
must be called by outer Initialize and ignore error
func (*SimpleActor) MessageQueue ¶
func (a *SimpleActor) MessageQueue() def.MessageQueue
func (*SimpleActor) Post ¶
func (a *SimpleActor) Post(ctx context.Context, message def.Message)
no any check for performance Post will lock if the mq has not been initial
func (*SimpleActor) Terminate ¶
func (a *SimpleActor) Terminate()
func (*SimpleActor) Type ¶
func (a *SimpleActor) Type() def.ActorType
type Supervisor ¶
type Supervisor struct { }
func NewSupervisor ¶
func NewSupervisor() (*Supervisor, error)
func (*Supervisor) HandleActor ¶
func (sup *Supervisor) HandleActor(actor def.ActorID, message def.Message)
func (*Supervisor) Initialize ¶
func (sup *Supervisor) Initialize() error
type TwoWayMap ¶
type TwoWayMap struct {
// contains filtered or unexported fields
}
func NewTwoWayMap ¶
func (*TwoWayMap) Delete ¶
func (m *TwoWayMap) Delete(key interface{})
Delete deletes the value for a key.
func (*TwoWayMap) Load ¶
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*TwoWayMap) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*TwoWayMap) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (*TwoWayMap) Range ¶
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.
Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.