Documentation
¶
Overview ¶
Package event provides real-time change notifications via PG LISTEN/NOTIFY.
Architecture:
DB Trigger (INSERT/UPDATE/DELETE on key tables)
→ PG NOTIFY 'vipas_changes', '{"table":"apps","op":"UPDATE","id":"..."}'
→ Listener (pgdriver LISTEN)
→ Broadcast to all SSE clients
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
Table string `json:"table"` // e.g. "applications", "deployments"
Op string `json:"op"` // INSERT, UPDATE, DELETE
ID string `json:"id"` // row UUID
}
Change represents a single database row change captured by a PG trigger.
type PGSubscriber ¶
type PGSubscriber struct {
// contains filtered or unexported fields
}
PGSubscriber listens to PG NOTIFY on the vipas_changes channel and exposes a Go channel of Change events. It automatically reconnects if the database connection is lost.
func NewPGSubscriber ¶
NewPGSubscriber creates a subscriber that auto-reconnects on failure.
func (*PGSubscriber) Changes ¶
func (s *PGSubscriber) Changes() <-chan Change
Changes returns the channel of parsed change events.
type Subscriber ¶
type Subscriber interface {
// Changes returns a read-only channel of database change events.
// The channel is closed when the subscriber is stopped.
Changes() <-chan Change
// Close stops listening and releases the connection.
Close() error
}
Subscriber receives real-time change events from the database.
Click to show internal directories.
Click to hide internal directories.