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)
| 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. |
| 126 | func (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 | } |