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

Method Pop

pkg/redis/redis.go:680–686  ·  view source on GitHub ↗

Pop calls f on the most recent task in the queue, for which timestamp is in range [0, time.Now()], if such is available, otherwise it blocks until it is or context is done. Pipeline is executed even if f returns an error. consumerID is used to identify the consumer and should be unique for all concu

(ctx context.Context, consumerID string, r redis.Cmdable, f func(redis.Pipeliner, string, time.Time) error)

Source from the content-addressed store, hash-verified

678// Pipeline is executed even if f returns an error.
679// consumerID is used to identify the consumer and should be unique for all concurrent calls to Pop.
680func (q *TaskQueue) Pop(ctx context.Context, consumerID string, r redis.Cmdable, f func(redis.Pipeliner, string, time.Time) error) error {
681 q.consumerIDs.LoadOrStore(consumerID, struct{}{})
682 if r == nil {
683 r = q.Redis
684 }
685 return popTask(ctx, r, q.Group, consumerID, f, q.Key, q.StreamBlockLimit)
686}
687
688var deduplicateProtosScript = redis.NewScript(`local exp = table.remove(ARGV, 1)
689local limit = tonumber(table.remove(ARGV, 1))

Callers 1

TestTaskQueueFunction · 0.95

Implementers 2

mockTaskQueuepkg/telemetry/exporter/task_queue_test
RedisTaskQueuepkg/telemetry/exporter/task_queue.go

Calls 1

popTaskFunction · 0.85

Tested by 1

TestTaskQueueFunction · 0.76