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

Function addTask

pkg/redis/redis.go:453–468  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
453func 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
470func parseTime(s string) (time.Time, error) {
471 nsec, err := strconv.ParseFloat(s, 64)

Callers 1

AddMethod · 0.85

Calls 4

ConvertErrorFunction · 0.85
InputTaskKeyFunction · 0.85
IsZeroMethod · 0.65
ErrMethod · 0.45

Tested by

no test coverage detected