mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-15 08:32:05 +00:00
feat(multiplayer): publish allocation state events
This commit is contained in:
@@ -42,6 +42,13 @@ WHERE published_at IS NULL AND event_type = 'match_completed'
|
||||
ORDER BY created_at, event_id
|
||||
LIMIT $1`
|
||||
|
||||
const OutboxUnpublishedStateSelectSQL = `SELECT event_id, aggregate_type, aggregate_id, revision,
|
||||
event_type, payload, created_at, published_at
|
||||
FROM outbox
|
||||
WHERE published_at IS NULL AND event_type = 'state_changed'
|
||||
ORDER BY created_at, event_id
|
||||
LIMIT $1`
|
||||
|
||||
const MatchParticipantIDsSQL = `SELECT player_id
|
||||
FROM match_participants
|
||||
WHERE match_id = $1
|
||||
@@ -125,6 +132,12 @@ func ReadUnpublishedResultOutbox(ctx context.Context, db *sql.DB, limit int) ([]
|
||||
return readUnpublishedOutbox(ctx, db, limit, OutboxUnpublishedResultSelectSQL)
|
||||
}
|
||||
|
||||
// ReadUnpublishedStateOutbox returns lifecycle state events, leaving proposal
|
||||
// and result rows to their dedicated consumers.
|
||||
func ReadUnpublishedStateOutbox(ctx context.Context, db *sql.DB, limit int) ([]OutboxEvent, error) {
|
||||
return readUnpublishedOutbox(ctx, db, limit, OutboxUnpublishedStateSelectSQL)
|
||||
}
|
||||
|
||||
func ReadMatchParticipantIDs(ctx context.Context, db *sql.DB, matchID string) ([]string, error) {
|
||||
if db == nil || matchID == "" {
|
||||
return nil, fmt.Errorf("invalid match participant read arguments")
|
||||
|
||||
Reference in New Issue
Block a user