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

Method queueIndexData

queue.go:140–164  ·  view source on GitHub ↗

queueIndexData enqueues a task to index data in a specified collection. Parameters: - id string: The ID of the data to index. - collection string: The name of the collection to index the data in. - data interface{}: The data to be indexed. Returns: - error: An error if the task could not be enqueu

(id string, collection string, data interface{})

Source from the content-addressed store, hash-verified

138// Returns:
139// - error: An error if the task could not be enqueued.
140func (q *Queue) queueIndexData(id string, collection string, data interface{}) error {
141 if q.config.TypeSense.Dns == "" {
142 return nil
143 }
144
145 payload := map[string]interface{}{
146 "collection": collection,
147 "payload": data,
148 }
149
150 IPayload, err := json.Marshal(payload)
151 if err != nil {
152 return err
153 }
154
155 taskOptions := []asynq.Option{asynq.Queue(q.config.Queue.IndexQueue)}
156 task := asynq.NewTask(q.config.Queue.IndexQueue, IPayload, taskOptions...)
157 _, err = q.Client.Enqueue(task)
158 if err != nil {
159 logrus.WithError(err).WithField("id", id).Error("failed to enqueue index data")
160 return err
161 }
162 logrus.WithField("id", id).Debug("successfully enqueued index data")
163 return nil
164}
165
166// Enqueue enqueues a transaction to the Redis queue.
167//

Callers 5

UpdateMetadataMethod · 0.80
postIdentityActionsMethod · 0.80
postLedgerActionsMethod · 0.80
postBalanceActionsMethod · 0.80

Calls 3

EnqueueMethod · 0.80
ErrorMethod · 0.45
DebugMethod · 0.45

Tested by

no test coverage detected