本文整理匯總了Golang中github.com/hashicorp/memberlist.TransmitLimitedQueue類的典型用法代碼示例。如果您正苦於以下問題:Golang TransmitLimitedQueue類的具體用法?Golang TransmitLimitedQueue怎麽用?Golang TransmitLimitedQueue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TransmitLimitedQueue類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkQueueDepth
// checkQueueDepth periodically checks the size of a queue to see if
// it is too large
func (s *Serf) checkQueueDepth(limit int, name string, queue *memberlist.TransmitLimitedQueue, shutdownCh chan struct{}) {
for {
select {
case <-time.After(time.Second):
numq := queue.NumQueued()
if numq >= limit {
s.logger.Printf("[WARN] %s queue depth: %d", name, numq)
}
case <-shutdownCh:
return
}
}
}
示例2: sendTableEvent
func (nDB *NetworkDB) sendTableEvent(event TableEvent_Type, nid string, tname string, key string, entry *entry) error {
tEvent := TableEvent{
Type: event,
LTime: entry.ltime,
NodeName: nDB.config.NodeName,
NetworkID: nid,
TableName: tname,
Key: key,
Value: entry.value,
}
raw, err := encodeMessage(MessageTypeTableEvent, &tEvent)
if err != nil {
return err
}
var broadcastQ *memberlist.TransmitLimitedQueue
nDB.RLock()
thisNodeNetworks, ok := nDB.networks[nDB.config.NodeName]
if ok {
// The network may have been removed
network, networkOk := thisNodeNetworks[nid]
if !networkOk {
nDB.RUnlock()
return nil
}
broadcastQ = network.tableBroadcasts
}
nDB.RUnlock()
// The network may have been removed
if broadcastQ == nil {
return nil
}
broadcastQ.QueueBroadcast(&tableEventMessage{
msg: raw,
id: nid,
tname: tname,
key: key,
node: nDB.config.NodeName,
})
return nil
}
示例3: checkQueueDepth
// checkQueueDepth periodically checks the size of a queue to see if
// it is too large
func (s *Serf) checkQueueDepth(name string, queue *memberlist.TransmitLimitedQueue) {
for {
select {
case <-time.After(time.Second):
numq := queue.NumQueued()
if numq >= s.config.QueueDepthWarning {
s.logger.Printf("[WARN] %s queue depth: %d", name, numq)
}
if numq > s.config.MaxQueueDepth {
s.logger.Printf("[WARN] %s queue depth (%d) exceeds limit (%d), dropping messages!",
name, numq, s.config.MaxQueueDepth)
queue.Prune(s.config.MaxQueueDepth)
}
case <-s.shutdownCh:
return
}
}
}