db

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package db contains the db node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConfig

type DBConfig struct {
	// DSN is a neat-style database DSN ("sqlite://file.db",
	// "postgres://user:pass@host/db", "mysql://user:pass@host/db").
	// Bare paths and ":memory:" are treated as SQLite DSNs.
	// "env:NAME" resolves the DSN from the scoped env chain.
	DSN string `json:"dsn"`
	// Operation is "query" (default) or "exec".
	Operation string `json:"operation"`
	// SQL is the statement with '?' bind placeholders (rebound to
	// the driver's native style). Values are never interpolated.
	SQL string `json:"sql"`
	// Params supplies bind values: a JSON array of literals, or a
	// string naming a dotted msg field path that resolves to an
	// array (e.g. "params", "payload.items", "msg.args"). Empty
	// falls back to an array at the message's "params" data field.
	Params interface{} `json:"params"`
	// Split emits one message per result row (query only).
	Split bool `json:"split"`
	// ReadOnly rejects exec operations at deploy time.
	ReadOnly bool `json:"readOnly"`
}

DBConfig holds the node.Data fields of a db node.

type DBNode

type DBNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

DBNode is the executor shell: Activate opens the pool, Execute runs one statement, Expand fans out rows in split mode, Stop closes.

func NewDBNode

func NewDBNode(node nodestore.NodeInterface, config *DBConfig, host nodebase.NodeHost) *DBNode

NewDBNode creates a new db node executor shell.

func (*DBNode) Activate

func (n *DBNode) Activate(ctx context.Context) error

Activate implements Activator: deploy opens the pooled connection and pings it, so an unparseable DSN or an unreachable database fails the deploy rather than the first message.

func (*DBNode) Execute

Execute runs the configured statement against the pool.

func (*DBNode) Expand

Expand implements MessageExpander: in split mode each result row becomes its own message (Data = the row object); an empty result set emits nothing. Non-split executions (and exec results) pass their single output through unchanged.

func (*DBNode) Stop

func (n *DBNode) Stop() error

Stop implements Stopper: closes the pooled handle. A subsequent Execute fails cleanly until the next Activate reopens it. Must not recreate host state — it may already be wiped.

func (*DBNode) StopKey

func (n *DBNode) StopKey() string

stopKey dedupes stopper registration: all executor shells of one node share the same pool.

func (*DBNode) Validate

func (n *DBNode) Validate() error

Validate checks config at deploy time: dsn and sql are required, operation must be known, readOnly rejects exec.

Jump to

Keyboard shortcuts

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