postgresflex

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package postgresflex provides an in-memory mock of Microsoft.DBforPostgreSQL (Azure Database for PostgreSQL — Flexible Server). It implements relationaldb/driver.RelationalDB so the same backend serves both the portable API (relationaldb.DB) and the SDK-compat HTTP layer.

Postgres Flex has a flat resource model: each flexible server is a standalone managed Postgres instance — there is no Aurora-style cluster concept. The driver's Cluster*/ClusterSnapshot* methods therefore return InvalidArgument. Snapshots are exposed via the portable API only; there is no ARM endpoint for them in the MVP.

Lifecycle: Postgres Flex supports start/stop/restart natively. The mock tracks state transitions and emits Microsoft.DBforPostgreSQL/flexibleServers metrics on each transition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

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

Mock is the in-memory Azure Postgres Flex implementation.

func New

func New(opts *config.Options) *Mock

New creates a new Postgres Flex mock.

func (*Mock) CreateCluster

func (*Mock) CreateCluster(_ context.Context, _ rdsdriver.ClusterConfig) (*rdsdriver.Cluster, error)

CreateCluster is unsupported on Postgres Flex — there is no cluster concept.

func (*Mock) CreateClusterSnapshot

func (*Mock) CreateClusterSnapshot(
	_ context.Context, _ rdsdriver.ClusterSnapshotConfig,
) (*rdsdriver.ClusterSnapshot, error)

CreateClusterSnapshot is unsupported on Postgres Flex.

func (*Mock) CreateInstance

func (m *Mock) CreateInstance(_ context.Context, cfg rdsdriver.InstanceConfig) (*rdsdriver.Instance, error)

CreateInstance creates a new Postgres Flex flexible server.

func (*Mock) CreateSnapshot

func (m *Mock) CreateSnapshot(_ context.Context, cfg rdsdriver.SnapshotConfig) (*rdsdriver.Snapshot, error)

CreateSnapshot creates a synthetic backup of a flexible server. Real Postgres Flex backups are managed automatically; the portable API exposes them as snapshots so generic relationaldb consumers have a uniform snapshot/restore story.

func (*Mock) DeleteCluster

func (*Mock) DeleteCluster(_ context.Context, _ string) error

DeleteCluster is unsupported on Postgres Flex.

func (*Mock) DeleteClusterSnapshot

func (*Mock) DeleteClusterSnapshot(_ context.Context, _ string) error

DeleteClusterSnapshot is unsupported on Postgres Flex.

func (*Mock) DeleteInstance

func (m *Mock) DeleteInstance(_ context.Context, id string) error

DeleteInstance removes a flexible server.

func (*Mock) DeleteSnapshot

func (m *Mock) DeleteSnapshot(_ context.Context, id string) error

DeleteSnapshot removes a snapshot.

func (*Mock) DescribeClusterSnapshots

func (*Mock) DescribeClusterSnapshots(
	_ context.Context, _ []string, _ string,
) ([]rdsdriver.ClusterSnapshot, error)

DescribeClusterSnapshots returns an empty list — Postgres Flex has no clusters.

func (*Mock) DescribeClusters

func (*Mock) DescribeClusters(_ context.Context, _ []string) ([]rdsdriver.Cluster, error)

DescribeClusters returns an empty list — Postgres Flex has no clusters.

func (*Mock) DescribeInstances

func (m *Mock) DescribeInstances(_ context.Context, ids []string) ([]rdsdriver.Instance, error)

DescribeInstances returns all servers if ids is empty, else only matching ones.

func (*Mock) DescribeSnapshots

func (m *Mock) DescribeSnapshots(
	_ context.Context, ids []string, instanceID string,
) ([]rdsdriver.Snapshot, error)

DescribeSnapshots returns snapshots filtered by ids and/or instance.

func (*Mock) ModifyCluster

ModifyCluster is unsupported on Postgres Flex.

func (*Mock) ModifyInstance

func (m *Mock) ModifyInstance(
	_ context.Context, id string, input rdsdriver.ModifyInstanceInput,
) (*rdsdriver.Instance, error)

ModifyInstance applies the supplied changes.

func (*Mock) RebootInstance

func (m *Mock) RebootInstance(_ context.Context, id string) error

RebootInstance cycles a running server through restart.

func (*Mock) RestoreClusterFromSnapshot

func (*Mock) RestoreClusterFromSnapshot(
	_ context.Context, _ rdsdriver.RestoreClusterInput,
) (*rdsdriver.Cluster, error)

RestoreClusterFromSnapshot is unsupported on Postgres Flex.

func (*Mock) RestoreInstanceFromSnapshot

func (m *Mock) RestoreInstanceFromSnapshot(
	_ context.Context, input rdsdriver.RestoreInstanceInput,
) (*rdsdriver.Instance, error)

RestoreInstanceFromSnapshot creates a new flexible server from a snapshot.

func (*Mock) SetMonitoring

func (m *Mock) SetMonitoring(mon mondriver.Monitoring)

SetMonitoring wires an Azure-Monitor-style backend for auto-metric emission.

func (*Mock) StartCluster

func (*Mock) StartCluster(_ context.Context, _ string) error

StartCluster is unsupported on Postgres Flex.

func (*Mock) StartInstance

func (m *Mock) StartInstance(_ context.Context, id string) error

StartInstance moves a stopped server back to running.

func (*Mock) StopCluster

func (*Mock) StopCluster(_ context.Context, _ string) error

StopCluster is unsupported on Postgres Flex.

func (*Mock) StopInstance

func (m *Mock) StopInstance(_ context.Context, id string) error

StopInstance moves a running server to stopped.

Jump to

Keyboard shortcuts

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