queueIndexBatch enqueues a batch of items to be indexed in dependency order. This ensures that dependencies (e.g., balances) are indexed before the primary item (e.g., transaction). Uses the same IndexQueue but with a different task type for routing. Parameters: - batch interface{}: The batch conta
(batch interface{})
| 108 | // Returns: |
| 109 | // - error: An error if the task could not be enqueued. |
| 110 | func (q *Queue) queueIndexBatch(batch interface{}) error { |
| 111 | if q.config.TypeSense.Dns == "" { |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | payload, err := json.Marshal(batch) |
| 116 | if err != nil { |
| 117 | return err |
| 118 | } |
| 119 | |
| 120 | taskOptions := []asynq.Option{asynq.Queue(q.config.Queue.IndexQueue)} |
| 121 | task := asynq.NewTask("new:index:batch", payload, taskOptions...) |
| 122 | _, err = q.Client.Enqueue(task) |
| 123 | if err != nil { |
| 124 | logrus.WithError(err).Error("failed to enqueue index batch") |
| 125 | return err |
| 126 | } |
| 127 | logrus.Debug("successfully enqueued index batch") |
| 128 | return nil |
| 129 | } |
| 130 | |
| 131 | // queueIndexData enqueues a task to index data in a specified collection. |
| 132 | // |
no test coverage detected