本文整理汇总了Golang中github.com/rogeralsing/gam/actor.Context类的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Receive
func (state *BecomeActor) Receive(context actor.Context) {
switch msg := context.Message().(type) {
case Hello:
fmt.Printf("Hello %v\n", msg.Who)
context.Become(state.Other)
}
}
开发者ID:yonglehou,项目名称:gam,代码行数:7,代码来源:main.go
示例2: sendEnvelopes
func (state *endpointWriter) sendEnvelopes(msg []interface{}, ctx actor.Context) {
envelopes := make([]*messages.MessageEnvelope, len(msg))
for i, tmp := range msg {
envelopes[i] = tmp.(*messages.MessageEnvelope)
}
batch := &messages.MessageBatch{
Envelopes: envelopes,
}
err := state.stream.Send(batch)
if err != nil {
ctx.Stash()
log.Println("Failed to send to host", state.host)
panic("restart")
}
}
开发者ID:yonglehou,项目名称:gam,代码行数:18,代码来源:endpointwriter.go
示例3: Receive
func (*remoteActor) Receive(context actor.Context) {
switch msg := context.Message().(type) {
case *messages.StartRemote:
log.Println("Starting")
msg.Sender.Tell(&messages.Start{})
case *messages.Ping:
msg.Sender.Tell(&messages.Pong{})
}
}
开发者ID:yonglehou,项目名称:gam,代码行数:9,代码来源:main.go
示例4: Receive
func (state *endpointWriter) Receive(ctx actor.Context) {
switch msg := ctx.Message().(type) {
case actor.Started:
state.initialize()
case actor.Stopped:
state.conn.Close()
case actor.Restarting:
state.conn.Close()
case []interface{}:
state.sendEnvelopes(msg, ctx)
default:
log.Fatal("Unknown message", msg)
}
}
开发者ID:yonglehou,项目名称:gam,代码行数:14,代码来源:endpointwriter.go
示例5: Receive
func (state *endpointManager) Receive(ctx actor.Context) {
switch msg := ctx.Message().(type) {
case actor.Started:
state.connections = make(map[string]*actor.PID)
log.Println("Started EndpointManager")
case *messages.MessageEnvelope:
pid, ok := state.connections[msg.Target.Host]
if !ok {
props := actor.
FromProducer(newEndpointWriter(msg.Target.Host, state.config)).
WithMailbox(newEndpointWriterMailbox(state.config.batchSize, 1000000))
pid = actor.Spawn(props)
state.connections[msg.Target.Host] = pid
}
pid.Tell(msg)
}
}
开发者ID:yonglehou,项目名称:gam,代码行数:17,代码来源:endpointmanager.go
示例6: Other
func (state *BecomeActor) Other(context actor.Context) {
switch msg := context.Message().(type) {
case Hello:
fmt.Printf("%v, ey we are now handling messages in another behavior", msg.Who)
}
}
开发者ID:yonglehou,项目名称:gam,代码行数:6,代码来源:main.go
注:本文中的github.com/rogeralsing/gam/actor.Context类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论