Documentation
¶
Overview ¶
Package postgres provides PostgreSQL persistence for the SENTINEL SOC.
Uses pgx/v5 driver (pure Go, no CGO) with connection pooling. Migrations managed by goose.
Index ¶
- type DB
- type SOCRepo
- func (r *SOCRepo) CountEvents(tenantID string) (int, error)
- func (r *SOCRepo) CountEventsSince(tenantID string, since time.Time) (int, error)
- func (r *SOCRepo) CountOpenIncidents(tenantID string) (int, error)
- func (r *SOCRepo) CountSensorsByStatus(tenantID string) (map[soc.SensorStatus]int, error)
- func (r *SOCRepo) EventExistsByHash(contentHash string) (bool, error)
- func (r *SOCRepo) GetEvent(id string) (*soc.SOCEvent, error)
- func (r *SOCRepo) GetIncident(id string) (*soc.Incident, error)
- func (r *SOCRepo) GetSensor(id string) (*soc.Sensor, error)
- func (r *SOCRepo) InsertEvent(e soc.SOCEvent) error
- func (r *SOCRepo) InsertIncident(inc soc.Incident) error
- func (r *SOCRepo) ListEvents(tenantID string, limit int) ([]soc.SOCEvent, error)
- func (r *SOCRepo) ListEventsByCategory(tenantID string, category string, limit int) ([]soc.SOCEvent, error)
- func (r *SOCRepo) ListIncidents(tenantID string, status string, limit int) ([]soc.Incident, error)
- func (r *SOCRepo) ListSensors(tenantID string) ([]soc.Sensor, error)
- func (r *SOCRepo) PurgeExpiredEvents(retentionDays int) (int64, error)
- func (r *SOCRepo) PurgeExpiredIncidents(retentionDays int) (int64, error)
- func (r *SOCRepo) UpdateIncident(inc *soc.Incident) error
- func (r *SOCRepo) UpdateIncidentStatus(id string, status soc.IncidentStatus) error
- func (r *SOCRepo) UpsertSensor(s soc.Sensor) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a PostgreSQL connection pool.
type SOCRepo ¶
type SOCRepo struct {
// contains filtered or unexported fields
}
SOCRepo provides PostgreSQL persistence for SOC events, incidents, and sensors. Implements domain/soc.SOCRepository.
func NewSOCRepo ¶
NewSOCRepo creates a PostgreSQL-backed SOC repository. Unlike SQLite, tables are created via goose migrations (not inline DDL).
func (*SOCRepo) CountEvents ¶
CountEvents returns total event count.
func (*SOCRepo) CountEventsSince ¶
CountEventsSince returns events in the given time window.
func (*SOCRepo) CountOpenIncidents ¶
CountOpenIncidents returns count of non-resolved incidents.
func (*SOCRepo) CountSensorsByStatus ¶
CountSensorsByStatus returns sensor count grouped by status.
func (*SOCRepo) EventExistsByHash ¶
EventExistsByHash checks if an event with the given content hash already exists (§5.2 dedup).
func (*SOCRepo) GetIncident ¶
GetIncident retrieves an incident by ID.
func (*SOCRepo) InsertEvent ¶
InsertEvent persists a SOC event.
func (*SOCRepo) InsertIncident ¶
InsertIncident persists a new incident.
func (*SOCRepo) ListEvents ¶
ListEvents returns events ordered by timestamp (newest first), with limit.
func (*SOCRepo) ListEventsByCategory ¶
func (r *SOCRepo) ListEventsByCategory(tenantID string, category string, limit int) ([]soc.SOCEvent, error)
ListEventsByCategory returns events filtered by category.
func (*SOCRepo) ListIncidents ¶
ListIncidents returns incidents, optionally filtered by status.
func (*SOCRepo) ListSensors ¶
ListSensors returns all registered sensors.
func (*SOCRepo) PurgeExpiredEvents ¶
PurgeExpiredEvents deletes events older than the retention period.
func (*SOCRepo) PurgeExpiredIncidents ¶
PurgeExpiredIncidents deletes resolved incidents older than the retention period.
func (*SOCRepo) UpdateIncident ¶
UpdateIncident persists full incident state (case management).
func (*SOCRepo) UpdateIncidentStatus ¶
func (r *SOCRepo) UpdateIncidentStatus(id string, status soc.IncidentStatus) error
UpdateIncidentStatus updates status (and optionally resolved_at).