Documentation
¶
Index ¶
Constants ¶
const TaskTypeCollectionEvent = "events:collection"
Using a constant prevents typos between the producer and the consumer.
Variables ¶
This section is empty.
Functions ¶
func EnqueueCollectionEvent ¶
func EnqueueCollectionEvent(ctx context.Context, client *asynq.Client, payload CollectionEventPayload) error
EnqueueCollectionEvent creates and enqueues a new generic collection event. When no queue client is configured (e.g. in tests or a deployment without Redis), the event is dropped with a debug log instead of panicking.
Types ¶
type CollectionEventPayload ¶
type CollectionEventPayload struct {
EventType EventType `json:"event_type"`
CollectionName string `json:"collection_name"`
ItemID uint `json:"item_id"`
ItemData map[string]any `json:"item_data"` // The full data of the item
}
CollectionEventPayload is the generic data structure for a collection event. This is sent from the storage layer to the dispatcher worker.
type EventType ¶
type EventType string
EventType defines the type of collection event that occurred.
const ( EventTypeCollectionCreated EventType = "collection:created" EventTypeCollectionUpdated EventType = "collection:updated" EventTypeCollectionDeleted EventType = "collection:deleted" EventTypeItemCreated EventType = "item:created" EventTypeItemUpdated EventType = "item:updated" EventTypeItemDeleted EventType = "item:deleted" )