MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / queueInflightCommit

Method queueInflightCommit

queue.go:308–329  ·  view source on GitHub ↗

queueInflightCommit enqueues a task to handle inflight commit for a transaction. Parameters: - transactionID string: The ID of the transaction. - commitAt time.Time: The scheduled time to automatically commit the inflight transaction. Returns: - error: An error if the task could not be enqueued.

(transactionID string, commitAt time.Time)

Source from the content-addressed store, hash-verified

306// Returns:
307// - error: An error if the task could not be enqueued.
308func (q *Queue) queueInflightCommit(transactionID string, commitAt time.Time) error {
309 IPayload, err := json.Marshal(transactionID)
310 if err != nil {
311 return err
312 }
313
314 taskOptions := []asynq.Option{
315 asynq.TaskID(transactionID),
316 asynq.Queue(q.config.Queue.InflightCommitQueue),
317 asynq.ProcessIn(time.Until(commitAt)),
318 }
319
320 task := asynq.NewTask(q.config.Queue.InflightCommitQueue, IPayload, taskOptions...)
321 _, err = q.Client.Enqueue(task)
322 if err != nil {
323 logrus.WithError(err).WithField("transaction_id", transactionID).Error("failed to enqueue inflight commit")
324 return err
325 }
326
327 logrus.WithField("transaction_id", transactionID).Debug("successfully enqueued inflight commit")
328 return nil
329}
330
331// QueueInflightCommit schedules an automatic commit for an inflight transaction at the specified date.
332//

Callers 1

QueueInflightCommitMethod · 0.95

Calls 3

EnqueueMethod · 0.80
ErrorMethod · 0.45
DebugMethod · 0.45

Tested by

no test coverage detected