Documentation
¶
Overview ¶
Package postgres is the builtin Orchard provider for PostgreSQL.
It offers raw SQL (postgres_query, capturing the first returned row as outputs), bulk loading (postgres_copy), and typed, schema-checked postgres_insert / _update / _delete, shared with the other SQL providers through internal/sqlcrud.
Index ¶
- type Provider
- func (p *Provider) Close() error
- func (p *Provider) Configure(ctx context.Context, config map[string]cty.Value) error
- func (p *Provider) Execute(ctx context.Context, action string, attrs map[string]cty.Value) (map[string]cty.Value, error)
- func (p *Provider) ExecuteUndo(ctx context.Context, action string, attrs map[string]cty.Value, ...) (map[string]cty.Value, *provider.Invocation, error)
- func (p *Provider) PlanAction(ctx context.Context, action string, attrs map[string]cty.Value) (provider.Plan, error)
- func (p *Provider) PlanConfigure(_ context.Context, _ map[string]cty.Value, snap *snapshot.Snapshot) error
- func (p *Provider) PullSchema(ctx context.Context, opts provider.PullOptions) (*provider.Capture, error)
- func (p *Provider) Schema() protocol.ProviderSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the PostgreSQL provider implementation.
A zero Provider is valid but not yet usable — Configure must be called before Execute. Schema works on a zero Provider so the engine can validate scenarios against its action set before a database connection has been established.
func New ¶
func New() *Provider
New returns an unconfigured PostgreSQL provider. Schema is parsed once up front so that any error in the embedded schema.hcl fails loudly at binary startup rather than at first use.
func (*Provider) Close ¶
Close releases the underlying pgxpool. Safe to call on an unconfigured provider or to call multiple times.
func (*Provider) Configure ¶
Configure opens a connection pool using the dsn config attribute. The pool is lazily tested — pgxpool.New does not dial until first use — so Configure will succeed for syntactically-valid DSNs even if the server is unreachable. Execute surfaces the connection failure later, which is the right place for it.
func (*Provider) Execute ¶
func (p *Provider) Execute(ctx context.Context, action string, attrs map[string]cty.Value) (map[string]cty.Value, error)
Execute dispatches to the handler for the given action.
func (*Provider) ExecuteUndo ¶
func (p *Provider) ExecuteUndo(ctx context.Context, action string, attrs map[string]cty.Value, opts provider.InverseOptions) (map[string]cty.Value, *provider.Invocation, error)
ExecuteUndo runs an action like Execute and, for a typed action, also describes its automatic teardown: deleting an inserted row by its primary key, or restoring the previous values of rows an update changed.
func (*Provider) PlanAction ¶
func (p *Provider) PlanAction(ctx context.Context, action string, attrs map[string]cty.Value) (provider.Plan, error)
PlanAction checks a typed action before the run: against the live schema after Configure, or the snapshot during `orchard plan`.
func (*Provider) PlanConfigure ¶
func (p *Provider) PlanConfigure(_ context.Context, _ map[string]cty.Value, snap *snapshot.Snapshot) error
PlanConfigure loads the schema snapshot `orchard plan` checks typed actions against. Without one, typed actions go unchecked at plan time. It doesn't connect.
func (*Provider) PullSchema ¶
func (p *Provider) PullSchema(ctx context.Context, opts provider.PullOptions) (*provider.Capture, error)
PullSchema captures ordinary and partitioned tables (not views or partitions) in every non-system schema, or only opts.Schemas.
func (*Provider) Schema ¶
func (p *Provider) Schema() protocol.ProviderSchema
Schema returns the embedded provider schema.