MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Pop

Method Pop

pkg/telemetry/exporter/task_queue.go:126–143  ·  view source on GitHub ↗

Pop pops the most recent task in the schedule, for which timestamp is in range [0, time.Now()], the value of the queue goes through the registered callback and determines which one should be called.

(ctx context.Context, consumerID string)

Source from the content-addressed store, hash-verified

124// Pop pops the most recent task in the schedule, for which timestamp is in range [0, time.Now()], the value of
125// the queue goes through the registered callback and determines which one should be called.
126func (q *RedisTaskQueue) Pop(ctx context.Context, consumerID string) error {
127 return q.queue.Pop(
128 ctx, consumerID, nil, func(p redis.Pipeliner, id string, t time.Time) error {
129 v, ok := q.callbacks.Load(id)
130 if !ok {
131 return errCallbackNotRegistered.WithAttributes("id", id)
132 }
133
134 tt, err := v.(TaskCallback)(ctx)
135 if err != nil {
136 log.FromContext(ctx).WithError(err).WithField("id", id).Warn("Failed to execute task from queue")
137 return q.Add(ctx, id, tt, false)
138 }
139
140 return q.Add(ctx, id, tt, false)
141 },
142 )
143}

Callers 1

TestConcurrentTaskSetFunction · 0.95

Calls 8

AddMethod · 0.95
FromContextFunction · 0.92
PopMethod · 0.65
WarnMethod · 0.65
WithFieldMethod · 0.65
WithErrorMethod · 0.65
LoadMethod · 0.45
WithAttributesMethod · 0.45

Tested by 1

TestConcurrentTaskSetFunction · 0.76