events

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublishLicenseEvent

func PublishLicenseEvent(pub *Publisher) func(c *gin.Context, id string, revision int, action string, data vo.LicenseVO)

PublishLicenseEvent publishes a license entity event.

func PublishPersonEvent

func PublishPersonEvent(pub *Publisher) func(c *gin.Context, id string, revision int, action string, data vo.PersonVO)

PublishPersonEvent publishes a person entity event.

func PublishPublisherEvent

func PublishPublisherEvent(pub *Publisher) func(c *gin.Context, id string, revision int, action string, data vo.PublisherVO)

PublishPublisherEvent publishes a publisher entity event.

func PublishStudioEvent

func PublishStudioEvent(pub *Publisher) func(c *gin.Context, id string, revision int, action string, data vo.StudioVO)

PublishStudioEvent publishes a studio entity event.

Types

type Envelope

type Envelope struct {
	EventID    string          `json:"event_id"`
	OccurredAt string          `json:"occurred_at"`
	Source     string          `json:"source"`
	EntityType string          `json:"entity_type"`
	EntityID   string          `json:"entity_id"`
	Action     string          `json:"action"`
	Revision   int             `json:"revision"`
	Data       json.RawMessage `json:"data"`
}

Envelope is the JSON event payload published to NATS JetStream. Fields: event_id (UUID string), occurred_at (RFC3339), source ("catalog-api"), entity_type, entity_id, action, revision (entity's post-change version, 0 for delete), data (object; for volume.updated include at least the current title; may be empty for delete).

func NewEnvelope

func NewEnvelope(eventID, entityType, entityID, action string, revision int, data interface{}) (*Envelope, error)

NewEnvelope creates a new event envelope with all required fields. eventID should be a UUID string, occurredAt is RFC3339 formatted, revision is the entity's post-change version (0 for delete), and data is arbitrary JSON (may be null).

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

Publisher publishes entity-change events to NATS JetStream.

func NewPublisher

func NewPublisher(ctx context.Context) (*Publisher, error)

NewPublisher creates a new NATS JetStream publisher from environment configuration. NATS_URL: NATS server URL (e.g., "nats://localhost:4222") NATS_CREDS: path to credentials file (optional, empty/unset for no-auth) PUBLISH_TIMEOUT_MS: milliseconds to wait for publish (default 3000)

func (*Publisher) Close

func (p *Publisher) Close()

Close closes the NATS connection.

func (*Publisher) PublishEntityCreated

func (p *Publisher) PublishEntityCreated(ctx context.Context, entityType, entityID string, revision int, data interface{})

PublishEntityCreated publishes a created event for an entity. data is the entity's current state.

func (*Publisher) PublishEntityDeleted

func (p *Publisher) PublishEntityDeleted(ctx context.Context, entityType, entityID string)

PublishEntityDeleted publishes a deleted event for an entity. revision is 0 for delete, data may be empty.

func (*Publisher) PublishEntityUpdated

func (p *Publisher) PublishEntityUpdated(ctx context.Context, entityType, entityID string, revision int, data interface{})

PublishEntityUpdated publishes an updated event for an entity. data is the entity's current state (for volume.updated must include title).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL