func (t *Topic) AggregateChannelE2eProcessingLatency() *util.Quantile { var latencyStream *util.Quantile for _, c := range t.channelMap { if c.e2eProcessingLatencyStream == nil { continue } if latencyStream == nil { latencyStream = util.NewQuantile( t.ctx.nsqd.opts.E2EProcessingLatencyWindowTime, t.ctx.nsqd.opts.E2EProcessingLatencyPercentiles) } latencyStream.Merge(c.e2eProcessingLatencyStream) } return latencyStream }
// NewChannel creates a new instance of the Channel type and returns a pointer func NewChannel(topicName string, channelName string, ctx *context, deleteCallback func(*Channel)) *Channel { c := &Channel{ topicName: topicName, name: channelName, incomingMsgChan: make(chan *Message, 1), memoryMsgChan: make(chan *Message, ctx.nsqd.opts.MemQueueSize), clientMsgChan: make(chan *Message), exitChan: make(chan int), clients: make(map[int64]Consumer), deleteCallback: deleteCallback, ctx: ctx, } if len(ctx.nsqd.opts.E2EProcessingLatencyPercentiles) > 0 { c.e2eProcessingLatencyStream = util.NewQuantile( ctx.nsqd.opts.E2EProcessingLatencyWindowTime, ctx.nsqd.opts.E2EProcessingLatencyPercentiles, ) } c.initPQ() if strings.HasSuffix(channelName, "#ephemeral") { c.ephemeralChannel = true c.backend = newDummyBackendQueue() } else { // backend names, for uniqueness, automatically include the topic... backendName := getBackendName(topicName, channelName) c.backend = newDiskQueue(backendName, ctx.nsqd.opts.DataPath, ctx.nsqd.opts.MaxBytesPerFile, ctx.nsqd.opts.SyncEvery, ctx.nsqd.opts.SyncTimeout, ctx.nsqd.opts.Logger) } go c.messagePump() c.waitGroup.Wrap(func() { c.router() }) c.waitGroup.Wrap(func() { c.deferredWorker() }) c.waitGroup.Wrap(func() { c.inFlightWorker() }) go c.ctx.nsqd.Notify(c) return c }