Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB interface {
// Query executes a SQL statement and returns the result rows as a slice of maps.
Query(ctx context.Context, sql string, params ...any) ([]map[string]any, error)
// Exec executes a SQL statement that produces no result rows.
Exec(ctx context.Context, sql string, params ...any) error
// Ping verifies the underlying connection is reachable.
Ping(ctx context.Context) error
}
DB abstracts data access so that the application can swap between Dapr binding (production) and a direct pgx pool (tests) transparently.
type DaprDB ¶
type DaprDB struct {
// contains filtered or unexported fields
}
DaprDB executes SQL via a Dapr PostgreSQL output binding. The binding reads its connection string from a K8s Secret managed by ESO, so credential rotation is transparent to the application.
func (*DaprDB) Exec ¶
Exec executes a SQL statement that produces no result rows. Use this for INSERT/UPDATE/DELETE without RETURNING.
func (*DaprDB) Ping ¶
Ping verifies the binding is reachable by executing a trivial statement. Uses exec (not query) to avoid JSON parsing overhead on a connectivity check.
func (*DaprDB) Query ¶
Query executes a SQL statement and returns the result rows as a slice of maps. Use this for SELECT statements and for INSERT/UPDATE … RETURNING.
The Dapr PostgreSQL binding v1 returns positional arrays [[val1, val2], ...]. To recover column names we wrap every query with json_agg(row_to_json(t))::text, which makes PostgreSQL serialise the result set as a single JSON text value. The binding then returns [[jsonText]] and we decode that inner JSON into []map[string]any — the same shape the rest of the codebase expects.