本文整理匯總了Golang中github.com/kandoo/beehive.Msg.NoReply方法的典型用法代碼示例。如果您正苦於以下問題:Golang Msg.NoReply方法的具體用法?Golang Msg.NoReply怎麽用?Golang Msg.NoReply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kandoo/beehive.Msg
的用法示例。
在下文中一共展示了Msg.NoReply方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Rcv
func (d *Driver) Rcv(m beehive.Msg, ctx beehive.RcvContext) error {
if m.NoReply() {
return nil
}
q, ok := m.Data().(StatQuery)
if !ok {
return nil
}
s, ok := d.switches[q.Switch]
if !ok {
return fmt.Errorf("No switch stored in the driver: %+v", s)
}
for i, f := range s.Flows {
f.Bytes += uint64(rand.Intn(maxSpike))
s.Flows[i] = f
glog.V(2).Infof("Emitting stat result for %+v", f)
ctx.Emit(StatResult{q, f.Flow, f.Bytes})
}
d.switches[q.Switch] = s
return nil
}
示例2: Rcv
func (h *UpdateHandler) Rcv(m beehive.Msg, ctx beehive.RcvContext) error {
if m.NoReply() {
return nil
}
u := m.Data().(MatrixUpdate)
glog.Infof("Received matrix update: %+v", u)
ctx.Emit(FlowMod{Switch: u.Switch})
return nil
}
示例3: Rcv
func (p *pinger) Rcv(msg bh.Msg, ctx bh.RcvContext) error {
dict := ctx.Dict(PingPongDict)
data := msg.Data()
switch data := data.(type) {
case ping:
fmt.Printf("Rx Ping %d %v->%v\n", data.Seq, msg.From(), ctx.ID())
time.Sleep(300 * time.Millisecond)
v, err := dict.Get("ping")
var p ping
if err == nil {
p = v.(ping)
}
if data != p {
return fmt.Errorf("Invalid ping: ping=%d, want=%d", data.Seq, p.Seq)
}
p.Seq += 1
dict.Put("ping", p)
fmt.Printf("Ping stored to %v\n", p.Seq)
if !msg.NoReply() {
fmt.Printf("Tx Pong %d @ %v\n", data.pong().Seq, ctx.ID())
ctx.Emit(data.pong())
}
case pong:
fmt.Printf("Rx Pong %d %v->%v\n", data.Seq, msg.From(), ctx.ID())
time.Sleep(300 * time.Millisecond)
dict := ctx.Dict(PingPongDict)
v, err := dict.Get("pong")
var p pong
if err == nil {
p = v.(pong)
}
if data != p {
return fmt.Errorf("Invalid pong: pong=%d, want=%d", data.Seq, p.Seq)
}
p.Seq += 1
dict.Put("pong", p)
fmt.Printf("Pong stored to %v\n", p.Seq)
fmt.Printf("Tx Ping %d @ %v\n", data.ping().Seq, ctx.ID())
ctx.Emit(data.ping())
}
return nil
}
示例4: Rcv
func (s *SwitchJoinHandler) Rcv(m beehive.Msg, ctx beehive.RcvContext) error {
if m.NoReply() {
return nil
}
joined := m.Data().(SwitchJoined)
matrix := ctx.Dict(matrixDict)
key := joined.Switch.Key()
_, err := matrix.Get(key)
if err != nil {
return fmt.Errorf("Switch already exists in matrix: %+v", joined)
}
sw := make(SwitchStats)
matrix.Put(key, sw)
s.poller.query <- StatQuery{joined.Switch}
glog.Infof("Switch joined: %+v", joined)
return nil
}