addTask adds a task identified by payload with timestamp startAt to the stream at InputTaskKey(k). maxLen is the approximate length of the stream, to which it may be trimmed.
(ctx context.Context, r redis.Cmdable, k string, maxLen int64, payload string, startAt time.Time, replace bool)
| 451 | // addTask adds a task identified by payload with timestamp startAt to the stream at InputTaskKey(k). |
| 452 | // maxLen is the approximate length of the stream, to which it may be trimmed. |
| 453 | func addTask(ctx context.Context, r redis.Cmdable, k string, maxLen int64, payload string, startAt time.Time, replace bool) error { |
| 454 | m := make(map[string]any, 2) |
| 455 | m[payloadKey] = payload |
| 456 | if replace { |
| 457 | m[replaceKey] = replace |
| 458 | } |
| 459 | if !startAt.IsZero() { |
| 460 | m[startAtKey] = startAt.UnixNano() |
| 461 | } |
| 462 | return ConvertError(r.XAdd(ctx, &redis.XAddArgs{ |
| 463 | Stream: InputTaskKey(k), |
| 464 | MaxLen: maxLen, |
| 465 | Approx: true, |
| 466 | Values: m, |
| 467 | }).Err()) |
| 468 | } |
| 469 | |
| 470 | func parseTime(s string) (time.Time, error) { |
| 471 | nsec, err := strconv.ParseFloat(s, 64) |
no test coverage detected