本文整理汇总了Golang中github.com/cockroachdb/cockroach/util.Subscription类的典型用法代码示例。如果您正苦于以下问题:Golang Subscription类的具体用法?Golang Subscription怎么用?Golang Subscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Subscription类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: readEvents
func (ser *storeEventReader) readEvents(sub *util.Subscription) {
ser.perStoreFeeds = make(map[proto.StoreID][]string)
ser.perStoreUpdateCount = make(map[proto.StoreID]map[proto.Method]int)
for e := range sub.Events() {
ser.recordEvent(e)
}
}
示例2: ProcessStoreEvents
// ProcessStoreEvents reads store events from the supplied channel and passes
// them to the correct methods of the supplied StoreEventListener. This method
// will run until the Subscription's events channel is closed.
func ProcessStoreEvents(l StoreEventListener, sub *util.Subscription) {
for event := range sub.Events() {
// TODO(tamird): https://github.com/barakmich/go-nyet/issues/7
switch specificEvent := event.(type) {
case *StartStoreEvent:
l.OnStartStore(specificEvent)
case *RegisterRangeEvent:
l.OnRegisterRange(specificEvent)
case *UpdateRangeEvent:
l.OnUpdateRange(specificEvent)
case *RemoveRangeEvent:
l.OnRemoveRange(specificEvent)
case *SplitRangeEvent:
l.OnSplitRange(specificEvent)
case *MergeRangeEvent:
l.OnMergeRange(specificEvent)
case *BeginScanRangesEvent:
l.OnBeginScanRanges(specificEvent)
case *EndScanRangesEvent:
l.OnEndScanRanges(specificEvent)
case *StoreStatusEvent:
l.OnStoreStatus(specificEvent)
case *ReplicationStatusEvent:
l.OnReplicationStatus(specificEvent)
}
}
}
示例3: ProcessNodeEvents
// ProcessNodeEvents reads node events from the supplied channel and passes them
// to the correct methods of the supplied NodeEventListener. This method will
// run until the Subscription's events channel is closed.
func ProcessNodeEvents(l NodeEventListener, sub *util.Subscription) {
for event := range sub.Events() {
// TODO(tamird): https://github.com/barakmich/go-nyet/issues/7
switch specificEvent := event.(type) {
case *CallSuccessEvent:
l.OnCallSuccess(specificEvent)
case *CallErrorEvent:
l.OnCallError(specificEvent)
}
}
}
示例4: readEvents
func (ner *nodeEventReader) readEvents(sub *util.Subscription) {
ner.perNodeFeeds = make(map[proto.NodeID][]string)
for e := range sub.Events() {
ner.recordEvent(e)
}
}