actor

package
v0.0.0-...-14bd45b Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnableDebug bool
View Source
var (
	OnReset util.Delegate
)
View Source
var RemoteProcessCreator func(*PID, *Domain) Process

Functions

func AllocRPCSeq

func AllocRPCSeq() int64

func DestroyDomain

func DestroyDomain(name string)

func Exit

func Exit(exitcode int)

退出

func Load

func Load(pid *PID, data []byte)

func LoopSystem

func LoopSystem() int

func Save

func Save(pid *PID) []byte

func StartSystem

func StartSystem()

func VisitDomains

func VisitDomains(callback func(*Domain) bool)

Types

type Actor

type Actor interface {
	OnRecv(c Context)
}

Actor模式接收消息主体

type ActorCreator

type ActorCreator func() Actor

type ActorTemplate

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

func NewTemplate

func NewTemplate() *ActorTemplate

func (*ActorTemplate) WithCreator

func (self *ActorTemplate) WithCreator(ac ActorCreator) *ActorTemplate

func (*ActorTemplate) WithFunc

func (self *ActorTemplate) WithFunc(f func(c Context)) *ActorTemplate

func (*ActorTemplate) WithID

func (self *ActorTemplate) WithID(id string) *ActorTemplate

func (*ActorTemplate) WithInstance

func (self *ActorTemplate) WithInstance(a Actor) *ActorTemplate

func (*ActorTemplate) WithParent

func (self *ActorTemplate) WithParent(pid *PID) *ActorTemplate

type Context

type Context interface {

	// 消息本体
	Msg() interface{}

	// 消息来源方,可能为空
	Source() *PID

	// Actor本体的PID
	Self() *PID

	Parent() *PID

	// 当对方用Call调用时, 需要用Reply回应
	Reply(data interface{})

	String() string
}

信息上下文

type Domain

type Domain struct {
	Name string

	RemoteContext interface{}
	// contains filtered or unexported fields
}

func CreateDomain

func CreateDomain(name string) *Domain

func CreateRemoteDomain

func CreateRemoteDomain(name string) *Domain

func GetDomain

func GetDomain(name string) *Domain

找到对应地址的远程pid管理器

func MustGetDomain

func MustGetDomain(name string) *Domain

func (*Domain) Add

func (self *Domain) Add(p Process) error

func (*Domain) Get

func (self *Domain) Get(pid *PID) Process

func (*Domain) GetByID

func (self *Domain) GetByID(id string) Process

func (*Domain) Kill

func (self *Domain) Kill(pid *PID)

func (*Domain) Spawn

func (self *Domain) Spawn(t *ActorTemplate) *PID

func (*Domain) String

func (self *Domain) String() string

type LocalProcess

type LocalProcess struct {
	*RelationImplement
	// contains filtered or unexported fields
}

func (*LocalProcess) CreateRPC

func (self *LocalProcess) CreateRPC(waitCallID int64) *util.Future

func (*LocalProcess) Init

func (self *LocalProcess) Init(a Actor, pid *PID, dm *Domain) *LocalProcess

func (*LocalProcess) OnRecv

func (self *LocalProcess) OnRecv(data interface{})

func (*LocalProcess) PID

func (self *LocalProcess) PID() *PID

func (*LocalProcess) Serialize

func (self *LocalProcess) Serialize(ser Serializer)

func (*LocalProcess) Stop

func (self *LocalProcess) Stop()

func (*LocalProcess) Tell

func (self *LocalProcess) Tell(data interface{})

type Message

type Message struct {
	Data      interface{}
	SourcePID *PID
	TargetPID *PID
	CallID    int64
}

func (*Message) Msg

func (self *Message) Msg() interface{}

func (*Message) Parent

func (self *Message) Parent() *PID

func (*Message) Reply

func (self *Message) Reply(data interface{})

func (*Message) Self

func (self *Message) Self() *PID

func (*Message) Source

func (self *Message) Source() *PID

func (*Message) String

func (self *Message) String() string

type PID

type PID struct {
	Domain string
	Id     string
	// contains filtered or unexported fields
}

func NewPID

func NewPID(domain, id string) *PID

func (*PID) Call

func (self *PID) Call(data interface{}, sender *PID) interface{}

func (*PID) CallFuture

func (self *PID) CallFuture(data interface{}, sender *PID) *util.Future

func (*PID) FromProto

func (self *PID) FromProto(pid proto.PID)

func (*PID) String

func (self *PID) String() string

func (*PID) Tell

func (self *PID) Tell(data interface{})

func (*PID) TellBySender

func (self *PID) TellBySender(data interface{}, sender *PID)

func (*PID) ToProto

func (self *PID) ToProto() proto.PID

type Process

type Process interface {
	Tell(interface{})

	Stop()

	PID() *PID

	Relation
}

type Relation

type Relation interface {
	AddChild(*PID)

	ParentPID() *PID

	SetParentPID(ppid *PID)
}

type RelationImplement

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

func NewRelation

func NewRelation(proc Process, dm *Domain) *RelationImplement

func (*RelationImplement) AddChild

func (self *RelationImplement) AddChild(pid *PID)

func (*RelationImplement) Domain

func (self *RelationImplement) Domain() *Domain

func (*RelationImplement) ParentPID

func (self *RelationImplement) ParentPID() *PID

func (*RelationImplement) SetParentPID

func (self *RelationImplement) SetParentPID(ppid *PID)

type Serializable

type Serializable interface {
	OnSerialize(Serializer)
}

type Serializer

type Serializer interface {
	IsLoading() bool

	Serialize(data interface{})

	Bytes() []byte
}

func NewBinaryReader

func NewBinaryReader(r io.Reader) Serializer

func NewBinaryWriter

func NewBinaryWriter() Serializer

Jump to

Keyboard shortcuts

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