Documentation
¶
Index ¶
Constants ¶
const QueueEvents = "events"
QueueEvents is the queue of collection events, processed by the dispatcher.
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 queue.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
// ItemTranslations holds localized values in other locales than the
// default, by locale.
ItemTranslations map[string]any `json:"item_translations,omitempty"`
// ActorKind and ActorName say who made the change (models.ActorUser,
// ActorAgent…): an agent is not triggered by its own changes.
ActorKind string `json:"actor_kind,omitempty"`
ActorName string `json:"actor_name,omitempty"`
}
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" // Draft-and-publish collections only: an item became visible to readers, // or was withdrawn. EventTypeItemPublished EventType = "item:published" EventTypeItemUnpublished EventType = "item:unpublished" // Singleton content events. Their CollectionName is // "singleton:<name>", like the singleton's permission key. EventTypeSingletonUpdated EventType = "singleton:updated" EventTypeSingletonDeleted EventType = "singleton:deleted" )