database

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package database provides a connector that owns a database/sql connection pool. A sql block binds to it by name and runs statements through its DB(); the connector opens the pool on Start and closes it on Stop. One connector type serves both flavors, selected by the "driver" setting: "postgres" (jackc/pgx) or "sqlite" (modernc.org/sqlite). Both are pure Go, so no CGO toolchain is needed.

This file provides the "sql" block: a processor that runs a SQL statement against this database connector and folds the result into the message body. In query mode (the default) the body becomes an array of row objects, or a single object when "single" is set; in exec mode the body becomes {"rowsAffected": N}. Bind parameters come from CEL expressions evaluated against the message.

Placeholder style is the driver's own: $1, $2 for Postgres and ? for SQLite.

The block lives in the connector's package: importing the connector registers the block too, and it binds to the connector by concrete type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

Connector is a configured database connection pool that flows' sql blocks run statements through. The pool is opened on Start and closed on Stop; a *sql.DB is safe for concurrent use, matching the shared-connector contract.

func (*Connector) DB

func (c *Connector) DB() (*sql.DB, error)

DB returns the connection pool. It is the capability a sql block binds to by referencing this connector by name.

func (*Connector) Start

func (c *Connector) Start(ctx context.Context, config types.ConnectorConfig) error

Start parses the settings, opens the pool, applies tuning, and verifies the connection so a bad DSN fails fast at startup rather than on first query.

func (*Connector) Stop

func (c *Connector) Stop(context.Context) error

Stop closes the connection pool if one was opened.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL