connection

package
v0.0.0-rc6 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Master      = Role("MASTER")
	Replica     = Role("REPLICA")
	RoleUnknown = Role("REPLICA")
)
View Source
const (
	ReplicaSync      = ReplicaType("SYNC")
	ReplicaAsync     = ReplicaType("ASYNC")
	ReplicaUndefined = ReplicaType("UNDEFINED")
)

Variables

View Source
var UninitializedResolverErr = xerrors.NewSentinel("connection resolver not initialized!")

Functions

func Init

func Init(resolver ConnResolver)

Types

type BaseSQLConnection

type BaseSQLConnection struct {
	Hosts    []*Host
	User     string
	Password model.SecretString
	// currently filled with user data, not from db list in managed connection
	Database       string
	HasTLS         bool
	CACertificates string
	ClusterID      string
}

func (*BaseSQLConnection) GetClusterID

func (b *BaseSQLConnection) GetClusterID() string

func (*BaseSQLConnection) GetPort

func (b *BaseSQLConnection) GetPort(hostName string) uint16

func (*BaseSQLConnection) GetUsername

func (b *BaseSQLConnection) GetUsername() string

func (*BaseSQLConnection) HostNames

func (b *BaseSQLConnection) HostNames() []string

func (*BaseSQLConnection) MasterHost

func (b *BaseSQLConnection) MasterHost() *Host

func (*BaseSQLConnection) Replicas

func (b *BaseSQLConnection) Replicas() []*Host

func (*BaseSQLConnection) SetHosts

func (b *BaseSQLConnection) SetHosts(hostNames []string, port int)

type ConnResolver

type ConnResolver interface {
	ResolveConnection(ctx context.Context, connectionID string, typ abstract.ProviderType) (ManagedConnection, error)
}

func Resolver

func Resolver() ConnResolver

type ConnectionCH

type ConnectionCH struct {
	// TODO: add shard params
	*BaseSQLConnection
	// field in manage connection with applicable databases, currently used for info only.
	// in the future we may want to check that DatabaseNames if defined includes Database from user input
	DatabaseNames []string
}

func (*ConnectionCH) GetDatabases

func (ch *ConnectionCH) GetDatabases() []string

type ConnectionMySQL

type ConnectionMySQL struct {
	*BaseSQLConnection
	// field in manage connection with applicable databases, currently used for info only.
	// in the future we may want to check that DatabaseNames if defined includes Database from user input
	DatabaseNames []string
}

func (*ConnectionMySQL) GetDatabases

func (m *ConnectionMySQL) GetDatabases() []string

type ConnectionPG

type ConnectionPG struct {
	*BaseSQLConnection
	// field in manage connection with applicable databases, currently used for info only.
	// in the future we may want to check that DatabaseNames if defined includes Database from user input
	DatabaseNames []string
}

func (*ConnectionPG) GetDatabases

func (pg *ConnectionPG) GetDatabases() []string

type Host

type Host struct {
	Name        string
	Port        int
	Role        Role
	ReplicaType ReplicaType
}

func SimpleHost

func SimpleHost(host string, port int) *Host

type ManagedConnection

type ManagedConnection interface {
	GetUsername() string
	GetClusterID() string
	GetDatabases() []string
	HostNames() []string
}

type ReplicaType

type ReplicaType string

type Role

type Role string

type StubConnectionResolver

type StubConnectionResolver struct {
	ConnectionsByID map[string]ManagedConnection
}

func NewStubConnectionResolver

func NewStubConnectionResolver() *StubConnectionResolver

func (*StubConnectionResolver) Add

func (d *StubConnectionResolver) Add(connectionID string, connection any) error

func (*StubConnectionResolver) ResolveConnection

func (d *StubConnectionResolver) ResolveConnection(ctx context.Context, connectionID string, typ abstract.ProviderType) (ManagedConnection, error)

type UnimplementedResolver

type UnimplementedResolver struct{}

func (UnimplementedResolver) ResolveConnection

func (u UnimplementedResolver) ResolveConnection(ctx context.Context, connectionID string, typ abstract.ProviderType) (ManagedConnection, error)

Jump to

Keyboard shortcuts

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