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)
| 306 | // Returns: |
| 307 | // - error: An error if the task could not be enqueued. |
| 308 | func (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 | // |
no test coverage detected