connection

package
v0.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 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 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 {
}

func (*ConnectionCH) IsManagedConnection

func (pg *ConnectionCH) IsManagedConnection()

type ConnectionPG

type ConnectionPG struct {
	Hosts          []*Host
	User           string
	Password       model.SecretString
	Database       string
	HasTLS         bool
	CACertificates string
	ClusterID      string
}

func (*ConnectionPG) GetPort

func (pg *ConnectionPG) GetPort(hostName string) uint16

func (*ConnectionPG) HostNames

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

func (*ConnectionPG) IsManagedConnection

func (pg *ConnectionPG) IsManagedConnection()

func (*ConnectionPG) MasterHost

func (pg *ConnectionPG) MasterHost() *Host

func (*ConnectionPG) Replicas

func (pg *ConnectionPG) Replicas() []*Host

func (*ConnectionPG) SetHosts

func (pg *ConnectionPG) SetHosts(hostNames []string, port int)

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 {
	IsManagedConnection()
}

type MockConnectionResolver

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

func NewMockConnectionResolver

func NewMockConnectionResolver() *MockConnectionResolver

func (*MockConnectionResolver) Add

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

func (*MockConnectionResolver) GetCHConnection

func (d *MockConnectionResolver) GetCHConnection(ctx context.Context, connectionID string) (conn *ConnectionCH, err error)

func (*MockConnectionResolver) GetConnection

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

func (*MockConnectionResolver) GetPGConnection

func (d *MockConnectionResolver) GetPGConnection(ctx context.Context, connectionID string) (*ConnectionPG, error)

func (*MockConnectionResolver) ResolveCHConnection

func (d *MockConnectionResolver) ResolveCHConnection(ctx context.Context, connectionID string) (conn *ConnectionCH, err error)

func (*MockConnectionResolver) ResolveClusterOrHosts

func (d *MockConnectionResolver) ResolveClusterOrHosts(ctx context.Context, connectionID string) (string, []string, error)

func (*MockConnectionResolver) ResolveConnection

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

func (*MockConnectionResolver) ResolveConnectionFolder

func (d *MockConnectionResolver) ResolveConnectionFolder(ctx context.Context, connectionID string) (string, error)

func (*MockConnectionResolver) ResolvePGConnection

func (d *MockConnectionResolver) ResolvePGConnection(ctx context.Context, connectionID string) (conn *ConnectionPG, err error)

func (*MockConnectionResolver) ResolveProviderType

func (d *MockConnectionResolver) ResolveProviderType(ctx context.Context, connectionID string) (abstract.ProviderType, error)

type ReplicaType

type ReplicaType string

type Role

type Role string

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