postgres

package
v0.0.0-...-28e1e40 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package postgres implements the storage.Store interface using PostgreSQL.

This is the HA storage driver for multi-instance EdgeFabric controller deployments. It uses pgx via the database/sql compatibility layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration struct {
	SQL         string
	Description string
}

Migration describes a single schema migration step.

type PostgresStore

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

PostgresStore implements storage.Store using PostgreSQL.

func New

func New(dsn string) (*PostgresStore, error)

New creates a new PostgreSQL store with connection pooling.

func (*PostgresStore) AddNodeToGroup

func (s *PostgresStore) AddNodeToGroup(ctx context.Context, groupID, nodeID domain.ID) error

func (*PostgresStore) Close

func (s *PostgresStore) Close() error

Close closes the database connection pool.

func (*PostgresStore) CreateAPIKey

func (s *PostgresStore) CreateAPIKey(ctx context.Context, k *domain.APIKey) error

func (*PostgresStore) CreateAuditEvent

func (s *PostgresStore) CreateAuditEvent(ctx context.Context, e *domain.AuditEvent) error

func (*PostgresStore) CreateBGPSession

func (s *PostgresStore) CreateBGPSession(ctx context.Context, sess *domain.BGPSession) error

func (*PostgresStore) CreateCDNOrigin

func (s *PostgresStore) CreateCDNOrigin(ctx context.Context, o *domain.CDNOrigin) error

func (*PostgresStore) CreateCDNSite

func (s *PostgresStore) CreateCDNSite(ctx context.Context, site *domain.CDNSite) error

func (*PostgresStore) CreateDNSRecord

func (s *PostgresStore) CreateDNSRecord(ctx context.Context, r *domain.DNSRecord) error

func (*PostgresStore) CreateDNSZone

func (s *PostgresStore) CreateDNSZone(ctx context.Context, z *domain.DNSZone) error

func (*PostgresStore) CreateEnrollmentToken

func (s *PostgresStore) CreateEnrollmentToken(ctx context.Context, t *domain.EnrollmentToken) error

func (*PostgresStore) CreateGateway

func (s *PostgresStore) CreateGateway(ctx context.Context, g *domain.Gateway) error

func (*PostgresStore) CreateIPAllocation

func (s *PostgresStore) CreateIPAllocation(ctx context.Context, ip *domain.IPAllocation) error

func (*PostgresStore) CreateNode

func (s *PostgresStore) CreateNode(ctx context.Context, n *domain.Node) error

func (*PostgresStore) CreateNodeGroup

func (s *PostgresStore) CreateNodeGroup(ctx context.Context, g *domain.NodeGroup) error

func (*PostgresStore) CreateProvisioningJob

func (s *PostgresStore) CreateProvisioningJob(ctx context.Context, j *domain.ProvisioningJob) error

func (*PostgresStore) CreateRoute

func (s *PostgresStore) CreateRoute(ctx context.Context, r *domain.Route) error

func (*PostgresStore) CreateSSHKey

func (s *PostgresStore) CreateSSHKey(ctx context.Context, k *domain.SSHKey) error

func (*PostgresStore) CreateTLSCertificate

func (s *PostgresStore) CreateTLSCertificate(ctx context.Context, c *domain.TLSCertificate) error

func (*PostgresStore) CreateTenant

func (s *PostgresStore) CreateTenant(ctx context.Context, t *domain.Tenant) error

func (*PostgresStore) CreateUser

func (s *PostgresStore) CreateUser(ctx context.Context, u *domain.User) error

func (*PostgresStore) CreateWireGuardPeer

func (s *PostgresStore) CreateWireGuardPeer(ctx context.Context, p *domain.WireGuardPeer) error

func (*PostgresStore) DB

func (s *PostgresStore) DB() *sql.DB

DB returns the underlying *sql.DB for use by the leader elector. Advisory locks require a dedicated connection from the same pool.

func (*PostgresStore) DeleteAPIKey

func (s *PostgresStore) DeleteAPIKey(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteBGPSession

func (s *PostgresStore) DeleteBGPSession(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteCDNOrigin

func (s *PostgresStore) DeleteCDNOrigin(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteCDNSite

func (s *PostgresStore) DeleteCDNSite(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteDNSRecord

func (s *PostgresStore) DeleteDNSRecord(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteDNSZone

func (s *PostgresStore) DeleteDNSZone(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteGateway

func (s *PostgresStore) DeleteGateway(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteIPAllocation

func (s *PostgresStore) DeleteIPAllocation(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteNode

func (s *PostgresStore) DeleteNode(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteNodeGroup

func (s *PostgresStore) DeleteNodeGroup(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteRoute

func (s *PostgresStore) DeleteRoute(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteSSHKey

func (s *PostgresStore) DeleteSSHKey(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteTLSCertificate

func (s *PostgresStore) DeleteTLSCertificate(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteTenant

func (s *PostgresStore) DeleteTenant(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteUser

func (s *PostgresStore) DeleteUser(ctx context.Context, id domain.ID) error

func (*PostgresStore) DeleteWireGuardPeer

func (s *PostgresStore) DeleteWireGuardPeer(ctx context.Context, id domain.ID) error

func (*PostgresStore) GetAPIKey

func (s *PostgresStore) GetAPIKey(ctx context.Context, id domain.ID) (*domain.APIKey, error)

func (*PostgresStore) GetAPIKeyByPrefix

func (s *PostgresStore) GetAPIKeyByPrefix(ctx context.Context, prefix string) (*domain.APIKey, error)

func (*PostgresStore) GetActiveProvisioningJob

func (s *PostgresStore) GetActiveProvisioningJob(ctx context.Context, nodeID domain.ID) (*domain.ProvisioningJob, error)

func (*PostgresStore) GetBGPSession

func (s *PostgresStore) GetBGPSession(ctx context.Context, id domain.ID) (*domain.BGPSession, error)

func (*PostgresStore) GetCDNOrigin

func (s *PostgresStore) GetCDNOrigin(ctx context.Context, id domain.ID) (*domain.CDNOrigin, error)

func (*PostgresStore) GetCDNSite

func (s *PostgresStore) GetCDNSite(ctx context.Context, id domain.ID) (*domain.CDNSite, error)

func (*PostgresStore) GetDNSRecord

func (s *PostgresStore) GetDNSRecord(ctx context.Context, id domain.ID) (*domain.DNSRecord, error)

func (*PostgresStore) GetDNSZone

func (s *PostgresStore) GetDNSZone(ctx context.Context, id domain.ID) (*domain.DNSZone, error)

func (*PostgresStore) GetEnrollmentToken

func (s *PostgresStore) GetEnrollmentToken(ctx context.Context, token string) (*domain.EnrollmentToken, error)

func (*PostgresStore) GetGateway

func (s *PostgresStore) GetGateway(ctx context.Context, id domain.ID) (*domain.Gateway, error)

func (*PostgresStore) GetIPAllocation

func (s *PostgresStore) GetIPAllocation(ctx context.Context, id domain.ID) (*domain.IPAllocation, error)

func (*PostgresStore) GetNode

func (s *PostgresStore) GetNode(ctx context.Context, id domain.ID) (*domain.Node, error)

func (*PostgresStore) GetNodeGroup

func (s *PostgresStore) GetNodeGroup(ctx context.Context, id domain.ID) (*domain.NodeGroup, error)

func (*PostgresStore) GetProvisioningJob

func (s *PostgresStore) GetProvisioningJob(ctx context.Context, id domain.ID) (*domain.ProvisioningJob, error)

func (*PostgresStore) GetRoute

func (s *PostgresStore) GetRoute(ctx context.Context, id domain.ID) (*domain.Route, error)

func (*PostgresStore) GetSSHKey

func (s *PostgresStore) GetSSHKey(ctx context.Context, id domain.ID) (*domain.SSHKey, error)

func (*PostgresStore) GetTLSCertificate

func (s *PostgresStore) GetTLSCertificate(ctx context.Context, id domain.ID) (*domain.TLSCertificate, error)

func (*PostgresStore) GetTenant

func (s *PostgresStore) GetTenant(ctx context.Context, id domain.ID) (*domain.Tenant, error)

func (*PostgresStore) GetTenantBySlug

func (s *PostgresStore) GetTenantBySlug(ctx context.Context, slug string) (*domain.Tenant, error)

func (*PostgresStore) GetUser

func (s *PostgresStore) GetUser(ctx context.Context, id domain.ID) (*domain.User, error)

func (*PostgresStore) GetUserByEmail

func (s *PostgresStore) GetUserByEmail(ctx context.Context, email string) (*domain.User, error)

func (*PostgresStore) GetWireGuardPeer

func (s *PostgresStore) GetWireGuardPeer(ctx context.Context, id domain.ID) (*domain.WireGuardPeer, error)

func (*PostgresStore) GetWireGuardPeerByOwner

func (s *PostgresStore) GetWireGuardPeerByOwner(ctx context.Context, ownerType domain.PeerOwnerType, ownerID domain.ID) (*domain.WireGuardPeer, error)

func (*PostgresStore) IncrementDNSZoneSerial

func (s *PostgresStore) IncrementDNSZoneSerial(ctx context.Context, id domain.ID) error

func (*PostgresStore) ListAPIKeys

func (s *PostgresStore) ListAPIKeys(ctx context.Context, tenantID domain.ID, params storage.ListParams) ([]*domain.APIKey, int, error)

func (*PostgresStore) ListAuditEvents

func (s *PostgresStore) ListAuditEvents(ctx context.Context, tenantID *domain.ID, params storage.ListParams) ([]*domain.AuditEvent, int, error)

func (*PostgresStore) ListBGPSessions

func (s *PostgresStore) ListBGPSessions(ctx context.Context, nodeID domain.ID, params storage.ListParams) ([]*domain.BGPSession, int, error)

func (*PostgresStore) ListCDNOrigins

func (s *PostgresStore) ListCDNOrigins(ctx context.Context, siteID domain.ID, params storage.ListParams) ([]*domain.CDNOrigin, int, error)

func (*PostgresStore) ListCDNSites

func (s *PostgresStore) ListCDNSites(ctx context.Context, tenantID domain.ID, params storage.ListParams) ([]*domain.CDNSite, int, error)

func (*PostgresStore) ListDNSRecords

func (s *PostgresStore) ListDNSRecords(ctx context.Context, zoneID domain.ID, params storage.ListParams) ([]*domain.DNSRecord, int, error)

func (*PostgresStore) ListDNSZones

func (s *PostgresStore) ListDNSZones(ctx context.Context, tenantID domain.ID, params storage.ListParams) ([]*domain.DNSZone, int, error)

func (*PostgresStore) ListGateways

func (s *PostgresStore) ListGateways(ctx context.Context, tenantID *domain.ID, params storage.ListParams) ([]*domain.Gateway, int, error)

func (*PostgresStore) ListGroupNodes

func (s *PostgresStore) ListGroupNodes(ctx context.Context, groupID domain.ID) ([]*domain.Node, error)

func (*PostgresStore) ListIPAllocations

func (s *PostgresStore) ListIPAllocations(ctx context.Context, tenantID domain.ID, params storage.ListParams) ([]*domain.IPAllocation, int, error)

func (*PostgresStore) ListNodeGroups

func (s *PostgresStore) ListNodeGroups(ctx context.Context, tenantID domain.ID, params storage.ListParams) ([]*domain.NodeGroup, int, error)

func (*PostgresStore) ListNodeGroups_ByNode

func (s *PostgresStore) ListNodeGroups_ByNode(ctx context.Context, nodeID domain.ID) ([]*domain.NodeGroup, error)

func (*PostgresStore) ListNodes

func (s *PostgresStore) ListNodes(ctx context.Context, tenantID *domain.ID, params storage.ListParams) ([]*domain.Node, int, error)

func (*PostgresStore) ListProvisioningJobs

func (s *PostgresStore) ListProvisioningJobs(ctx context.Context, nodeID *domain.ID, params storage.ListParams) ([]*domain.ProvisioningJob, int, error)

func (*PostgresStore) ListRoutes

func (s *PostgresStore) ListRoutes(ctx context.Context, tenantID domain.ID, params storage.ListParams) ([]*domain.Route, int, error)

func (*PostgresStore) ListRoutesByGateway

func (s *PostgresStore) ListRoutesByGateway(ctx context.Context, gatewayID domain.ID) ([]*domain.Route, error)

func (*PostgresStore) ListSSHKeys

func (s *PostgresStore) ListSSHKeys(ctx context.Context, params storage.ListParams) ([]*domain.SSHKey, int, error)

func (*PostgresStore) ListTLSCertificates

func (s *PostgresStore) ListTLSCertificates(ctx context.Context, tenantID domain.ID, params storage.ListParams) ([]*domain.TLSCertificate, int, error)

func (*PostgresStore) ListTenants

func (s *PostgresStore) ListTenants(ctx context.Context, params storage.ListParams) ([]*domain.Tenant, int, error)

func (*PostgresStore) ListUsers

func (s *PostgresStore) ListUsers(ctx context.Context, tenantID *domain.ID, params storage.ListParams) ([]*domain.User, int, error)

func (*PostgresStore) ListWireGuardPeers

func (s *PostgresStore) ListWireGuardPeers(ctx context.Context, params storage.ListParams) ([]*domain.WireGuardPeer, int, error)

func (*PostgresStore) MarkEnrollmentTokenUsed

func (s *PostgresStore) MarkEnrollmentTokenUsed(ctx context.Context, id domain.ID) error

func (*PostgresStore) Migrate

func (s *PostgresStore) Migrate(ctx context.Context) error

Migrate runs database migrations to ensure the schema is current.

func (*PostgresStore) Ping

func (s *PostgresStore) Ping(ctx context.Context) error

Ping checks database connectivity.

func (*PostgresStore) RemoveNodeFromGroup

func (s *PostgresStore) RemoveNodeFromGroup(ctx context.Context, groupID, nodeID domain.ID) error

func (*PostgresStore) SchemaVersion

func (s *PostgresStore) SchemaVersion(ctx context.Context) (int, error)

SchemaVersion returns the latest applied schema version number.

func (*PostgresStore) UpdateAPIKeyLastUsed

func (s *PostgresStore) UpdateAPIKeyLastUsed(ctx context.Context, id domain.ID) error

func (*PostgresStore) UpdateBGPSession

func (s *PostgresStore) UpdateBGPSession(ctx context.Context, sess *domain.BGPSession) error

func (*PostgresStore) UpdateCDNOrigin

func (s *PostgresStore) UpdateCDNOrigin(ctx context.Context, o *domain.CDNOrigin) error

func (*PostgresStore) UpdateCDNSite

func (s *PostgresStore) UpdateCDNSite(ctx context.Context, site *domain.CDNSite) error

func (*PostgresStore) UpdateDNSRecord

func (s *PostgresStore) UpdateDNSRecord(ctx context.Context, r *domain.DNSRecord) error

func (*PostgresStore) UpdateDNSZone

func (s *PostgresStore) UpdateDNSZone(ctx context.Context, z *domain.DNSZone) error

func (*PostgresStore) UpdateGateway

func (s *PostgresStore) UpdateGateway(ctx context.Context, g *domain.Gateway) error

func (*PostgresStore) UpdateGatewayConfigSync

func (s *PostgresStore) UpdateGatewayConfigSync(ctx context.Context, id domain.ID) error

func (*PostgresStore) UpdateGatewayHeartbeat

func (s *PostgresStore) UpdateGatewayHeartbeat(ctx context.Context, id domain.ID) error

func (*PostgresStore) UpdateIPAllocation

func (s *PostgresStore) UpdateIPAllocation(ctx context.Context, ip *domain.IPAllocation) error

func (*PostgresStore) UpdateNode

func (s *PostgresStore) UpdateNode(ctx context.Context, n *domain.Node) error

func (*PostgresStore) UpdateNodeConfigSync

func (s *PostgresStore) UpdateNodeConfigSync(ctx context.Context, id domain.ID) error

func (*PostgresStore) UpdateNodeGroup

func (s *PostgresStore) UpdateNodeGroup(ctx context.Context, g *domain.NodeGroup) error

func (*PostgresStore) UpdateNodeHeartbeat

func (s *PostgresStore) UpdateNodeHeartbeat(ctx context.Context, id domain.ID) error

func (*PostgresStore) UpdateProvisioningJob

func (s *PostgresStore) UpdateProvisioningJob(ctx context.Context, j *domain.ProvisioningJob) error

func (*PostgresStore) UpdateRoute

func (s *PostgresStore) UpdateRoute(ctx context.Context, r *domain.Route) error

func (*PostgresStore) UpdateSSHKey

func (s *PostgresStore) UpdateSSHKey(ctx context.Context, k *domain.SSHKey) error

func (*PostgresStore) UpdateTenant

func (s *PostgresStore) UpdateTenant(ctx context.Context, t *domain.Tenant) error

func (*PostgresStore) UpdateUser

func (s *PostgresStore) UpdateUser(ctx context.Context, u *domain.User) error

func (*PostgresStore) UpdateWireGuardPeer

func (s *PostgresStore) UpdateWireGuardPeer(ctx context.Context, p *domain.WireGuardPeer) error

Jump to

Keyboard shortcuts

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