client

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWaitReplicaTimeout = errors.New("timeout waiting for replica to be synced")
)

Functions

func BuildDSN

func BuildDSN(opts Opts) (string, error)

func Connect

func Connect(dsn string) (*sql.DB, error)

func ConnectWithOpts added in v0.0.20

func ConnectWithOpts(opts Opts) (*sql.DB, error)

Types

type ChangeMasterOpts

type ChangeMasterOpts struct {
	Connection string
	Host       string
	User       string
	Password   string
	Gtid       string
	Retries    int
}

type Client

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

func NewClient

func NewClient(clientOpts ...Opt) (*Client, error)

func NewClientWithMariaDB added in v0.0.16

func NewClientWithMariaDB(ctx context.Context, mariadb *mariadbv1alpha1.MariaDB, refResolver *refresolver.RefResolver,
	clientOpts ...Opt) (*Client, error)

func NewInternalClientWithPodIndex added in v0.0.16

func NewInternalClientWithPodIndex(ctx context.Context, mariadb *mariadbv1alpha1.MariaDB, refResolver *refresolver.RefResolver,
	podIndex int, clientOpts ...Opt) (*Client, error)

func (*Client) AlterUser added in v0.0.20

func (c *Client) AlterUser(ctx context.Context, username, password string) error

func (*Client) ChangeMaster

func (c *Client) ChangeMaster(ctx context.Context, opts *ChangeMasterOpts) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, database string, opts DatabaseOpts) error

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, accountName string, opts CreateUserOpts) error

func (*Client) DisableReadOnly added in v0.0.15

func (c *Client) DisableReadOnly(ctx context.Context) error

func (*Client) DropDatabase

func (c *Client) DropDatabase(ctx context.Context, database string) error

func (*Client) DropUser

func (c *Client) DropUser(ctx context.Context, accountName string) error

func (*Client) EnableReadOnly added in v0.0.16

func (c *Client) EnableReadOnly(ctx context.Context) error

func (*Client) Exec

func (c *Client) Exec(ctx context.Context, sql string, args ...any) error

func (*Client) ExecFlushingPrivileges added in v0.0.13

func (c *Client) ExecFlushingPrivileges(ctx context.Context, sql string, args ...any) error

func (*Client) FlushPrivileges

func (c *Client) FlushPrivileges(ctx context.Context) error

func (*Client) GaleraClusterSize added in v0.0.16

func (c *Client) GaleraClusterSize(ctx context.Context) (int, error)

func (*Client) GaleraClusterStatus added in v0.0.16

func (c *Client) GaleraClusterStatus(ctx context.Context) (string, error)

func (*Client) GaleraLocalState added in v0.0.16

func (c *Client) GaleraLocalState(ctx context.Context) (string, error)

func (*Client) Grant

func (c *Client) Grant(
	ctx context.Context,
	privileges []string,
	database string,
	table string,
	accountName string,
	opts ...GrantOption,
) error

func (*Client) ResetAllSlaves

func (c *Client) ResetAllSlaves(ctx context.Context) error

func (*Client) ResetMaster

func (c *Client) ResetMaster(ctx context.Context) error

func (*Client) ResetSlavePos

func (c *Client) ResetSlavePos(ctx context.Context) error

func (*Client) Revoke

func (c *Client) Revoke(
	ctx context.Context,
	privileges []string,
	database string,
	table string,
	accountName string,
	opts ...GrantOption,
) error

func (*Client) SetSystemVariable added in v0.0.16

func (c *Client) SetSystemVariable(ctx context.Context, variable string, value string) error

func (*Client) SetSystemVariables added in v0.0.16

func (c *Client) SetSystemVariables(ctx context.Context, keyVal map[string]string) error

func (*Client) StartSlave

func (c *Client) StartSlave(ctx context.Context, connName string) error

func (*Client) StatusVariable added in v0.0.16

func (c *Client) StatusVariable(ctx context.Context, variable string) (string, error)

func (*Client) StatusVariableInt added in v0.0.16

func (c *Client) StatusVariableInt(ctx context.Context, variable string) (int, error)

func (*Client) StopAllSlaves

func (c *Client) StopAllSlaves(ctx context.Context) error

func (*Client) SystemVariable added in v0.0.16

func (c *Client) SystemVariable(ctx context.Context, variable string) (string, error)

func (*Client) UserExists added in v0.0.20

func (c *Client) UserExists(ctx context.Context, username string) (bool, error)

func (*Client) WaitForReplicaGtid

func (c *Client) WaitForReplicaGtid(ctx context.Context, gtid string, timeout time.Duration) error

type ClientSet added in v0.0.16

type ClientSet struct {
	Mariadb *mariadbv1alpha1.MariaDB
	// contains filtered or unexported fields
}

func NewClientSet added in v0.0.16

func NewClientSet(mariadb *mariadbv1alpha1.MariaDB, refResolver *refresolver.RefResolver) *ClientSet

func (*ClientSet) ClientForIndex added in v0.0.16

func (c *ClientSet) ClientForIndex(ctx context.Context, index int, clientOpts ...Opt) (*Client, error)

func (*ClientSet) Close added in v0.0.16

func (c *ClientSet) Close() error

type CreateUserOpts

type CreateUserOpts struct {
	IdentifiedBy       string
	MaxUserConnections int32
}

type DatabaseOpts

type DatabaseOpts struct {
	CharacterSet string
	Collate      string
}

type GrantOption added in v0.0.20

type GrantOption func(*grantOpts)

func WithGrantOption added in v0.0.20

func WithGrantOption() GrantOption

type Opt added in v0.0.16

type Opt func(*Opts)

func WitHost added in v0.0.16

func WitHost(host string) Opt

func WithDatabase added in v0.0.16

func WithDatabase(database string) Opt

func WithParams added in v0.0.16

func WithParams(params map[string]string) Opt

func WithPassword added in v0.0.16

func WithPassword(password string) Opt

func WithPort added in v0.0.16

func WithPort(port int32) Opt

func WithUsername added in v0.0.16

func WithUsername(username string) Opt

type Opts

type Opts struct {
	Username string
	Password string
	Host     string
	Port     int32
	Database string
	Params   map[string]string
}

Jump to

Keyboard shortcuts

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