Documentation ¶
Index ¶
- Constants
- func LDebug(l *lua.LState) int
- func LError(l *lua.LState) int
- func LGoVersion(l *lua.LState) int
- func LWarn(l *lua.LState) int
- func New(id string, handler IActorHandler, op ...ActorOption) *actor
- func ParseRequestId(requestId string) (source string, target string, addr string, ok bool)
- type ActorHanlerBase
- func (s *ActorHanlerBase) BResponse(requestId string, msg interface{})
- func (s *ActorHanlerBase) HandleEvent(event interface{})
- func (s *ActorHanlerBase) HandleMessage(sourceId, targetId string, msg interface{})
- func (s *ActorHanlerBase) HandleRequest(sourceId, targetId, requestId string, msg interface{}) (respErr error)
- func (s *ActorHanlerBase) Init()
- func (s *ActorHanlerBase) Stop() bool
- type ActorOption
- type ActorSystem
- func (s *ActorSystem) Address() string
- func (s *ActorSystem) ClusterId() string
- func (s *ActorSystem) Regist(actor *actor) error
- func (as *ActorSystem) RegistCmd(actorId, cmd string, fn func(...string))
- func (s *ActorSystem) Send(sourceId, targetId, requestId string, msg interface{}) error
- func (s *ActorSystem) SetCluster(id string)
- func (s *ActorSystem) Stop()
- type Ev_clusterUpdate
- type Ev_delActor
- type Ev_delSession
- type Ev_newActor
- type Ev_newSession
- type EventDispatcher
- func (ed *EventDispatcher) CancelAll(actorId string)
- func (ed *EventDispatcher) CancelEvent(actorId string, events ...interface{}) error
- func (ed *EventDispatcher) DispatchEvent(sourceId string, event interface{}) error
- func (ed *EventDispatcher) RegistEvent(actorId string, events ...interface{}) error
- type IActor
- type IActorHandler
- type ICmd
- type SystemOption
Constants ¶
View Source
const DefaultTimeout = time.Second * 30
Variables ¶
This section is empty.
Functions ¶
func LGoVersion ¶
func New ¶ added in v1.0.1
func New(id string, handler IActorHandler, op ...ActorOption) *actor
创建actor id actorId外部定义 @和$为内部符号,其他id尽量不占用 handler 消息处理模块 op 修改默认属性
Types ¶
type ActorHanlerBase ¶
type ActorHanlerBase struct {
IActor
}
func (*ActorHanlerBase) BResponse ¶
func (s *ActorHanlerBase) BResponse(requestId string, msg interface{})
func (*ActorHanlerBase) HandleEvent ¶
func (s *ActorHanlerBase) HandleEvent(event interface{})
func (*ActorHanlerBase) HandleMessage ¶
func (s *ActorHanlerBase) HandleMessage(sourceId, targetId string, msg interface{})
func (*ActorHanlerBase) HandleRequest ¶
func (s *ActorHanlerBase) HandleRequest(sourceId, targetId, requestId string, msg interface{}) (respErr error)
func (*ActorHanlerBase) Init ¶
func (s *ActorHanlerBase) Init()
func (*ActorHanlerBase) Stop ¶
func (s *ActorHanlerBase) Stop() bool
type ActorOption ¶
type ActorOption func(*actor)
func SetLocalized ¶
func SetLocalized() ActorOption
func SetLua ¶
func SetLua(path string) ActorOption
func SetTimerAccuracy ¶
func SetTimerAccuracy(acc int64) ActorOption
type ActorSystem ¶
type ActorSystem struct { *EventDispatcher // contains filtered or unexported fields }
func System ¶ added in v1.0.1
func System(op ...SystemOption) (*ActorSystem, error)
func (*ActorSystem) Address ¶
func (s *ActorSystem) Address() string
func (*ActorSystem) ClusterId ¶
func (s *ActorSystem) ClusterId() string
func (*ActorSystem) Regist ¶
func (s *ActorSystem) Regist(actor *actor) error
注册actor,外部创建对象,保证ActorId唯一性
func (*ActorSystem) RegistCmd ¶
func (as *ActorSystem) RegistCmd(actorId, cmd string, fn func(...string))
func (*ActorSystem) Send ¶
func (s *ActorSystem) Send(sourceId, targetId, requestId string, msg interface{}) error
actor之间发送消息, sourceid 发送源actor targetid 目标actor message 消息内容
func (*ActorSystem) SetCluster ¶ added in v1.0.1
func (s *ActorSystem) SetCluster(id string)
func (*ActorSystem) Stop ¶
func (s *ActorSystem) Stop()
type Ev_clusterUpdate ¶
type Ev_delActor ¶
type Ev_delSession ¶
type Ev_delSession struct {
Host string
}
type Ev_newActor ¶
type Ev_newSession ¶
type Ev_newSession struct {
Host string
}
type EventDispatcher ¶ added in v1.0.1
func NewActorEvent ¶ added in v1.0.1
func NewActorEvent(s *ActorSystem) *EventDispatcher
func (*EventDispatcher) CancelAll ¶ added in v1.0.1
func (ed *EventDispatcher) CancelAll(actorId string)
取消actor事件
func (*EventDispatcher) CancelEvent ¶ added in v1.0.1
func (ed *EventDispatcher) CancelEvent(actorId string, events ...interface{}) error
取消actor事件
func (*EventDispatcher) DispatchEvent ¶ added in v1.0.1
func (ed *EventDispatcher) DispatchEvent(sourceId string, event interface{}) error
事件触发
func (*EventDispatcher) RegistEvent ¶ added in v1.0.1
func (ed *EventDispatcher) RegistEvent(actorId string, events ...interface{}) error
注册actor事件
type IActor ¶
type IActor interface { //core GetID() string ActorSystem() *ActorSystem LogicStop() //timer AddTimer(interval time.Duration, trigger_times int32, callback jtimer.FuncCallback) int64 CancelTimer(timerId int64) //lua CallLua(name string, ret int, args ...lua.LValue) []lua.LValue // Send 不保证消息发送可靠性,如果需要超时处理用 Request Send(targetId string, msg interface{}) Request(targetId string, msg interface{}, timeout ...time.Duration) (req *request) RequestWait(targetId string, msg interface{}, timeout ...time.Duration) (result interface{}, err error) Response(requestId string, msg interface{}) error //cmd RegistCmd(cmd string, fn func(...string)) }
type IActorHandler ¶
type IActorHandler interface { Init() Stop() (immediatelyStop bool) // true 立刻停止,false 延迟停止 HandleEvent(event interface{}) //事件消息 HandleMessage(sourceId, targetId string, msg interface{}) //普通消息(只管发送) HandleRequest(sourceId, targetId, requestId string, msg interface{}) (respErr error) //请求消息(需要应答) // contains filtered or unexported methods }
actor 处理接口
type ICmd ¶
type ICmd interface { Start(actorSystem *ActorSystem) RegistCmd(actorId, cmd string, f func(...string)) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.