geTask generates a task for a transaction and assigns it to a specific queue based on the balance ID. It ensures that transactions are evenly distributed across multiple queues by hashing the balance ID. This approach helps to avoid race conditions on a balance by ensuring that all transactions rela
(transaction *model.Transaction, payload []byte)
| 224 | // Returns: |
| 225 | // - *asynq.Task: The generated task ready to be enqueued. |
| 226 | func (q *Queue) geTask(transaction *model.Transaction, payload []byte) *asynq.Task { |
| 227 | queueName := q.transactionQueueName(transaction) |
| 228 | |
| 229 | taskOptions := []asynq.Option{asynq.TaskID(transaction.TransactionID), asynq.Queue(queueName)} |
| 230 | if !transaction.ScheduledFor.IsZero() { |
| 231 | taskOptions = append(taskOptions, asynq.ProcessIn(time.Until(transaction.ScheduledFor))) |
| 232 | } |
| 233 | |
| 234 | return asynq.NewTask(queueName, payload, taskOptions...) |
| 235 | } |
| 236 | |
| 237 | func (q *Queue) transactionQueueName(transaction *model.Transaction) string { |
| 238 | if q.config.Queue.EnableHotLane && transaction != nil && transaction.MetaData != nil { |
no test coverage detected