Second checkpoint

This commit is contained in:
2026-06-25 01:17:42 +05:00
parent 854ef138d0
commit 9cf791b789
90 changed files with 5504 additions and 988 deletions

View File

@@ -0,0 +1,26 @@
package postgres
import (
"context"
"encoding/json"
"github.com/jackc/pgx/v5/pgxpool"
)
// EventRepository records events for the generic example consumer. It is part of
// the messaging scaffold; remove it alongside the example flow.
type EventRepository struct {
pool *pgxpool.Pool
}
// NewEventRepository returns an EventRepository backed by the given pool.
func NewEventRepository(pool *pgxpool.Pool) *EventRepository {
return &EventRepository{pool: pool}
}
// Record inserts an event row. It satisfies rabbitmq.EventRecorder.
func (r *EventRepository) Record(ctx context.Context, kind string, payload json.RawMessage) error {
_, err := r.pool.Exec(ctx,
`INSERT INTO events (kind, payload) VALUES ($1, $2)`, kind, payload)
return mapError(err)
}