Documentation
¶
Index ¶
- func PublishLicenseEvent(pub *Publisher) ...
- func PublishPersonEvent(pub *Publisher) func(c *gin.Context, id string, revision int, action string, data vo.PersonVO)
- func PublishPublisherEvent(pub *Publisher) ...
- func PublishStudioEvent(pub *Publisher) func(c *gin.Context, id string, revision int, action string, data vo.StudioVO)
- type Consumer
- type Envelope
- type Publisher
- func (p *Publisher) Close()
- func (p *Publisher) PublishEntityCreated(ctx context.Context, entityType, entityID string, revision int, ...)
- func (p *Publisher) PublishEntityDeleted(ctx context.Context, entityType, entityID string)
- func (p *Publisher) PublishEntityUpdated(ctx context.Context, entityType, entityID string, revision int, ...)
- type SystemUpdateHandler
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.
Types ¶
type Consumer ¶ added in v0.29.0
type Consumer struct {
// contains filtered or unexported fields
}
Consumer binds catalog-api's durable pull consumer on the game-systems events stream and dispatches system.updated events to a handler.
func NewConsumer ¶ added in v0.29.0
NewConsumer builds a Consumer from the environment (same NATS_URL / NATS_CREDS / NATS_USER+NATS_PASSWORD scheme as the publisher). Returns (nil, nil) when NATS_URL is unset so the caller treats sync as disabled rather than a startup error.
func (*Consumer) Start ¶ added in v0.29.0
func (c *Consumer) Start(ctx context.Context, handle SystemUpdateHandler) error
Start binds the durable (declared as a NACK CRD in sweetrpg/infrastructure; created here as a fallback for local runs without NACK) and begins delivering events to handle in the background. It returns once the subscription is established.
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 ¶
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) 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 ¶
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).