MCPcopy Index your code
hub / github.com/devaccuracy/ledgerforge / Enqueue

Method Enqueue

queue.go:174–196  ·  view source on GitHub ↗

Enqueue enqueues a transaction to the Redis queue. Parameters: - ctx context.Context: The context for the operation. - transaction *model.Transaction: The transaction to be enqueued. Returns: - error: An error if the transaction could not be enqueued.

(ctx context.Context, transaction *model.Transaction)

Source from the content-addressed store, hash-verified

172// Returns:
173// - error: An error if the transaction could not be enqueued.
174func (q *Queue) Enqueue(ctx context.Context, transaction *model.Transaction) error {
175 ctx, span := tracer.Start(ctx, "Adding Transaction To Redis Queue")
176 defer span.End()
177
178 payload, err := json.Marshal(transaction)
179 if err != nil {
180 return err
181 }
182 task := q.geTask(transaction, payload)
183 _, err = q.Client.EnqueueContext(ctx, task, asynq.MaxRetry(q.config.Queue.MaxRetryAttempts))
184 if err != nil {
185 logrus.WithError(err).WithField("reference", transaction.Reference).Error("failed to enqueue transaction")
186 return err
187 }
188 logrus.WithField("reference", transaction.Reference).Debug("successfully enqueued transaction")
189
190 // Record enqueue metrics.
191 metrics.QueueEnqueuedTotal.Add(ctx, 1,
192 otelmetric.WithAttributes(attribute.String("queue_name", task.Type())),
193 )
194
195 return nil
196}
197
198// QueueInflightExpiry handles queuing a transaction for inflight expiration.
199// This method is separate from the main Enqueue to ensure expiration is handled

Callers 10

SendWebhookMethod · 0.80
enqueueTransactionsFunction · 0.80
queueInflightExpiryMethod · 0.80
queueIndexBatchMethod · 0.80
queueIndexDataMethod · 0.80
queueInflightCommitMethod · 0.80
sendHeartbeatFunction · 0.80

Calls 4

geTaskMethod · 0.95
StartMethod · 0.45
ErrorMethod · 0.45
DebugMethod · 0.45