本文整理汇总了Golang中github.com/kandoo/beehive.RcvContext.App方法的典型用法代码示例。如果您正苦于以下问题:Golang RcvContext.App方法的具体用法?Golang RcvContext.App怎么用?Golang RcvContext.App使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kandoo/beehive.RcvContext
的用法示例。
在下文中一共展示了RcvContext.App方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addFlowEntriesForPath
func addFlowEntriesForPath(sub bh.AppCellKey, path nom.Path,
flows []nom.FlowEntry, ctx bh.RcvContext) {
fs := make([]flowAndStatus, 0, len(flows))
path.ID = strconv.FormatUint(reservePathID(ctx), 16)
for i := range flows {
flows[i].ID = path.ID
fs = append(fs, flowAndStatus{Flow: flows[i]})
}
pf := pathAndFlows{
Subscriber: sub,
Path: path,
Flows: fs,
Timestamp: time.Now(),
}
d := ctx.Dict(dictPath)
if err := d.Put(path.ID, pf); err != nil {
glog.Fatalf("error in storing path entry: %v", err)
}
ack := centralizedAppCellKey(ctx.App())
for _, f := range flows {
addf := nom.AddFlowEntry{
Flow: f,
Subscriber: ack,
}
ctx.Emit(addf)
}
}
示例2: Rcv
func (h *nodeJoinedHandler) Rcv(msg bh.Msg, ctx bh.RcvContext) error {
joined := msg.Data().(nom.NodeJoined)
d := ctx.Dict(nodeDict)
n := nom.Node(joined)
k := string(n.UID())
var np nodePortsAndLinks
if v, err := d.Get(k); err != nil {
glog.Warningf("%v rejoins", n)
} else {
np = v.(nodePortsAndLinks)
}
np.N = n
// Add a flow entry to forward arp packets to the controller
mt := nom.Match{}
mt.AddField(nom.EthType(nom.EthTypeARP))
acs := []nom.Action{
nom.ActionSendToController{
MaxLen: 0xffff,
},
}
fe := nom.FlowEntry{
ID: "Discovery-Host-ARP",
Node: n.UID(),
Priority: 0,
Match: mt,
Actions: acs,
}
afe := nom.AddFlowEntry{
Flow: fe,
Subscriber: bh.AppCellKey{
App: ctx.App(),
Key: k,
Dict: nodeDict,
},
}
ctx.Emit(afe)
// Add a flow entry to forward lldp packets to the controller
mt = nom.Match{}
mt.AddField(nom.EthType(nom.EthTypeLLDP))
acs = []nom.Action{
nom.ActionSendToController{
MaxLen: 0xffff,
},
}
fe = nom.FlowEntry{
ID: "Discovery-Topo-LLDP",
Node: n.UID(),
Priority: 0,
Match: mt,
Actions: acs,
}
afe = nom.AddFlowEntry{
Flow: fe,
Subscriber: bh.AppCellKey{
App: ctx.App(),
Key: k,
Dict: nodeDict,
},
}
ctx.Emit(afe)
return d.Put(k, np)
}