database

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: PostgreSQL Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EtcdCaCertName     = "ca.crt"
	EtcdClientCertName = "client.crt"
	EtcdClientKeyName  = "client.key"
)
View Source
const (
	PostgresCaCertName         = "ca.crt"
	PostgresServerCertName     = "server.crt"
	PostgresServerKeyName      = "server.key"
	PostgresSuperuserCertName  = "superuser.crt"
	PostgresSuperuserKeyName   = "superuser.key"
	PostgresReplicatorCertName = "replication.crt"
	PostgresReplicatorKeyName  = "replication.key"
)
View Source
const (
	TargetSessionAttrsPrimary       = "primary"
	TargetSessionAttrsPreferStandby = "prefer-standby"
	TargetSessionAttrsStandby       = "standby"
	TargetSessionAttrsReadWrite     = "read-write"
	TargetSessionAttrsAny           = "any"
)

libpq target_session_attrs values (PG 14+). See: https://www.postgresql.org/docs/current/libpq-connect.html

View Source
const InstanceMonitorRefreshInterval = 5 * time.Second
View Source
const ResourceTypeDumpRoles resource.Type = "database.dump_roles"
View Source
const ResourceTypeInstance resource.Type = "database.instance"
View Source
const ResourceTypeLagTrackerCommitTS resource.Type = "database.lag_tracker_commit_ts"
View Source
const ResourceTypeNode resource.Type = "database.node"
View Source
const ResourceTypePostgresDatabase resource.Type = "database.postgres_database"
View Source
const ResourceTypeReplicationSlot resource.Type = "database.replication_slot"
View Source
const ResourceTypeReplicationSlotAdvanceFromCTS resource.Type = "database.replication_slot_advance_from_cts"
View Source
const ResourceTypeReplicationSlotCreate resource.Type = "database.replication_slot_create"
View Source
const ResourceTypeRolesSource resource.Type = "database.roles_source"
View Source
const ResourceTypeServiceInstance = "swarm.service_instance"

ResourceTypeServiceInstance is the resource type identifier for service instances. This constant is defined here to avoid import cycles between the orchestrator and workflow packages.

View Source
const ResourceTypeSubscription resource.Type = "database.subscription"
View Source
const ResourceTypeSwitchover resource.Type = "database.switchover"
View Source
const ResourceTypeSyncEvent resource.Type = "database.sync_event"
View Source
const ResourceTypeWaitForSyncEvent resource.Type = "database.wait_for_sync_event"
View Source
const ServiceInstanceMonitorRefreshInterval = 10 * time.Second
View Source
const VariableNameDatabaseNotCreated resource.VariableName = "database_not_created"

Variables

View Source
var (
	ErrDatabaseAlreadyExists   = errors.New("database already exists")
	ErrDatabaseNotFound        = errors.New("database not found")
	ErrDatabaseNotModifiable   = errors.New("database not modifiable")
	ErrInstanceNotFound        = errors.New("instance not found")
	ErrInstanceStopped         = errors.New("instance stopped")
	ErrInvalidDatabaseUpdate   = errors.New("invalid database update")
	ErrInvalidSourceNode       = errors.New("invalid source node")
	ErrServiceInstanceNotFound = errors.New("service instance not found")
)
View Source
var ErrNodeNotInDBSpec = errors.New("node not in db spec")

Functions

func ConnectToInstance

func ConnectToInstance(ctx context.Context, opts *ConnectionOptions) (*pgx.Conn, error)

func DatabaseStateModifiable

func DatabaseStateModifiable(state DatabaseState) bool

func DumpRolesResourceIdentifier added in v0.8.0

func DumpRolesResourceIdentifier(nodeName string) resource.Identifier

func ExecuteScript added in v0.8.0

func ExecuteScript(ctx context.Context, rc *resource.Context, conn *pgx.Conn, script *Script) error

func GenerateDatabaseNetworkID added in v0.7.0

func GenerateDatabaseNetworkID(databaseID string) string

GenerateDatabaseNetworkID creates the overlay network ID for a database. Format: {database_id}

func GenerateServiceInstanceID added in v0.7.0

func GenerateServiceInstanceID(databaseID, serviceID, hostID string) string

GenerateServiceInstanceID creates a unique ID for a service instance. Format: {database_id}-{service_id}-{host_id}

func GetPrimaryInstanceID

func GetPrimaryInstanceID(ctx context.Context, patroniClient *patroni.Client, timeout time.Duration) (string, error)

func InstanceIDFor

func InstanceIDFor(hostID, databaseID, nodeName string) string

func InstanceResourceIdentifier

func InstanceResourceIdentifier(instanceID string) resource.Identifier

func IsDatabaseNotCreated added in v0.8.0

func IsDatabaseNotCreated(rc *resource.Context) (bool, error)

func LagTrackerCommitTSIdentifier

func LagTrackerCommitTSIdentifier(originNode, receiverNode, databaseName string) resource.Identifier

func NodeResourceIdentifier

func NodeResourceIdentifier(nodeName string) resource.Identifier

func PostgresDatabaseResourceIdentifier added in v0.8.0

func PostgresDatabaseResourceIdentifier(nodeName, dbName string) resource.Identifier

func Provide

func Provide(i *do.Injector)

func RegisterResourceTypes

func RegisterResourceTypes(registry *resource.Registry)

func ReplicationSlotAdvanceFromCTSResourceIdentifier

func ReplicationSlotAdvanceFromCTSResourceIdentifier(providerNode, subscriberNode, databaseName string) resource.Identifier

ReplicationSlotAdvanceFromCTSResourceIdentifier creates a stable identifier for this resource.

func ReplicationSlotCreateResourceIdentifier

func ReplicationSlotCreateResourceIdentifier(databaseName, providerNode, subscriberNode string) resource.Identifier

func ReplicationSlotResourceIdentifier added in v0.7.0

func ReplicationSlotResourceIdentifier(providerNode, subscriberNode, databaseName string) resource.Identifier

func RolesSourceResourceIdentifier added in v0.8.0

func RolesSourceResourceIdentifier(nodeName string) resource.Identifier

func SanitizeRolesDump added in v0.8.0

func SanitizeRolesDump(in string) ([]string, []string)

func SetScriptNeedsToRun added in v0.8.0

func SetScriptNeedsToRun(ctx context.Context, rc *resource.Context, script *Script) error

func SubscriptionResourceIdentifier

func SubscriptionResourceIdentifier(providerNode, subscriberNode, databaseName string) resource.Identifier

func SwitchoverResourceIdentifier

func SwitchoverResourceIdentifier(nodeName string) resource.Identifier

func SyncEventResourceIdentifier

func SyncEventResourceIdentifier(providerNode, subscriberNode, databaseName string) resource.Identifier

func ValidateChangedSpec

func ValidateChangedSpec(current, updated *Spec) error

func WaitForPatroniRunning

func WaitForPatroniRunning(ctx context.Context, patroniClient *patroni.Client, timeout time.Duration) error

WaitForPatroniRunning polls the Patroni instance status endpoint until one of the following is true: - Patroni reports a running state - The context is canceled - The timeout has elapsed - We encounter more than 3 connection errors Giving a timeout of 0 will disable the timeout condition.

func WaitForSyncEventResourceIdentifier

func WaitForSyncEventResourceIdentifier(providerNode, subscriberNode, databaseName string) resource.Identifier

Types

type BackupConfig

type BackupConfig struct {
	Repositories []*pgbackrest.Repository `json:"repositories"`
	Schedules    []*BackupSchedule        `json:"schedules"`
}

func (*BackupConfig) Clone

func (b *BackupConfig) Clone() *BackupConfig

func (*BackupConfig) DefaultOptionalFieldsFrom

func (b *BackupConfig) DefaultOptionalFieldsFrom(other *BackupConfig)

DefaultOptionalFieldsFrom will default this config's optional fields to the values from the given config.

type BackupSchedule

type BackupSchedule struct {
	ID             string             `json:"id"`
	Type           BackupScheduleType `json:"type"`
	CronExpression string             `json:"cron_expression"`
}

func (*BackupSchedule) Clone

func (b *BackupSchedule) Clone() *BackupSchedule

type BackupScheduleType

type BackupScheduleType string
const (
	BackupScheduleTypeFull        BackupScheduleType = "full"
	BackupScheduleTypeIncremental BackupScheduleType = "incr"
)

type BuildServiceHostListParams added in v0.7.0

type BuildServiceHostListParams struct {
	ServiceHostID      string           // Host where the service instance runs
	NodeInstances      []*NodeInstances // All database instances, grouped by node
	TargetNodes        []string         // Optional ordered node filter (from database_connection.target_nodes)
	TargetSessionAttrs string           // Caller-provided: "primary", "prefer-standby", etc.
}

BuildServiceHostListParams holds the inputs for BuildServiceHostList.

type ConnectionInfo

type ConnectionInfo struct {
	AdminHost        string
	AdminPort        int
	PeerHost         string
	PeerPort         int
	PeerSSLCert      string
	PeerSSLKey       string
	PeerSSLRootCert  string
	PatroniPort      int
	ClientAddresses  []string
	ClientPort       int
	InstanceHostname string
}

func (*ConnectionInfo) AdminDSN

func (c *ConnectionInfo) AdminDSN(dbName string) *postgres.DSN

func (*ConnectionInfo) PatroniURL

func (c *ConnectionInfo) PatroniURL() *url.URL

type ConnectionOptions

type ConnectionOptions struct {
	DSN *postgres.DSN
	TLS *tls.Config
}

type Database

type Database struct {
	DatabaseID       string
	TenantID         *string
	CreatedAt        time.Time
	UpdatedAt        time.Time
	State            DatabaseState
	Spec             *Spec
	Instances        []*Instance
	ServiceInstances []*ServiceInstance
	NotCreated       bool
}

func (*Database) Variables added in v0.8.0

func (d *Database) Variables() resource.Variables

type DatabaseConnection added in v0.7.0

type DatabaseConnection struct {
	TargetNodes        []string `json:"target_nodes,omitempty"`
	TargetSessionAttrs string   `json:"target_session_attrs,omitempty"`
}

DatabaseConnection controls how a service connects to the database.

func (*DatabaseConnection) Clone added in v0.7.0

type DatabaseState

type DatabaseState string
const (
	DatabaseStateCreating  DatabaseState = "creating"
	DatabaseStateModifying DatabaseState = "modifying"
	DatabaseStateAvailable DatabaseState = "available"
	DatabaseStateDeleting  DatabaseState = "deleting"
	DatabaseStateDegraded  DatabaseState = "degraded"
	DatabaseStateFailed    DatabaseState = "failed"
	DatabaseStateRestoring DatabaseState = "restoring"
	DatabaseStateUnknown   DatabaseState = "unknown"
)

func (DatabaseState) IsInProgress added in v0.8.0

func (d DatabaseState) IsInProgress() bool

type DatabaseStore

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

func NewDatabaseStore

func NewDatabaseStore(client *clientv3.Client, root string) *DatabaseStore

func (*DatabaseStore) Create

func (*DatabaseStore) Delete

func (*DatabaseStore) ExistsByKey

func (s *DatabaseStore) ExistsByKey(databaseID string) storage.ExistsOp

func (*DatabaseStore) GetAll

func (*DatabaseStore) GetByKey

func (s *DatabaseStore) GetByKey(databaseID string) storage.GetOp[*StoredDatabase]

func (*DatabaseStore) GetByKeys

func (s *DatabaseStore) GetByKeys(databaseIDs ...string) storage.GetMultipleOp[*StoredDatabase]

func (*DatabaseStore) Key

func (s *DatabaseStore) Key(databaseID string) string

func (*DatabaseStore) Prefix

func (s *DatabaseStore) Prefix() string

func (*DatabaseStore) Update

type DumpRolesResource added in v0.8.0

type DumpRolesResource struct {
	NodeName   string   `json:"node_name"`
	Roles      []string `json:"roles"`
	Statements []string `json:"statements"`
}

func (*DumpRolesResource) Create added in v0.8.0

func (r *DumpRolesResource) Create(ctx context.Context, rc *resource.Context) error

func (*DumpRolesResource) Delete added in v0.8.0

func (r *DumpRolesResource) Delete(ctx context.Context, rc *resource.Context) error

func (*DumpRolesResource) Dependencies added in v0.8.0

func (r *DumpRolesResource) Dependencies() []resource.Identifier

func (*DumpRolesResource) DiffIgnore added in v0.8.0

func (r *DumpRolesResource) DiffIgnore() []string

func (*DumpRolesResource) Executor added in v0.8.0

func (r *DumpRolesResource) Executor() resource.Executor

func (*DumpRolesResource) Identifier added in v0.8.0

func (r *DumpRolesResource) Identifier() resource.Identifier

func (*DumpRolesResource) Refresh added in v0.8.0

func (r *DumpRolesResource) Refresh(ctx context.Context, rc *resource.Context) error

func (*DumpRolesResource) ResourceVersion added in v0.8.0

func (r *DumpRolesResource) ResourceVersion() string

func (*DumpRolesResource) TypeDependencies added in v0.8.0

func (r *DumpRolesResource) TypeDependencies() []resource.Type

func (*DumpRolesResource) Update added in v0.8.0

func (r *DumpRolesResource) Update(ctx context.Context, rc *resource.Context) error

type Extension

type Extension struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type ExtraNetworkSpec

type ExtraNetworkSpec struct {
	ID         string            `json:"id"`                    // required
	Aliases    []string          `json:"aliases,omitempty"`     // optional
	DriverOpts map[string]string `json:"driver_opts,omitempty"` // optional
}

type ExtraVolumesSpec

type ExtraVolumesSpec struct {
	HostPath        string `json:"host_path"`
	DestinationPath string `json:"destination_path"`
}

type HealthCheckResult added in v0.7.0

type HealthCheckResult struct {
	Status    string    `json:"status"`
	Message   string    `json:"message,omitempty"`
	CheckedAt time.Time `json:"checked_at"`
}

type Instance

type Instance struct {
	InstanceID    string            `json:"instance_id"`
	DatabaseID    string            `json:"database_id"`
	HostID        string            `json:"host_id"`
	NodeName      string            `json:"node_name"`
	State         InstanceState     `json:"state"`
	Status        *InstanceStatus   `json:"status"`
	CreatedAt     time.Time         `json:"created_at"`
	UpdatedAt     time.Time         `json:"updated_at"`
	Port          *int              `json:"port"`
	PatroniPort   *int              `json:"patroni_port"`
	PgEdgeVersion *ds.PgEdgeVersion `json:"pgedge_version"`
	Error         string            `json:"error,omitempty"`
}

type InstancePaths added in v0.8.0

type InstancePaths struct {
	Instance       Paths  `json:"instance"`
	Host           Paths  `json:"host"`
	PgBackRestPath string `json:"pg_backrest_path"`
	PatroniPath    string `json:"patroni_path"`
}

func (*InstancePaths) HostMvDataToRestoreCmd added in v0.8.0

func (p *InstancePaths) HostMvDataToRestoreCmd() []string

func (*InstancePaths) InstanceMvRestoreToDataCmd added in v0.8.0

func (p *InstancePaths) InstanceMvRestoreToDataCmd() []string

func (*InstancePaths) PgBackRestBackupCmd added in v0.8.0

func (p *InstancePaths) PgBackRestBackupCmd(command string, args ...string) pgbackrest.Cmd

func (*InstancePaths) PgBackRestRestoreCmd added in v0.8.0

func (p *InstancePaths) PgBackRestRestoreCmd(command string, args ...string) pgbackrest.Cmd

type InstanceResource

type InstanceResource struct {
	Spec                     *InstanceSpec         `json:"spec"`
	InstanceHostname         string                `json:"instance_hostname"`
	PrimaryInstanceID        string                `json:"primary_instance_id"`
	OrchestratorDependencies []resource.Identifier `json:"dependencies"`
	ConnectionInfo           *ConnectionInfo       `json:"connection_info"`
	PostInit                 *Script               `json:"post_init"`
}

func GetAllInstances

func GetAllInstances(ctx context.Context, rc *resource.Context, nodeName string) ([]*InstanceResource, error)

func GetPrimaryInstance

func GetPrimaryInstance(ctx context.Context, rc *resource.Context, nodeName string) (*InstanceResource, error)

func (*InstanceResource) Connection

func (r *InstanceResource) Connection(ctx context.Context, rc *resource.Context, dbName string) (*pgx.Conn, error)

func (*InstanceResource) Create

func (r *InstanceResource) Create(ctx context.Context, rc *resource.Context) error

func (*InstanceResource) Delete

func (r *InstanceResource) Delete(ctx context.Context, rc *resource.Context) error

func (*InstanceResource) Dependencies

func (r *InstanceResource) Dependencies() []resource.Identifier

func (*InstanceResource) DiffIgnore

func (r *InstanceResource) DiffIgnore() []string

func (*InstanceResource) Executor

func (r *InstanceResource) Executor() resource.Executor

func (*InstanceResource) Identifier

func (r *InstanceResource) Identifier() resource.Identifier

func (*InstanceResource) InstanceID added in v0.8.0

func (r *InstanceResource) InstanceID() string

func (*InstanceResource) Paths added in v0.8.0

func (r *InstanceResource) Paths(orchestrator Orchestrator) (InstancePaths, error)

func (*InstanceResource) PostgresVersion added in v0.8.0

func (r *InstanceResource) PostgresVersion() (*ds.Version, error)

func (*InstanceResource) Refresh

func (r *InstanceResource) Refresh(ctx context.Context, rc *resource.Context) error

func (*InstanceResource) ResourceVersion

func (r *InstanceResource) ResourceVersion() string

func (*InstanceResource) TypeDependencies added in v0.7.0

func (r *InstanceResource) TypeDependencies() []resource.Type

func (*InstanceResource) Update

func (r *InstanceResource) Update(ctx context.Context, rc *resource.Context) error

func (*InstanceResource) Validate

func (r *InstanceResource) Validate() error

type InstanceResources

type InstanceResources struct {
	Instance             *InstanceResource
	InstanceDependencies []*resource.ResourceData
	DatabaseDependencies []*resource.ResourceData
	NodeDependents       []*resource.ResourceData
}

func NewInstanceResources

func NewInstanceResources(
	instance *InstanceResource,
	instanceDependencies []resource.Resource,
	databaseDependencies []resource.Resource,
	nodeDependents []resource.Resource,
) (*InstanceResources, error)

func (*InstanceResources) AddDatabaseDependencies added in v0.8.0

func (r *InstanceResources) AddDatabaseDependencies(resources ...resource.Resource) error

func (*InstanceResources) AddInstanceDependencies added in v0.8.0

func (r *InstanceResources) AddInstanceDependencies(resources ...resource.Resource) error

func (*InstanceResources) AddNodeDependents added in v0.8.0

func (r *InstanceResources) AddNodeDependents(resources ...resource.Resource) error

func (*InstanceResources) DatabaseDependencyIdentifiers added in v0.8.0

func (r *InstanceResources) DatabaseDependencyIdentifiers() []resource.Identifier

func (*InstanceResources) DatabaseID

func (r *InstanceResources) DatabaseID() string

func (*InstanceResources) DatabaseName

func (r *InstanceResources) DatabaseName() string

func (*InstanceResources) HostID

func (r *InstanceResources) HostID() string

func (*InstanceResources) InstanceID

func (r *InstanceResources) InstanceID() string

func (*InstanceResources) InstanceState added in v0.8.0

func (r *InstanceResources) InstanceState() (*resource.State, error)

func (*InstanceResources) NodeName

func (r *InstanceResources) NodeName() string

type InstanceSpec

type InstanceSpec struct {
	InstanceID       string            `json:"instance_id"`
	TenantID         *string           `json:"tenant_id,omitempty"`
	DatabaseID       string            `json:"database_id"`
	HostID           string            `json:"host_id"`
	DatabaseName     string            `json:"database_name"`
	NodeName         string            `json:"node_name"`
	NodeOrdinal      int               `json:"node_ordinal"`
	PgEdgeVersion    *ds.PgEdgeVersion `json:"pg_edge_version"`
	Port             *int              `json:"port"`
	PatroniPort      *int              `json:"patroni_port"`
	CPUs             float64           `json:"cpus"`
	MemoryBytes      uint64            `json:"memory"`
	DatabaseUsers    []*User           `json:"database_users"`
	BackupConfig     *BackupConfig     `json:"backup_config"`
	RestoreConfig    *RestoreConfig    `json:"restore_config"`
	PostgreSQLConf   map[string]any    `json:"postgresql_conf"`
	ClusterSize      int               `json:"cluster_size"`
	NodeSize         int               `json:"node_size"`
	OrchestratorOpts *OrchestratorOpts `json:"orchestrator_opts,omitempty"`
	InPlaceRestore   bool              `json:"in_place_restore,omitempty"`
	AllHostIDs       []string          `json:"all_host_ids"` // All host IDs in the database
}

func (*InstanceSpec) Clone

func (s *InstanceSpec) Clone() *InstanceSpec

func (*InstanceSpec) CopySettingsFrom added in v0.7.0

func (s *InstanceSpec) CopySettingsFrom(current *InstanceSpec)

type InstanceSpecChange added in v0.5.1

type InstanceSpecChange struct {
	Previous *InstanceSpec
	Current  *InstanceSpec
}

type InstanceSpecStore added in v0.7.0

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

func NewInstanceSpecStore added in v0.7.0

func NewInstanceSpecStore(client *clientv3.Client, root string) *InstanceSpecStore

func (*InstanceSpecStore) DatabasePrefix added in v0.7.0

func (s *InstanceSpecStore) DatabasePrefix(databaseID string) string

func (*InstanceSpecStore) DeleteByDatabaseID added in v0.7.0

func (s *InstanceSpecStore) DeleteByDatabaseID(databaseID string) storage.DeleteOp

func (*InstanceSpecStore) DeleteByKey added in v0.7.0

func (s *InstanceSpecStore) DeleteByKey(databaseID, instanceID string) storage.DeleteOp

func (*InstanceSpecStore) GetAll added in v0.7.0

func (*InstanceSpecStore) GetByDatabaseID added in v0.7.0

func (s *InstanceSpecStore) GetByDatabaseID(databaseID string) storage.GetMultipleOp[*StoredInstanceSpec]

func (*InstanceSpecStore) GetByKey added in v0.7.0

func (s *InstanceSpecStore) GetByKey(databaseID, instanceID string) storage.GetOp[*StoredInstanceSpec]

func (*InstanceSpecStore) Key added in v0.7.0

func (s *InstanceSpecStore) Key(databaseID, instanceID string) string

func (*InstanceSpecStore) Prefix added in v0.7.0

func (s *InstanceSpecStore) Prefix() string

func (*InstanceSpecStore) Update added in v0.7.0

type InstanceState

type InstanceState string
const (
	InstanceStateCreating  InstanceState = "creating"
	InstanceStateModifying InstanceState = "modifying"
	InstanceStateDeleting  InstanceState = "deleting"
	InstanceStateBackingUp InstanceState = "backing_up"
	InstanceStateAvailable InstanceState = "available"
	InstanceStateDegraded  InstanceState = "degraded"
	InstanceStateFailed    InstanceState = "failed"
	InstanceStateStopped   InstanceState = "stopped"
	InstanceStateUnknown   InstanceState = "unknown"
)

func (InstanceState) IsInProgress added in v0.7.0

func (i InstanceState) IsInProgress() bool

type InstanceStateUpdateOptions added in v0.8.0

type InstanceStateUpdateOptions struct {
	InstanceID string        `json:"instance_id"`
	DatabaseID string        `json:"database_id"`
	HostID     string        `json:"host_id"`
	NodeName   string        `json:"node_name"`
	State      InstanceState `json:"state"`
	Error      string        `json:"error,omitempty"`
	Now        time.Time     `json:"now"`
}

type InstanceStatus

type InstanceStatus struct {
	PostgresVersion *string               `json:"postgres_version,omitempty"`
	SpockVersion    *string               `json:"spock_version,omitempty"`
	Addresses       []string              `json:"addresses,omitempty"`
	Port            *int                  `json:"port,omitempty"`
	PatroniState    *patroni.State        `json:"patroni_state,omitempty"`
	Role            *patroni.InstanceRole `json:"role,omitempty"`
	ReadOnly        *string               `json:"read_only,omitempty"`
	PendingRestart  *bool                 `json:"pending_restart,omitempty"`
	PatroniPaused   *bool                 `json:"patroni_paused,omitempty"`
	StatusUpdatedAt *time.Time            `json:"status_updated_at,omitempty"`
	Stopped         *bool                 `json:"stopped,omitempty"`
	Subscriptions   []SubscriptionStatus  `json:"subscriptions,omitempty"`
	Error           *string               `json:"error,omitempty"`
}

func (*InstanceStatus) IsPrimary

func (s *InstanceStatus) IsPrimary() bool

type InstanceStatusStore

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

func NewInstanceStatusStore

func NewInstanceStatusStore(client *clientv3.Client, root string) *InstanceStatusStore

func (*InstanceStatusStore) DatabasePrefix

func (s *InstanceStatusStore) DatabasePrefix(databaseID string) string

func (*InstanceStatusStore) DeleteByDatabaseID added in v0.7.0

func (s *InstanceStatusStore) DeleteByDatabaseID(databaseID string) storage.DeleteOp

func (*InstanceStatusStore) DeleteByKey

func (s *InstanceStatusStore) DeleteByKey(databaseID, instanceID string) storage.DeleteOp

func (*InstanceStatusStore) GetAll

func (*InstanceStatusStore) GetByDatabaseID

func (s *InstanceStatusStore) GetByDatabaseID(databaseID string) storage.GetMultipleOp[*StoredInstanceStatus]

func (*InstanceStatusStore) GetByKey

func (s *InstanceStatusStore) GetByKey(databaseID, instanceID string) storage.GetOp[*StoredInstanceStatus]

func (*InstanceStatusStore) Key

func (s *InstanceStatusStore) Key(databaseID, instanceID string) string

func (*InstanceStatusStore) Prefix

func (s *InstanceStatusStore) Prefix() string

func (*InstanceStatusStore) Put

type InstanceStore

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

func NewInstanceStore

func NewInstanceStore(client *clientv3.Client, root string) *InstanceStore

func (*InstanceStore) DatabasePrefix

func (s *InstanceStore) DatabasePrefix(databaseID string) string

func (*InstanceStore) DeleteByDatabaseID added in v0.7.0

func (s *InstanceStore) DeleteByDatabaseID(databaseID string) storage.DeleteOp

func (*InstanceStore) DeleteByKey

func (s *InstanceStore) DeleteByKey(databaseID, instanceID string) storage.DeleteOp

func (*InstanceStore) GetAll

func (*InstanceStore) GetByDatabaseID

func (s *InstanceStore) GetByDatabaseID(databaseID string) storage.GetMultipleOp[*StoredInstance]

func (*InstanceStore) GetByKey

func (s *InstanceStore) GetByKey(databaseID, instanceID string) storage.GetOp[*StoredInstance]

func (*InstanceStore) Key

func (s *InstanceStore) Key(databaseID, instanceID string) string

func (*InstanceStore) Prefix

func (s *InstanceStore) Prefix() string

func (*InstanceStore) Put

type InstanceUpdateOptions

type InstanceUpdateOptions struct {
	InstanceID    string            `json:"instance_id"`
	DatabaseID    string            `json:"database_id"`
	HostID        string            `json:"host_id"`
	NodeName      string            `json:"node_name"`
	State         InstanceState     `json:"state"`
	Port          *int              `json:"port"`
	PatroniPort   *int              `json:"patroni_port"`
	PgEdgeVersion *ds.PgEdgeVersion `json:"pgedge_version"`
	Error         string            `json:"error,omitempty"`
	Now           time.Time         `json:"now"`
}

type LagTrackerCommitTimestampResource

type LagTrackerCommitTimestampResource struct {
	// Planner fields
	OriginNode   string `json:"origin_node"`
	ReceiverNode string `json:"receiver_node"`
	DatabaseName string `json:"database_name"`

	// Dependency wiring
	ExtraDependencies []resource.Identifier `json:"dependent_resources,omitempty"`

	// Output (filled at Refresh/Create time)
	CommitTimestamp *time.Time `json:"commit_timestamp,omitempty"`
}

func (*LagTrackerCommitTimestampResource) Create

func (*LagTrackerCommitTimestampResource) Delete

func (*LagTrackerCommitTimestampResource) Dependencies

func (*LagTrackerCommitTimestampResource) DiffIgnore

func (r *LagTrackerCommitTimestampResource) DiffIgnore() []string

func (*LagTrackerCommitTimestampResource) Executor

func (*LagTrackerCommitTimestampResource) Identifier

func (*LagTrackerCommitTimestampResource) Refresh

func (*LagTrackerCommitTimestampResource) ResourceVersion

func (r *LagTrackerCommitTimestampResource) ResourceVersion() string

func (*LagTrackerCommitTimestampResource) TypeDependencies added in v0.7.0

func (r *LagTrackerCommitTimestampResource) TypeDependencies() []resource.Type

func (*LagTrackerCommitTimestampResource) Update

type MCPServiceConfig added in v0.7.0

type MCPServiceConfig struct {
	// Optional - LLM proxy for web client (default: false)
	LLMEnabled *bool `json:"llm_enabled,omitempty"`

	// Required when llm_enabled is true
	LLMProvider     string  `json:"llm_provider"`
	LLMModel        string  `json:"llm_model"`
	AnthropicAPIKey *string `json:"anthropic_api_key,omitempty"`
	OpenAIAPIKey    *string `json:"openai_api_key,omitempty"`
	OllamaURL       *string `json:"ollama_url,omitempty"`

	// Optional - security
	AllowWrites *bool            `json:"allow_writes,omitempty"`
	InitToken   *string          `json:"init_token,omitempty"`
	InitUsers   []MCPServiceUser `json:"init_users,omitempty"`

	// Optional - embeddings
	EmbeddingProvider *string `json:"embedding_provider,omitempty"`
	EmbeddingModel    *string `json:"embedding_model,omitempty"`
	EmbeddingAPIKey   *string `json:"embedding_api_key,omitempty"`

	// Optional - LLM tuning (overridable defaults)
	LLMTemperature *float64 `json:"llm_temperature,omitempty"`
	LLMMaxTokens   *int     `json:"llm_max_tokens,omitempty"`

	// Optional - connection pool (overridable defaults)
	PoolMaxConns *int `json:"pool_max_conns,omitempty"`

	// Optional - tool toggles (all enabled by default)
	DisableQueryDatabase       *bool `json:"disable_query_database,omitempty"`
	DisableGetSchemaInfo       *bool `json:"disable_get_schema_info,omitempty"`
	DisableSimilaritySearch    *bool `json:"disable_similarity_search,omitempty"`
	DisableExecuteExplain      *bool `json:"disable_execute_explain,omitempty"`
	DisableGenerateEmbedding   *bool `json:"disable_generate_embedding,omitempty"`
	DisableSearchKnowledgebase *bool `json:"disable_search_knowledgebase,omitempty"`
	DisableCountRows           *bool `json:"disable_count_rows,omitempty"`
}

MCPServiceConfig is the typed internal representation of MCP service configuration. It is parsed from the ServiceSpec.Config map[string]any and validated.

func ParseMCPServiceConfig added in v0.7.0

func ParseMCPServiceConfig(config map[string]any, isUpdate bool) (*MCPServiceConfig, []error)

ParseMCPServiceConfig parses and validates a config map into a typed MCPServiceConfig. If isUpdate is true, bootstrap-only fields (init_token, init_users) are rejected.

type MCPServiceUser added in v0.7.0

type MCPServiceUser struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

MCPServiceUser represents a bootstrap user account for the MCP service.

type Node

type Node struct {
	Name             string            `json:"name"`
	HostIDs          []string          `json:"host_ids"`
	PostgresVersion  string            `json:"postgres_version"`
	Port             *int              `json:"port"`
	PatroniPort      *int              `json:"patroni_port"`
	CPUs             float64           `json:"cpus"`
	MemoryBytes      uint64            `json:"memory"`
	PostgreSQLConf   map[string]any    `json:"postgresql_conf"`
	BackupConfig     *BackupConfig     `json:"backup_config"`
	RestoreConfig    *RestoreConfig    `json:"restore_config"`
	OrchestratorOpts *OrchestratorOpts `json:"orchestrator_opts,omitempty"`
	SourceNode       string            `json:"source_node,omitempty"`
}

func (*Node) Clone

func (n *Node) Clone() *Node

func (*Node) DefaultOptionalFieldsFrom

func (n *Node) DefaultOptionalFieldsFrom(other *Node)

DefaultOptionalFieldsFrom will default this node's optional fields to the values from the given node.

type NodeInstances

type NodeInstances struct {
	DatabaseID    string            `json:"database_id"`
	DatabaseOwner string            `json:"database_owner"`
	DatabaseName  string            `json:"database_name"`
	NodeName      string            `json:"node_name"`
	SourceNode    string            `json:"source_node"`
	Instances     []*InstanceSpec   `json:"instances"`
	RestoreConfig *RestoreConfig    `json:"restore_config"`
	Scripts       *ScriptStatements `json:"scripts"`
}

func (*NodeInstances) InstanceIDs

func (n *NodeInstances) InstanceIDs() []string

type NodeResource

type NodeResource struct {
	Name              string   `json:"name"`
	InstanceIDs       []string `json:"instance_ids"`
	PrimaryInstanceID string   `json:"primary_instance_id"`
}

func (*NodeResource) Create

func (n *NodeResource) Create(ctx context.Context, rc *resource.Context) error

func (*NodeResource) DSN added in v0.8.0

func (n *NodeResource) DSN(
	ctx context.Context,
	rc *resource.Context,
	fromInstance *InstanceResource,
	dbName string,
) (*postgres.DSN, error)

func (*NodeResource) Delete

func (n *NodeResource) Delete(ctx context.Context, rc *resource.Context) error

func (*NodeResource) Dependencies

func (n *NodeResource) Dependencies() []resource.Identifier

func (*NodeResource) DiffIgnore

func (n *NodeResource) DiffIgnore() []string

func (*NodeResource) Executor

func (n *NodeResource) Executor() resource.Executor

func (*NodeResource) Identifier

func (n *NodeResource) Identifier() resource.Identifier

func (*NodeResource) PrimaryInstance added in v0.8.0

func (n *NodeResource) PrimaryInstance(ctx context.Context, rc *resource.Context) (*InstanceResource, error)

func (*NodeResource) Refresh

func (n *NodeResource) Refresh(ctx context.Context, rc *resource.Context) error

func (*NodeResource) ResourceVersion

func (n *NodeResource) ResourceVersion() string

func (*NodeResource) TypeDependencies added in v0.7.0

func (n *NodeResource) TypeDependencies() []resource.Type

func (*NodeResource) Update

func (n *NodeResource) Update(ctx context.Context, rc *resource.Context) error

type Orchestrator

type Orchestrator interface {
	GenerateInstanceResources(spec *InstanceSpec, scripts Scripts) (*InstanceResources, error)
	GenerateInstanceRestoreResources(spec *InstanceSpec, taskID uuid.UUID) (*InstanceResources, error)
	GenerateServiceInstanceResources(spec *ServiceInstanceSpec) (*ServiceInstanceResources, error)
	GetInstanceConnectionInfo(ctx context.Context,
		databaseID, instanceID string,
		postgresPort, patroniPort *int,
		pgEdgeVersion *ds.PgEdgeVersion) (*ConnectionInfo, error)
	GetServiceInstanceStatus(ctx context.Context, serviceInstanceID string) (*ServiceInstanceStatus, error)
	CreatePgBackRestBackup(ctx context.Context, w io.Writer, spec *InstanceSpec, options *pgbackrest.BackupOptions) error
	ExecuteInstanceCommand(ctx context.Context, w io.Writer, databaseID, instanceID string, args ...string) error
	ValidateInstanceSpecs(ctx context.Context, changes []*InstanceSpecChange) ([]*ValidationResult, error)
	StopInstance(ctx context.Context, instanceID string) error
	StartInstance(ctx context.Context, instanceID string) error
	NodeDSN(ctx context.Context, rc *resource.Context, nodeName string, fromInstanceID string, dbName string) (*postgres.DSN, error)
	InstancePaths(pgVersion *ds.Version, instanceID string) (InstancePaths, error)
}

type OrchestratorOpts

type OrchestratorOpts struct {
	Swarm *SwarmOpts `json:"docker,omitempty"`
}

func (*OrchestratorOpts) Clone

func (o *OrchestratorOpts) Clone() *OrchestratorOpts

type Paths added in v0.8.0

type Paths struct {
	BaseDir string `json:"base_dir"`
}

func (*Paths) Certificates added in v0.8.0

func (p *Paths) Certificates() string

func (*Paths) Configs added in v0.8.0

func (p *Paths) Configs() string

func (*Paths) Data added in v0.8.0

func (p *Paths) Data() string

func (*Paths) EtcdCaCert added in v0.8.0

func (p *Paths) EtcdCaCert() string

func (*Paths) EtcdCertificates added in v0.8.0

func (p *Paths) EtcdCertificates() string

func (*Paths) EtcdClientCert added in v0.8.0

func (p *Paths) EtcdClientCert() string

func (*Paths) EtcdClientKey added in v0.8.0

func (p *Paths) EtcdClientKey() string

func (*Paths) PatroniConfig added in v0.8.0

func (p *Paths) PatroniConfig() string

func (*Paths) PgBackRestConfig added in v0.8.0

func (p *Paths) PgBackRestConfig(confType pgbackrest.ConfigType) string

func (*Paths) PgData added in v0.8.0

func (p *Paths) PgData() string

func (*Paths) PgDataRestore added in v0.8.0

func (p *Paths) PgDataRestore() string

func (*Paths) PostgresCaCert added in v0.8.0

func (p *Paths) PostgresCaCert() string

func (*Paths) PostgresCertificates added in v0.8.0

func (p *Paths) PostgresCertificates() string

func (*Paths) PostgresReplicatorCert added in v0.8.0

func (p *Paths) PostgresReplicatorCert() string

func (*Paths) PostgresReplicatorKey added in v0.8.0

func (p *Paths) PostgresReplicatorKey() string

func (*Paths) PostgresServerCert added in v0.8.0

func (p *Paths) PostgresServerCert() string

func (*Paths) PostgresServerKey added in v0.8.0

func (p *Paths) PostgresServerKey() string

func (*Paths) PostgresSuperuserCert added in v0.8.0

func (p *Paths) PostgresSuperuserCert() string

func (*Paths) PostgresSuperuserKey added in v0.8.0

func (p *Paths) PostgresSuperuserKey() string

type PortMapping added in v0.7.0

type PortMapping struct {
	Name          string `json:"name"`
	ContainerPort int    `json:"container_port"`
	HostPort      *int   `json:"host_port,omitempty"`
}

type PostgRESTConnParams added in v0.8.0

type PostgRESTConnParams struct {
	Username           string
	Password           string
	DatabaseName       string
	DatabaseHosts      []ServiceHostEntry
	TargetSessionAttrs string
}

PostgRESTConnParams holds the connection and credential details needed to generate a complete postgrest.conf. These are kept separate from PostgRESTServiceConfig because they are runtime-provisioned values (not user-supplied configuration).

type PostgRESTServiceConfig added in v0.7.0

type PostgRESTServiceConfig struct {
	DBSchemas                string  `json:"db_schemas"`   // default: "public"
	DBAnonRole               string  `json:"db_anon_role"` // required: no default
	DBPool                   int     `json:"db_pool"`      // default: 10, range: 1-30
	MaxRows                  int     `json:"max_rows"`     // default: 1000, range: 1-10000
	JWTSecret                *string `json:"jwt_secret,omitempty"`
	JWTAud                   *string `json:"jwt_aud,omitempty"`
	JWTRoleClaimKey          *string `json:"jwt_role_claim_key,omitempty"`
	ServerCORSAllowedOrigins *string `json:"server_cors_allowed_origins,omitempty"`
}

PostgRESTServiceConfig is the typed internal representation of PostgREST service configuration. Parsed from ServiceSpec.Config map[string]any. DBAnonRole is required; all other fields are optional with defaults applied when absent.

func ParsePostgRESTServiceConfig added in v0.7.0

func ParsePostgRESTServiceConfig(config map[string]any) (*PostgRESTServiceConfig, []error)

ParsePostgRESTServiceConfig parses and validates a config map into a typed PostgRESTServiceConfig. All fields are optional with sensible defaults.

func (*PostgRESTServiceConfig) GenerateConf added in v0.8.0

func (c *PostgRESTServiceConfig) GenerateConf(conn PostgRESTConnParams) ([]byte, error)

GenerateConf renders a postgrest.conf file from the service config and the runtime connection parameters. The db-uri (including credentials) is written into the file; no credentials are exposed as environment variables.

type PostgresDatabaseResource added in v0.8.0

type PostgresDatabaseResource struct {
	DatabaseID         string                `json:"database_id"`
	NodeName           string                `json:"node_name"`
	DatabaseName       string                `json:"database_name"`
	Owner              string                `json:"owner"`
	RenameFrom         string                `json:"rename_from"`
	HasRestoreConfig   bool                  `json:"has_restore_config"`
	ExtraDependencies  []resource.Identifier `json:"extra_dependencies"`
	PostDatabaseCreate *Script               `json:"post_database_create,omitempty"`
}

func (*PostgresDatabaseResource) Create added in v0.8.0

func (*PostgresDatabaseResource) Delete added in v0.8.0

func (*PostgresDatabaseResource) Dependencies added in v0.8.0

func (p *PostgresDatabaseResource) Dependencies() []resource.Identifier

func (*PostgresDatabaseResource) DiffIgnore added in v0.8.0

func (p *PostgresDatabaseResource) DiffIgnore() []string

func (*PostgresDatabaseResource) Executor added in v0.8.0

func (*PostgresDatabaseResource) Identifier added in v0.8.0

func (*PostgresDatabaseResource) Refresh added in v0.8.0

func (*PostgresDatabaseResource) ResourceVersion added in v0.8.0

func (p *PostgresDatabaseResource) ResourceVersion() string

func (*PostgresDatabaseResource) TypeDependencies added in v0.8.0

func (p *PostgresDatabaseResource) TypeDependencies() []resource.Type

func (*PostgresDatabaseResource) Update added in v0.8.0

type RAGDefaults added in v0.8.0

type RAGDefaults struct {
	TokenBudget *int `json:"token_budget,omitempty"`
	TopN        *int `json:"top_n,omitempty"`
}

RAGDefaults represents default values applied to all pipelines.

type RAGPipeline added in v0.8.0

type RAGPipeline struct {
	Name         string               `json:"name"`
	Description  *string              `json:"description,omitempty"`
	Tables       []RAGPipelineTable   `json:"tables"`
	EmbeddingLLM RAGPipelineLLMConfig `json:"embedding_llm"`
	RAGLLM       RAGPipelineLLMConfig `json:"rag_llm"`
	TokenBudget  *int                 `json:"token_budget,omitempty"`
	TopN         *int                 `json:"top_n,omitempty"`
	SystemPrompt *string              `json:"system_prompt,omitempty"`
	Search       *RAGPipelineSearch   `json:"search,omitempty"`
}

RAGPipeline represents a single RAG pipeline configuration.

type RAGPipelineLLMConfig added in v0.8.0

type RAGPipelineLLMConfig struct {
	Provider string  `json:"provider"`
	Model    string  `json:"model"`
	APIKey   *string `json:"api_key,omitempty"`
	BaseURL  *string `json:"base_url,omitempty"`
}

RAGPipelineLLMConfig represents LLM configuration for an embedding or RAG step.

type RAGPipelineSearch added in v0.8.0

type RAGPipelineSearch struct {
	HybridEnabled *bool    `json:"hybrid_enabled,omitempty"`
	VectorWeight  *float64 `json:"vector_weight,omitempty"`
}

RAGPipelineSearch represents search tuning for a pipeline.

type RAGPipelineTable added in v0.8.0

type RAGPipelineTable struct {
	Table        string  `json:"table"`
	TextColumn   string  `json:"text_column"`
	VectorColumn string  `json:"vector_column"`
	IDColumn     *string `json:"id_column,omitempty"`
}

RAGPipelineTable represents a table configuration for a pipeline.

type RAGServiceConfig added in v0.8.0

type RAGServiceConfig struct {
	Pipelines []RAGPipeline `json:"pipelines"`
	Defaults  *RAGDefaults  `json:"defaults,omitempty"`
}

RAGServiceConfig is the typed internal representation of RAG service configuration. It is parsed from the ServiceSpec.Config map[string]any and validated.

func ParseRAGServiceConfig added in v0.8.0

func ParseRAGServiceConfig(config map[string]any, _ bool) (*RAGServiceConfig, []error)

ParseRAGServiceConfig parses and validates a config map into a typed RAGServiceConfig.

type ReplicationSlotAdvanceFromCTSResource

type ReplicationSlotAdvanceFromCTSResource struct {
	DatabaseName   string `json:"database_name"`
	ProviderNode   string `json:"provider_node"`   // slot lives here
	SubscriberNode string `json:"subscriber_node"` // target/receiver node
}

ReplicationSlotAdvanceFromCTSResource advances the replication slot on the provider to the LSN derived from the commit timestamp captured in lag_tracker.

func (*ReplicationSlotAdvanceFromCTSResource) Create

func (*ReplicationSlotAdvanceFromCTSResource) Delete

func (*ReplicationSlotAdvanceFromCTSResource) Dependencies

func (*ReplicationSlotAdvanceFromCTSResource) DiffIgnore

No diff-ignore fields needed; this always executes idempotently when asked.

func (*ReplicationSlotAdvanceFromCTSResource) Executor

Execute on the provider node (the slot exists there).

func (*ReplicationSlotAdvanceFromCTSResource) Identifier

func (*ReplicationSlotAdvanceFromCTSResource) Refresh

func (*ReplicationSlotAdvanceFromCTSResource) ResourceVersion

func (r *ReplicationSlotAdvanceFromCTSResource) ResourceVersion() string

func (*ReplicationSlotAdvanceFromCTSResource) TypeDependencies added in v0.7.0

func (r *ReplicationSlotAdvanceFromCTSResource) TypeDependencies() []resource.Type

func (*ReplicationSlotAdvanceFromCTSResource) Update

type ReplicationSlotCreateResource

type ReplicationSlotCreateResource struct {
	DatabaseName   string `json:"database_name"`
	ProviderNode   string `json:"provider_node"`
	SubscriberNode string `json:"subscriber_node"`
}

func (*ReplicationSlotCreateResource) Create

func (*ReplicationSlotCreateResource) Delete

func (*ReplicationSlotCreateResource) Dependencies

func (*ReplicationSlotCreateResource) DiffIgnore

func (r *ReplicationSlotCreateResource) DiffIgnore() []string

func (*ReplicationSlotCreateResource) Executor

func (*ReplicationSlotCreateResource) Identifier

func (*ReplicationSlotCreateResource) Refresh

func (*ReplicationSlotCreateResource) ResourceVersion

func (r *ReplicationSlotCreateResource) ResourceVersion() string

func (*ReplicationSlotCreateResource) TypeDependencies added in v0.7.0

func (r *ReplicationSlotCreateResource) TypeDependencies() []resource.Type

func (*ReplicationSlotCreateResource) Update

type ReplicationSlotResource added in v0.7.0

type ReplicationSlotResource struct {
	DatabaseName   string `json:"database_name"`
	ProviderNode   string `json:"provider_node"`
	SubscriberNode string `json:"subscriber_node"`
}

ReplicationSlotResource represents the replication slot on a provider node that serves a subscription from a subscriber node. It only implements the Delete lifecycle method: when a subscription is removed, this resource ensures the corresponding replication slot is dropped on the provider, preventing orphaned slots from accumulating WAL.

func (*ReplicationSlotResource) Create added in v0.7.0

func (*ReplicationSlotResource) Delete added in v0.7.0

func (*ReplicationSlotResource) Dependencies added in v0.7.0

func (r *ReplicationSlotResource) Dependencies() []resource.Identifier

func (*ReplicationSlotResource) DiffIgnore added in v0.7.0

func (r *ReplicationSlotResource) DiffIgnore() []string

func (*ReplicationSlotResource) Executor added in v0.7.0

func (*ReplicationSlotResource) Identifier added in v0.7.0

func (*ReplicationSlotResource) Refresh added in v0.7.0

func (*ReplicationSlotResource) ResourceVersion added in v0.7.0

func (r *ReplicationSlotResource) ResourceVersion() string

func (*ReplicationSlotResource) TypeDependencies added in v0.7.0

func (r *ReplicationSlotResource) TypeDependencies() []resource.Type

func (*ReplicationSlotResource) Update added in v0.7.0

type RestoreConfig

type RestoreConfig struct {
	SourceDatabaseID   string                 `json:"source_database_id"`
	SourceNodeName     string                 `json:"source_node_name"`
	SourceDatabaseName string                 `json:"source_database_name"`
	Repository         *pgbackrest.Repository `json:"repository"`
	RestoreOptions     map[string]string      `json:"restore_options"`
}

func (*RestoreConfig) Clone

func (r *RestoreConfig) Clone() *RestoreConfig

func (*RestoreConfig) DefaultOptionalFieldsFrom

func (r *RestoreConfig) DefaultOptionalFieldsFrom(other *RestoreConfig)

DefaultOptionalFieldsFrom will default this config's optional fields to the values from the given config.

type RolesSourceResource added in v0.8.0

type RolesSourceResource struct {
	NodeName       string `json:"node_name"`
	SourceNodeName string `json:"source_node_name"`
}

func (*RolesSourceResource) Create added in v0.8.0

func (*RolesSourceResource) Delete added in v0.8.0

func (*RolesSourceResource) Dependencies added in v0.8.0

func (r *RolesSourceResource) Dependencies() []resource.Identifier

func (*RolesSourceResource) DiffIgnore added in v0.8.0

func (r *RolesSourceResource) DiffIgnore() []string

func (*RolesSourceResource) Executor added in v0.8.0

func (r *RolesSourceResource) Executor() resource.Executor

func (*RolesSourceResource) Identifier added in v0.8.0

func (r *RolesSourceResource) Identifier() resource.Identifier

func (*RolesSourceResource) Refresh added in v0.8.0

func (*RolesSourceResource) ResourceVersion added in v0.8.0

func (r *RolesSourceResource) ResourceVersion() string

func (*RolesSourceResource) TypeDependencies added in v0.8.0

func (r *RolesSourceResource) TypeDependencies() []resource.Type

func (*RolesSourceResource) Update added in v0.8.0

type Script added in v0.8.0

type Script struct {
	DatabaseID string     `json:"database_id"`
	NodeName   string     `json:"node_name"`
	Name       ScriptName `json:"name"`
	Statements []string   `json:"statements"`
	Succeeded  bool       `json:"succeeded"`
	// NeedsToRun is used to trigger a resource diff. Resources should call
	// SetScriptNeedsToRun to set it.
	NeedsToRun bool `json:"needs_to_run"`
}

type ScriptName added in v0.8.0

type ScriptName string
const (
	ScriptNamePostInit           ScriptName = "post_init"
	ScriptNamePostDatabaseCreate ScriptName = "post_database_create"
)

func (ScriptName) String added in v0.8.0

func (s ScriptName) String() string

type ScriptResult added in v0.8.0

type ScriptResult struct {
	DatabaseID  string     `json:"database_id"`
	ScriptName  ScriptName `json:"script_name"`
	NodeName    string     `json:"node_name"`
	Succeeded   bool       `json:"succeeded"`
	StartedAt   time.Time  `json:"started_at"`
	CompletedAt time.Time  `json:"completed_at"`
	Error       string     `json:"error"`
}

func NewScriptResult added in v0.8.0

func NewScriptResult(databaseID string, scriptName ScriptName, nodeName string) *ScriptResult

func (*ScriptResult) Validate added in v0.8.0

func (s *ScriptResult) Validate() error

type ScriptResultStore added in v0.8.0

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

func NewScriptResultStore added in v0.8.0

func NewScriptResultStore(client *clientv3.Client, root string) *ScriptResultStore

func (*ScriptResultStore) DatabasePrefix added in v0.8.0

func (s *ScriptResultStore) DatabasePrefix(databaseID string) string

func (*ScriptResultStore) DeleteByDatabaseID added in v0.8.0

func (s *ScriptResultStore) DeleteByDatabaseID(databaseID string) storage.DeleteOp

func (*ScriptResultStore) GetByKey added in v0.8.0

func (s *ScriptResultStore) GetByKey(databaseID string, scriptName ScriptName, nodeName string) storage.GetOp[*StoredScriptResult]

func (*ScriptResultStore) Key added in v0.8.0

func (s *ScriptResultStore) Key(databaseID string, scriptName ScriptName, nodeName string) string

func (*ScriptResultStore) Prefix added in v0.8.0

func (s *ScriptResultStore) Prefix() string

func (*ScriptResultStore) ScriptNamePrefix added in v0.8.0

func (s *ScriptResultStore) ScriptNamePrefix(databaseID string, name ScriptName) string

func (*ScriptResultStore) Update added in v0.8.0

type ScriptStatements added in v0.8.0

type ScriptStatements struct {
	PostInit           []string `json:"post_init"`
	PostDatabaseCreate []string `json:"post_database_create"`
}

func (*ScriptStatements) Clone added in v0.8.0

func (s *ScriptStatements) Clone() *ScriptStatements

type Scripts added in v0.8.0

type Scripts map[ScriptName]*Script

type Service

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

func NewService

func NewService(
	cfg config.Config,
	orchestrator Orchestrator,
	store *Store,
	hostSvc *host.Service,
	portsSvc *ports.Service,
) *Service

func (*Service) CreateDatabase

func (s *Service) CreateDatabase(ctx context.Context, spec *Spec) (*Database, error)

func (*Service) CreatePgBackRestBackup added in v0.8.0

func (s *Service) CreatePgBackRestBackup(ctx context.Context, w io.Writer, databaseID, instanceID string, options *pgbackrest.BackupOptions) error

func (*Service) DeleteDatabase

func (s *Service) DeleteDatabase(ctx context.Context, databaseID string) error

func (*Service) DeleteInstance

func (s *Service) DeleteInstance(ctx context.Context, databaseID, instanceID string) error

func (*Service) DeleteInstanceSpec added in v0.7.0

func (s *Service) DeleteInstanceSpec(ctx context.Context, databaseID, instanceID string) error

func (*Service) DeleteServiceInstance added in v0.7.0

func (s *Service) DeleteServiceInstance(ctx context.Context, databaseID, serviceInstanceID string) error

func (*Service) DeleteServiceInstanceSpec added in v0.8.0

func (s *Service) DeleteServiceInstanceSpec(ctx context.Context, databaseID, serviceInstanceID string) error

func (*Service) GetAllInstances

func (s *Service) GetAllInstances(ctx context.Context) ([]*Instance, error)

func (*Service) GetAllServiceInstances added in v0.7.0

func (s *Service) GetAllServiceInstances(ctx context.Context) ([]*ServiceInstance, error)

func (*Service) GetDatabase

func (s *Service) GetDatabase(ctx context.Context, databaseID string) (*Database, error)

func (*Service) GetDatabases

func (s *Service) GetDatabases(ctx context.Context) ([]*Database, error)

func (*Service) GetDatabasesByHostId added in v0.6.0

func (s *Service) GetDatabasesByHostId(ctx context.Context, hostID string) ([]*Database, error)

func (*Service) GetInstance

func (s *Service) GetInstance(ctx context.Context, databaseID, instanceID string) (*Instance, error)

func (*Service) GetInstanceConnectionInfo added in v0.7.0

func (s *Service) GetInstanceConnectionInfo(ctx context.Context, databaseID, instanceID string) (*ConnectionInfo, error)

func (*Service) GetInstances

func (s *Service) GetInstances(ctx context.Context, databaseID string) ([]*Instance, error)

func (*Service) GetScriptResult added in v0.8.0

func (s *Service) GetScriptResult(ctx context.Context, databaseID string, scriptName ScriptName, nodeName string) (*ScriptResult, error)

func (*Service) GetServiceInstance added in v0.7.0

func (s *Service) GetServiceInstance(ctx context.Context, databaseID, serviceInstanceID string) (*ServiceInstance, error)

func (*Service) GetServiceInstances added in v0.7.0

func (s *Service) GetServiceInstances(ctx context.Context, databaseID string) ([]*ServiceInstance, error)

func (*Service) GetStoredDatabaseState added in v0.8.0

func (s *Service) GetStoredDatabaseState(ctx context.Context, databaseID string) (DatabaseState, error)

func (*Service) GetStoredInstanceState

func (s *Service) GetStoredInstanceState(ctx context.Context, databaseID, instanceID string) (InstanceState, error)

func (*Service) InstanceCountForHost

func (s *Service) InstanceCountForHost(ctx context.Context, hostID string) (int, error)

func (*Service) PopulateSpecDefaults

func (s *Service) PopulateSpecDefaults(ctx context.Context, spec *Spec) error

func (*Service) ReconcileInstanceSpec added in v0.7.0

func (s *Service) ReconcileInstanceSpec(ctx context.Context, spec *InstanceSpec) (*InstanceSpec, error)

func (*Service) ReconcileServiceInstanceSpec added in v0.8.0

func (s *Service) ReconcileServiceInstanceSpec(ctx context.Context, spec *ServiceInstanceSpec) (*ServiceInstanceSpec, error)

func (*Service) SetServiceInstanceState added in v0.7.0

func (s *Service) SetServiceInstanceState(
	ctx context.Context,
	databaseID, serviceInstanceID string,
	state ServiceInstanceState,
) error

SetServiceInstanceState performs a targeted state update using a direct key lookup instead of scanning all service instances.

func (*Service) UpdateDatabase

func (s *Service) UpdateDatabase(ctx context.Context, state DatabaseState, spec *Spec) (*Database, error)

func (*Service) UpdateDatabaseState

func (s *Service) UpdateDatabaseState(ctx context.Context, databaseID string, from, to DatabaseState) error

func (*Service) UpdateInstance

func (s *Service) UpdateInstance(ctx context.Context, opts *InstanceUpdateOptions) error

func (*Service) UpdateInstanceState added in v0.8.0

func (s *Service) UpdateInstanceState(ctx context.Context, opts *InstanceStateUpdateOptions) error

func (*Service) UpdateInstanceStatus

func (s *Service) UpdateInstanceStatus(
	ctx context.Context,
	databaseID string,
	instanceID string,
	status *InstanceStatus,
) error

func (*Service) UpdateScriptResult added in v0.8.0

func (s *Service) UpdateScriptResult(ctx context.Context, result *ScriptResult) error

func (*Service) UpdateServiceInstance added in v0.7.0

func (s *Service) UpdateServiceInstance(ctx context.Context, opts *ServiceInstanceUpdateOptions) error

func (*Service) UpdateServiceInstanceState added in v0.7.0

func (s *Service) UpdateServiceInstanceState(
	ctx context.Context,
	serviceInstanceID string,
	update *ServiceInstanceStateUpdate,
) error

func (*Service) UpdateServiceInstanceStatus added in v0.7.0

func (s *Service) UpdateServiceInstanceStatus(
	ctx context.Context,
	databaseID string,
	serviceInstanceID string,
	status *ServiceInstanceStatus,
) error

type ServiceConnectionInfo added in v0.7.0

type ServiceConnectionInfo struct {
	Hosts              []ServiceHostEntry
	TargetSessionAttrs string
}

ServiceConnectionInfo holds the ordered host list and connection parameters for a service instance's database connection.

func BuildServiceHostList added in v0.7.0

func BuildServiceHostList(params *BuildServiceHostListParams) (*ServiceConnectionInfo, error)

BuildServiceHostList produces an ordered list of database host:port entries for a service instance's connection string. The ordering is determined by co-location with the service host and optional node filtering.

Algorithm:

  1. Determine node list and ordering: - If TargetNodes is set: use only listed nodes in that order, ignoring co-location - If TargetNodes is not set: all nodes, with the local node (containing a co-located instance) first, then remaining nodes in iteration order
  2. Build host list, grouped by node: - For each node group: co-located instance first (same host as service), then remaining - Hostname format: "postgres-{instanceID}" (swarm overlay convention) - Port: always 5432 (internal container port via overlay network)
  3. Pass through TargetSessionAttrs unchanged.

Invariant: Only database instances from NodeInstances generate entries. ServiceHostID affects ordering only, never membership. A service on a dedicated host (no database instance on that host) does not add the service host to the list.

type ServiceHostEntry added in v0.7.0

type ServiceHostEntry struct {
	Host string
	Port int
}

ServiceHostEntry represents a single host:port pair in an ordered host list.

type ServiceInstance added in v0.7.0

type ServiceInstance struct {
	ServiceInstanceID string                 `json:"service_instance_id"`
	ServiceID         string                 `json:"service_id"`
	DatabaseID        string                 `json:"database_id"`
	HostID            string                 `json:"host_id"`
	State             ServiceInstanceState   `json:"state"`
	Status            *ServiceInstanceStatus `json:"status,omitempty"`
	CreatedAt         time.Time              `json:"created_at"`
	UpdatedAt         time.Time              `json:"updated_at"`
	Error             string                 `json:"error,omitempty"`
}

type ServiceInstanceResources added in v0.7.0

type ServiceInstanceResources struct {
	ServiceInstance *ServiceInstance
	Resources       []*resource.ResourceData
}

type ServiceInstanceSpec added in v0.7.0

type ServiceInstanceSpec struct {
	ServiceInstanceID  string
	ServiceSpec        *ServiceSpec
	PgEdgeVersion      *ds.PgEdgeVersion // Database version, used for compatibility validation
	DatabaseID         string
	DatabaseName       string
	HostID             string
	CohortMemberID     string
	DatabaseNetworkID  string
	NodeName           string             // Database node name for PrimaryExecutor routing
	DatabaseHosts      []ServiceHostEntry // Ordered list of Postgres host:port entries
	TargetSessionAttrs string             // libpq target_session_attrs value
	Port               *int               // Service instance published port (optional, 0 = random)
	DatabaseNodes      []*NodeInstances   // All database nodes; used to create per-node resources
	ConnectAsUsername  string             // Username from database_users (resolved from ServiceSpec.ConnectAs)
	ConnectAsPassword  string             // Password from database_users (resolved from ServiceSpec.ConnectAs)
}

ServiceInstanceSpec contains the specification for generating service instance resources.

func (*ServiceInstanceSpec) CopyPortFrom added in v0.8.0

func (s *ServiceInstanceSpec) CopyPortFrom(current *ServiceInstanceSpec)

CopyPortFrom copies the port from the current (persisted) spec to this spec, retaining any previously allocated stable random port. This mirrors the reconcilePort logic used by InstanceSpec.CopySettingsFrom.

type ServiceInstanceSpecStore added in v0.8.0

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

func NewServiceInstanceSpecStore added in v0.8.0

func NewServiceInstanceSpecStore(client *clientv3.Client, root string) *ServiceInstanceSpecStore

func (*ServiceInstanceSpecStore) DatabasePrefix added in v0.8.0

func (s *ServiceInstanceSpecStore) DatabasePrefix(databaseID string) string

func (*ServiceInstanceSpecStore) DeleteByDatabaseID added in v0.8.0

func (s *ServiceInstanceSpecStore) DeleteByDatabaseID(databaseID string) storage.DeleteOp

func (*ServiceInstanceSpecStore) DeleteByKey added in v0.8.0

func (s *ServiceInstanceSpecStore) DeleteByKey(databaseID, serviceInstanceID string) storage.DeleteOp

func (*ServiceInstanceSpecStore) GetByDatabaseID added in v0.8.0

func (*ServiceInstanceSpecStore) GetByKey added in v0.8.0

func (s *ServiceInstanceSpecStore) GetByKey(databaseID, serviceInstanceID string) storage.GetOp[*StoredServiceInstanceSpec]

func (*ServiceInstanceSpecStore) Key added in v0.8.0

func (s *ServiceInstanceSpecStore) Key(databaseID, serviceInstanceID string) string

func (*ServiceInstanceSpecStore) Prefix added in v0.8.0

func (s *ServiceInstanceSpecStore) Prefix() string

func (*ServiceInstanceSpecStore) Update added in v0.8.0

type ServiceInstanceState added in v0.7.0

type ServiceInstanceState string
const (
	ServiceInstanceStateCreating ServiceInstanceState = "creating"
	ServiceInstanceStateRunning  ServiceInstanceState = "running"
	ServiceInstanceStateFailed   ServiceInstanceState = "failed"
	ServiceInstanceStateDeleting ServiceInstanceState = "deleting"
)

type ServiceInstanceStateUpdate added in v0.7.0

type ServiceInstanceStateUpdate struct {
	DatabaseID string                 `json:"database_id,omitempty"`
	State      ServiceInstanceState   `json:"state"`
	Status     *ServiceInstanceStatus `json:"status,omitempty"`
	Error      string                 `json:"error,omitempty"`
}

type ServiceInstanceStatus added in v0.7.0

type ServiceInstanceStatus struct {
	ContainerID  *string            `json:"container_id,omitempty"`
	ImageVersion *string            `json:"image_version,omitempty"`
	Addresses    []string           `json:"addresses,omitempty"`
	Ports        []PortMapping      `json:"ports,omitempty"`
	HealthCheck  *HealthCheckResult `json:"health_check,omitempty"`
	LastHealthAt *time.Time         `json:"last_health_at,omitempty"`
	ServiceReady *bool              `json:"service_ready,omitempty"`
}

type ServiceInstanceStatusStore added in v0.7.0

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

func NewServiceInstanceStatusStore added in v0.7.0

func NewServiceInstanceStatusStore(client *clientv3.Client, root string) *ServiceInstanceStatusStore

func (*ServiceInstanceStatusStore) DatabasePrefix added in v0.7.0

func (s *ServiceInstanceStatusStore) DatabasePrefix(databaseID string) string

func (*ServiceInstanceStatusStore) DeleteByKey added in v0.7.0

func (s *ServiceInstanceStatusStore) DeleteByKey(databaseID, serviceInstanceID string) storage.DeleteOp

func (*ServiceInstanceStatusStore) GetAll added in v0.7.0

func (*ServiceInstanceStatusStore) GetByDatabaseID added in v0.7.0

func (*ServiceInstanceStatusStore) GetByKey added in v0.7.0

func (s *ServiceInstanceStatusStore) GetByKey(databaseID, serviceInstanceID string) storage.GetOp[*StoredServiceInstanceStatus]

func (*ServiceInstanceStatusStore) Key added in v0.7.0

func (s *ServiceInstanceStatusStore) Key(databaseID, serviceInstanceID string) string

func (*ServiceInstanceStatusStore) Prefix added in v0.7.0

func (s *ServiceInstanceStatusStore) Prefix() string

func (*ServiceInstanceStatusStore) Put added in v0.7.0

type ServiceInstanceStore added in v0.7.0

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

func NewServiceInstanceStore added in v0.7.0

func NewServiceInstanceStore(client *clientv3.Client, root string) *ServiceInstanceStore

func (*ServiceInstanceStore) DatabasePrefix added in v0.7.0

func (s *ServiceInstanceStore) DatabasePrefix(databaseID string) string

func (*ServiceInstanceStore) DeleteByKey added in v0.7.0

func (s *ServiceInstanceStore) DeleteByKey(databaseID, serviceInstanceID string) storage.DeleteOp

func (*ServiceInstanceStore) GetAll added in v0.7.0

func (*ServiceInstanceStore) GetByDatabaseID added in v0.7.0

func (s *ServiceInstanceStore) GetByDatabaseID(databaseID string) storage.GetMultipleOp[*StoredServiceInstance]

func (*ServiceInstanceStore) GetByKey added in v0.7.0

func (s *ServiceInstanceStore) GetByKey(databaseID, serviceInstanceID string) storage.GetOp[*StoredServiceInstance]

func (*ServiceInstanceStore) Key added in v0.7.0

func (s *ServiceInstanceStore) Key(databaseID, serviceInstanceID string) string

func (*ServiceInstanceStore) Prefix added in v0.7.0

func (s *ServiceInstanceStore) Prefix() string

func (*ServiceInstanceStore) Put added in v0.7.0

type ServiceInstanceUpdateOptions added in v0.7.0

type ServiceInstanceUpdateOptions struct {
	ServiceInstanceID string               `json:"service_instance_id"`
	ServiceID         string               `json:"service_id"`
	DatabaseID        string               `json:"database_id"`
	HostID            string               `json:"host_id"`
	State             ServiceInstanceState `json:"state"`
	Error             string               `json:"error,omitempty"`
}

type ServiceSpec added in v0.7.0

type ServiceSpec struct {
	ServiceID          string              `json:"service_id"`
	ServiceType        string              `json:"service_type"`
	Version            string              `json:"version"`
	HostIDs            []string            `json:"host_ids"`
	Config             map[string]any      `json:"config"`
	Port               *int                `json:"port,omitempty"`
	CPUs               *float64            `json:"cpus,omitempty"`
	MemoryBytes        *uint64             `json:"memory,omitempty"`
	OrchestratorOpts   *OrchestratorOpts   `json:"orchestrator_opts,omitempty"`
	DatabaseConnection *DatabaseConnection `json:"database_connection,omitempty"`
	ConnectAs          string              `json:"connect_as"`
}

func (*ServiceSpec) Clone added in v0.7.0

func (s *ServiceSpec) Clone() *ServiceSpec

type Spec

type Spec struct {
	DatabaseID       string            `json:"database_id"`
	TenantID         *string           `json:"tenant_id,omitempty"`
	DatabaseName     string            `json:"database_name"`
	PostgresVersion  string            `json:"postgres_version"`
	SpockVersion     string            `json:"spock_version"`
	Port             *int              `json:"port"`
	PatroniPort      *int              `json:"patroni_port"`
	CPUs             float64           `json:"cpus"`
	MemoryBytes      uint64            `json:"memory"`
	Nodes            []*Node           `json:"nodes"`
	DatabaseUsers    []*User           `json:"database_users"`
	Services         []*ServiceSpec    `json:"services,omitempty"`
	BackupConfig     *BackupConfig     `json:"backup_config"`
	RestoreConfig    *RestoreConfig    `json:"restore_config"`
	PostgreSQLConf   map[string]any    `json:"postgresql_conf"`
	OrchestratorOpts *OrchestratorOpts `json:"orchestrator_opts,omitempty"`
	Scripts          *ScriptStatements `json:"scripts,omitempty"`
}

func (*Spec) Clone

func (s *Spec) Clone() *Spec

func (*Spec) DefaultOptionalFieldsFrom

func (s *Spec) DefaultOptionalFieldsFrom(other *Spec)

DefaultOptionalFieldsFrom will default this spec's optional fields to the values from the given spec.

func (*Spec) Node

func (s *Spec) Node(name string) (*Node, error)

func (*Spec) NodeInstances

func (s *Spec) NodeInstances() ([]*NodeInstances, error)

func (*Spec) NodeNames

func (s *Spec) NodeNames() []string

func (*Spec) NormalizeBackupConfig

func (s *Spec) NormalizeBackupConfig()

NormalizeBackupConfig normalizes the backup config so that its defined per-node rather than at the database level. This is useful as a preliminary step if we need to modify the backup configs on the user's behalf.

func (*Spec) RemoveBackupConfigFrom

func (s *Spec) RemoveBackupConfigFrom(nodes ...string)

RemoveBackupConfigFrom removes backup configuration from the given nodes. It normalizes the backup configuration first to ensure that only the given nodes are affected.

func (*Spec) RemoveHost added in v0.6.0

func (s *Spec) RemoveHost(hostId string) (ok bool)

RemoveHost removes hostId from Spec.Nodes.HostIDs (if present). If this results in an empty Node, then the Node is removed from Spec.Nodes. Return true if hostId was found and removed, false otherwise.

func (*Spec) ValidateNodeNames

func (s *Spec) ValidateNodeNames(names ...string) error

type SpecStore

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

func NewSpecStore

func NewSpecStore(client *clientv3.Client, root string) *SpecStore

func (*SpecStore) Create

func (s *SpecStore) Create(item *StoredSpec) storage.PutOp[*StoredSpec]

func (*SpecStore) Delete

func (*SpecStore) ExistsByKey

func (s *SpecStore) ExistsByKey(databaseID string) storage.ExistsOp

func (*SpecStore) GetAll

func (s *SpecStore) GetAll() storage.GetMultipleOp[*StoredSpec]

func (*SpecStore) GetByKey

func (s *SpecStore) GetByKey(databaseID string) storage.GetOp[*StoredSpec]

func (*SpecStore) GetByKeys

func (s *SpecStore) GetByKeys(databaseIDs ...string) storage.GetMultipleOp[*StoredSpec]

func (*SpecStore) Key

func (s *SpecStore) Key(databaseID string) string

func (*SpecStore) Prefix

func (s *SpecStore) Prefix() string

func (*SpecStore) Update

func (s *SpecStore) Update(item *StoredSpec) storage.PutOp[*StoredSpec]

type Store

type Store struct {
	Spec                  *SpecStore
	Database              *DatabaseStore
	Instance              *InstanceStore
	InstanceStatus        *InstanceStatusStore
	InstanceSpec          *InstanceSpecStore
	ScriptResult          *ScriptResultStore
	ServiceInstance       *ServiceInstanceStore
	ServiceInstanceStatus *ServiceInstanceStatusStore
	ServiceInstanceSpec   *ServiceInstanceSpecStore
	// contains filtered or unexported fields
}

func NewStore

func NewStore(client *clientv3.Client, root string) *Store

func (*Store) Txn

func (s *Store) Txn(ops ...storage.TxnOperation) storage.Txn

type StoredDatabase

type StoredDatabase struct {
	storage.StoredValue
	DatabaseID string        `json:"database_id"`
	TenantID   *string       `json:"tenant_id,omitempty"`
	CreatedAt  time.Time     `json:"created_at"`
	UpdatedAt  time.Time     `json:"updated_at"`
	State      DatabaseState `json:"state"`
	NotCreated bool          `json:"not_created"`
}

type StoredInstance

type StoredInstance struct {
	storage.StoredValue
	InstanceID    string            `json:"instance_id"`
	DatabaseID    string            `json:"database_id"`
	HostID        string            `json:"host_id"`
	NodeName      string            `json:"node_name"`
	State         InstanceState     `json:"state"`
	CreatedAt     time.Time         `json:"created_at"`
	UpdateAt      time.Time         `json:"updated_at"`
	Port          *int              `json:"port"`
	PatroniPort   *int              `json:"patroni_port"`
	PgEdgeVersion *ds.PgEdgeVersion `json:"pgedge_version"`
	Error         string            `json:"error,omitempty"`
}

func NewStoredInstance

func NewStoredInstance(opts *InstanceUpdateOptions) *StoredInstance

func (*StoredInstance) Update

func (i *StoredInstance) Update(opts *InstanceUpdateOptions)

func (*StoredInstance) UpdateState added in v0.8.0

func (i *StoredInstance) UpdateState(opts *InstanceStateUpdateOptions)

type StoredInstanceSpec added in v0.7.0

type StoredInstanceSpec struct {
	storage.StoredValue
	Spec *InstanceSpec `json:"spec"`
}

type StoredInstanceStatus

type StoredInstanceStatus struct {
	storage.StoredValue
	DatabaseID string          `json:"database_id"`
	InstanceID string          `json:"instance_id"`
	Status     *InstanceStatus `json:"status"`
}

type StoredScriptResult added in v0.8.0

type StoredScriptResult struct {
	storage.StoredValue
	Result *ScriptResult `json:"script_result"`
}

type StoredServiceInstance added in v0.7.0

type StoredServiceInstance struct {
	storage.StoredValue
	ServiceInstanceID string               `json:"service_instance_id"`
	ServiceID         string               `json:"service_id"`
	DatabaseID        string               `json:"database_id"`
	HostID            string               `json:"host_id"`
	State             ServiceInstanceState `json:"state"`
	CreatedAt         time.Time            `json:"created_at"`
	UpdatedAt         time.Time            `json:"updated_at"`
	Error             string               `json:"error,omitempty"`
}

func NewStoredServiceInstance added in v0.7.0

func NewStoredServiceInstance(opts *ServiceInstanceUpdateOptions) *StoredServiceInstance

func (*StoredServiceInstance) Update added in v0.7.0

type StoredServiceInstanceSpec added in v0.8.0

type StoredServiceInstanceSpec struct {
	storage.StoredValue
	Spec *ServiceInstanceSpec `json:"spec"`
}

type StoredServiceInstanceStatus added in v0.7.0

type StoredServiceInstanceStatus struct {
	storage.StoredValue
	DatabaseID        string                 `json:"database_id"`
	ServiceInstanceID string                 `json:"service_instance_id"`
	Status            *ServiceInstanceStatus `json:"status"`
}

type StoredSpec

type StoredSpec struct {
	storage.StoredValue
	*Spec
}

type SubscriptionResource

type SubscriptionResource struct {
	DatabaseName      string                `json:"database_name"`
	SubscriberNode    string                `json:"subscriber_node"`
	ProviderNode      string                `json:"provider_node"`
	Disabled          bool                  `json:"disabled"`
	SyncStructure     bool                  `json:"sync_structure"`
	SyncData          bool                  `json:"sync_data"`
	ExtraDependencies []resource.Identifier `json:"extra_dependencies"`
	NeedsUpdate       bool                  `json:"needs_update"`
}

func (*SubscriptionResource) Create

func (*SubscriptionResource) Delete

func (*SubscriptionResource) Dependencies

func (s *SubscriptionResource) Dependencies() []resource.Identifier

func (*SubscriptionResource) DiffIgnore

func (s *SubscriptionResource) DiffIgnore() []string

func (*SubscriptionResource) Executor

func (s *SubscriptionResource) Executor() resource.Executor

func (*SubscriptionResource) Identifier

func (s *SubscriptionResource) Identifier() resource.Identifier

func (*SubscriptionResource) Refresh

func (*SubscriptionResource) ResourceVersion

func (s *SubscriptionResource) ResourceVersion() string

func (*SubscriptionResource) TypeDependencies added in v0.7.0

func (s *SubscriptionResource) TypeDependencies() []resource.Type

func (*SubscriptionResource) Update

type SubscriptionStatus

type SubscriptionStatus struct {
	ProviderNode string `json:"provider_node"`
	Name         string `json:"name"`
	Status       string `json:"status"`
}

type SwarmOpts

type SwarmOpts struct {
	ExtraVolumes  []ExtraVolumesSpec `json:"extra_volumes,omitempty"`
	ExtraNetworks []ExtraNetworkSpec `json:"extra_networks,omitempty"`
	ExtraLabels   map[string]string  `json:"extra_labels,omitempty"` // optional, used for custom labels on the swarm service
}

func (*SwarmOpts) Clone

func (d *SwarmOpts) Clone() *SwarmOpts

type SwitchoverResource

type SwitchoverResource struct {
	HostID     string               `json:"host_id"`
	InstanceID string               `json:"instance_id"`
	TargetRole patroni.InstanceRole `json:"target_role"`
}

func (*SwitchoverResource) Create

func (*SwitchoverResource) Delete

func (*SwitchoverResource) Dependencies

func (s *SwitchoverResource) Dependencies() []resource.Identifier

func (*SwitchoverResource) DiffIgnore

func (s *SwitchoverResource) DiffIgnore() []string

func (*SwitchoverResource) Executor

func (s *SwitchoverResource) Executor() resource.Executor

func (*SwitchoverResource) Identifier

func (s *SwitchoverResource) Identifier() resource.Identifier

func (*SwitchoverResource) Refresh

func (s *SwitchoverResource) Refresh(ctx context.Context, rc *resource.Context) error

func (*SwitchoverResource) ResourceVersion

func (s *SwitchoverResource) ResourceVersion() string

func (*SwitchoverResource) TypeDependencies added in v0.7.0

func (s *SwitchoverResource) TypeDependencies() []resource.Type

func (*SwitchoverResource) Update

type SyncEventResource

type SyncEventResource struct {
	DatabaseName      string                `json:"database_name"`
	ProviderNode      string                `json:"provider_node"`
	SubscriberNode    string                `json:"subscriber_node"`
	SyncEventLsn      string                `json:"sync_event_lsn"`
	ExtraDependencies []resource.Identifier `json:"extra_dependencies"`
}

func (*SyncEventResource) Create

func (r *SyncEventResource) Create(ctx context.Context, rc *resource.Context) error

func (*SyncEventResource) Delete

func (r *SyncEventResource) Delete(ctx context.Context, rc *resource.Context) error

func (*SyncEventResource) Dependencies

func (r *SyncEventResource) Dependencies() []resource.Identifier

func (*SyncEventResource) DiffIgnore

func (r *SyncEventResource) DiffIgnore() []string

func (*SyncEventResource) Executor

func (r *SyncEventResource) Executor() resource.Executor

func (*SyncEventResource) Identifier

func (r *SyncEventResource) Identifier() resource.Identifier

func (*SyncEventResource) Refresh

func (r *SyncEventResource) Refresh(ctx context.Context, rc *resource.Context) error

Confirm synchronization by sending sync_event from provider and waiting for it on subscriber

func (*SyncEventResource) ResourceVersion

func (r *SyncEventResource) ResourceVersion() string

func (*SyncEventResource) TypeDependencies added in v0.7.0

func (r *SyncEventResource) TypeDependencies() []resource.Type

func (*SyncEventResource) Update

func (r *SyncEventResource) Update(ctx context.Context, rc *resource.Context) error

type User

type User struct {
	Username   string   `json:"username"`
	Password   string   `json:"password"`
	DBOwner    bool     `json:"db_owner,omitempty"`
	Attributes []string `json:"attributes,omitempty"`
	Roles      []string `json:"roles,omitempty"`
}

func (*User) Clone

func (u *User) Clone() *User

func (*User) DefaultOptionalFieldsFrom

func (u *User) DefaultOptionalFieldsFrom(other *User)

DefaultOptionalFieldsFrom will default this user's optional fields to the values from the given user.

type ValidationResult

type ValidationResult struct {
	InstanceID string   `json:"instance_id"`
	HostID     string   `json:"host_id"`
	NodeName   string   `json:"node_name"`
	Valid      bool     `json:"valid"`
	Errors     []string `json:"errors"`
}

type WaitForSyncEventResource

type WaitForSyncEventResource struct {
	DatabaseName   string `json:"database_name"`
	SubscriberNode string `json:"subscriber_node"`
	ProviderNode   string `json:"provider_node"`
}

func (*WaitForSyncEventResource) Create

func (*WaitForSyncEventResource) Delete

func (*WaitForSyncEventResource) Dependencies

func (r *WaitForSyncEventResource) Dependencies() []resource.Identifier

func (*WaitForSyncEventResource) DiffIgnore

func (r *WaitForSyncEventResource) DiffIgnore() []string

func (*WaitForSyncEventResource) Executor

func (*WaitForSyncEventResource) Identifier

func (*WaitForSyncEventResource) Refresh

Confirm synchronization by sending sync_event from provider and waiting for it on subscriber

func (*WaitForSyncEventResource) ResourceVersion

func (r *WaitForSyncEventResource) ResourceVersion() string

func (*WaitForSyncEventResource) TypeDependencies added in v0.7.0

func (r *WaitForSyncEventResource) TypeDependencies() []resource.Type

func (*WaitForSyncEventResource) Update

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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