Documentation
¶
Overview ¶
Package db contains the db node implementation.
Index ¶
- type DBConfig
- type DBNode
- func (n *DBNode) Activate(ctx context.Context) error
- func (n *DBNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
- func (n *DBNode) Expand(output nodestore.MessageInterface) []nodestore.MessageInterface
- func (n *DBNode) Stop() error
- func (n *DBNode) StopKey() string
- func (n *DBNode) Validate() error
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 ¶
DBNode is the executor shell: Activate opens the pool, Execute runs one statement, Expand fans out rows in split mode, Stop closes.
func (*DBNode) Activate ¶
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 ¶
func (n *DBNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute runs the configured statement against the pool.
func (*DBNode) Expand ¶
func (n *DBNode) Expand(output nodestore.MessageInterface) []nodestore.MessageInterface
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 ¶
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.