connection

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConnectionString = errors.New("connection: invalid connection string")
	ErrImportUnavailable       = errors.New("connection: import unavailable")
)
View Source
var (
	ErrDatabaseUnavailable = errors.New("connection: database unavailable")
	ErrDatabaseNotFound    = errors.New("connection: database not found")
	ErrDefinitionNotFound  = errors.New("connection: definition not found")
)
View Source
var (
	ErrAdapterNotFound = errors.New("connection: adapter not found")
)
View Source
var ErrInvalidDefinition = errors.New("connection: invalid definition")

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Kind() Kind
	ParseConnectionString([]byte) (ParsedConnection, error)
}

type AdapterResolver

type AdapterResolver interface {
	Resolve(Kind) (Adapter, error)
}

type CleanupWarning

type CleanupWarning func(databaseID ID, category string)

type Connector

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

func NewConnector

func NewConnector(adapters ...Adapter) (*Connector, error)

func (*Connector) Resolve

func (c *Connector) Resolve(kind Kind) (Adapter, error)

type Definition

type Definition struct {
	ID         ID                          `json:"id"`
	Kind       Kind                        `json:"kind"`
	Settings   map[string]string           `json:"settings"`
	SecretRefs map[string]secret.Reference `json:"secretRefs"`
}

func (Definition) Clone

func (d Definition) Clone() Definition

func (Definition) Validate

func (d Definition) Validate() error

type DefinitionRegistrar

type DefinitionRegistrar interface {
	Register(Definition) (RegistrationResult, error)
}

type DefinitionRepository

type DefinitionRepository interface {
	Lookup(context.Context, ID) (Definition, error)
	Upsert(context.Context, Definition) error
}

type ID

type ID string

func (ID) Validate

func (id ID) Validate() error

type ImportRequest

type ImportRequest struct {
	ID               ID
	Kind             Kind
	ConnectionString []byte
}

type ImportResult

type ImportResult struct {
	ID                 ID
	IsUpdated          bool
	IsConnectionTested bool
}

type Importer

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

func NewImporter

func NewImporter(dependencies ImporterDependencies) (*Importer, error)

func (*Importer) Import

func (i *Importer) Import(ctx context.Context, request ImportRequest) (ImportResult, error)

type ImporterDependencies

type ImporterDependencies struct {
	Adapters    AdapterResolver
	Secrets     SecretWriter
	Definitions DefinitionRepository
	Registrar   DefinitionRegistrar
	Warn        CleanupWarning
}

type Kind

type Kind string

type Manager

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

func NewManager

func NewManager(resolver SecretResolver, definitions []Definition) (*Manager, error)

func (*Manager) List

func (m *Manager) List() []Definition

func (*Manager) Lookup

func (m *Manager) Lookup(id ID) (Definition, error)

func (*Manager) Prepare

func (m *Manager) Prepare(ctx context.Context, id ID) (ResolvedDefinition, error)

func (*Manager) Register

func (m *Manager) Register(definition Definition) (RegistrationResult, error)

type ParsedConnection

type ParsedConnection struct {
	Settings map[string]string
	Secrets  map[string][]byte
}

func (ParsedConnection) Clone

type RegistrationResult

type RegistrationResult struct {
	Previous Definition
	Replaced bool
}

type ResolvedDefinition

type ResolvedDefinition struct {
	ID       ID
	Kind     Kind
	Settings map[string]string
	Secrets  map[string][]byte
}

func (ResolvedDefinition) Clone

type SecretResolver

type SecretResolver interface {
	Resolve(context.Context, secret.Reference) ([]byte, error)
}

type SecretWriter

type SecretWriter interface {
	Store(context.Context, []byte) (secret.Reference, error)
	Delete(context.Context, secret.Reference) error
}

Directories

Path Synopsis
Package mysql implements the MySQL relational connector.
Package mysql implements the MySQL relational connector.
Package postgres parses PostgreSQL connection imports and owns their cached runtime pools.
Package postgres parses PostgreSQL connection imports and owns their cached runtime pools.
Package sqlite implements the SQLite connector edge.
Package sqlite implements the SQLite connector edge.

Jump to

Keyboard shortcuts

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