Documentation ¶
Index ¶
- Variables
- type AlterRoleQuery
- type AlterRoleQueryPassword
- type Client
- func (client *Client) AlterRole(query *AlterRoleQuery) error
- func (client *Client) Close() error
- func (client *Client) CreateDB(db, role string) error
- func (client *Client) CreateExtension(ext string) error
- func (client *Client) DeploySqitch(db, dir, user string) error
- func (con *Client) DropTables(query *DropTablesQuery) error
- func (client *Client) MigrateTables(from, to string, tables []string, user string, ...) error
- func (client *Client) RenameDB(to, from string) error
- func (client *Client) SetPublicSchemaRole(role string) error
- type ClientOpt
- type DropTablesQuery
- type ErrChan
- type Procedure
- type ProcedureChan
- type SerialProcedureRunner
- type StructChan
Constants ¶
This section is empty.
Variables ¶
var ErrSrcDbMissing = errors.New("source database does not exist")
Functions ¶
This section is empty.
Types ¶
type AlterRoleQuery ¶
type AlterRoleQuery struct { Role string `json:"role"` Superuser bool `json:"superuser"` NoSuperuser bool `json:"nosuperuser"` CreateDB bool `json:"createdb"` NoCreateDB bool `json:"nocreatedb"` CreateRole bool `json:"createrole"` NoCreateRole bool `json:"nocreaterole"` CreateUser bool `json:"createuser"` NoCreateUser bool `json:"nocreateuser"` Inherit bool `json:"inherit"` NoInherit bool `json:"noinherit"` Login bool `json:"login"` NoLogin bool `json:"nologin"` Replication bool `json:"replication"` NoReplication bool `json:"noreplication"` ConnectionLimit int `json:"connection_limit"` Password AlterRoleQueryPassword `json:"password"` }
AlterRoleQuery represents the available options for an ALTER ROLE query
func NewAlterRoleQuery ¶
func NewAlterRoleQuery() *AlterRoleQuery
NewAlterRoleQuery returns a pointer to a new AlterRoleQuery
func (*AlterRoleQuery) String ¶
func (o *AlterRoleQuery) String() string
String returns the options as query
type AlterRoleQueryPassword ¶
type AlterRoleQueryPassword struct { Value string `json:"value"` Unencrypted bool `json:"unencrypted"` }
AlterRoleQueryPassword represents an ALTER ROLE PASSWORD option
type Client ¶
Client represents the Postgres Sidecar Services database connection
func (*Client) AlterRole ¶
func (client *Client) AlterRole(query *AlterRoleQuery) error
AlterRole takes a rolename and role options and
func (*Client) CreateExtension ¶
CreateExtension takes a database name and role and creates a database
func (*Client) DeploySqitch ¶
DeploySqitch takes a connection database name and sqitch directory and runs sqitch
func (*Client) DropTables ¶
func (con *Client) DropTables(query *DropTablesQuery) error
DropTables takes a DropTablesQuery and executes it
func (*Client) MigrateTables ¶
func (client *Client) MigrateTables(from, to string, tables []string, user string, failIfSrcMissing, skipCreate bool) error
MigrateTables migrates tables from a given database to another
func (*Client) RenameDB ¶
RenameDB takes an existing database name and a desired name and renames the database if it exists
func (*Client) SetPublicSchemaRole ¶
SetPublicSchemaRole change the owner of all tables in the public and sqitch schemas to the given role name
type ClientOpt ¶
type ClientOpt func(*Client)
ClientOpt are functional arguments used when creating a new connection
func WithPlatformConfig ¶
func WithPlatformConfig(platformConfig *platform_config.Config) ClientOpt
WithPlatformConfig sets the platform config to use
type DropTablesQuery ¶
DropTablesQuery represents the available options for an ALTER ROLE query
func NewDropTablesQuery ¶
func NewDropTablesQuery() *DropTablesQuery
NewDropTablesQuery returns a pointer to a new AlterRoleQuery
func (*DropTablesQuery) String ¶
func (q *DropTablesQuery) String() string
String returns the query as SQL
type ErrChan ¶
type ErrChan struct { C chan error // contains filtered or unexported fields }
ErrChan is a close() safe error chan
func NewErrChan ¶
NewErrChan takes a buffer length and returns a buffered ErrChan
type Procedure ¶
type Procedure interface { // Ctx returns the context for deadlines and cancellation Ctx() context.Context // FinishedC returns a channel that will be closed if the procedure // completes successfully FinishedC() *StructChan // ErrC returns a channel which will return an error if the procedure // fails ErrC() *ErrChan // Run runs the procedure's work function Run() error // Wait takes a timeout waits for the procedure to complete. It will return // any error that it encounters on the ErrC or if the timeout is rea // an error if the Ctx deadline is reached. Wait() error // Close performs any cleanup actions that need to be performed Close() }
Procedure in an interface that describes a unit of work that the SerialProcedureRunner can run.
type ProcedureChan ¶
type ProcedureChan struct { C chan Procedure // contains filtered or unexported fields }
ProcedureChan is a close() safe SerialProcedure chan
func NewProcedureChan ¶
func NewProcedureChan(buffer int) *ProcedureChan
NewProcedureChan takes a buffer length and returns a buffered ProcedureChan
func (*ProcedureChan) Close ¶
func (c *ProcedureChan) Close()
Close safely closes the embedded channel once to prevent a panic if it is called multiple times.
type SerialProcedureRunner ¶
type SerialProcedureRunner struct { C *ProcedureChan // contains filtered or unexported fields }
SerialProcedureRunner runs SerialProcedure's in sequentially and serially. This allows us to queue database operations and wait for them to complete using channels instead of mutexes.
func NewSerialProcedureRunner ¶
func NewSerialProcedureRunner() *SerialProcedureRunner
NewSerialProcedureRunner returns a default SerialProcedureRunner
func (*SerialProcedureRunner) Start ¶
func (r *SerialProcedureRunner) Start()
Start starts the SerialProcedureRunner. It listens on it's channel and processes SerialProcedure's serially without requiring a mutex.
func (*SerialProcedureRunner) Stop ¶
func (r *SerialProcedureRunner) Stop()
Stop terminates the SerialProcedureRunner's processing goroutine
type StructChan ¶
type StructChan struct { C chan struct{} // contains filtered or unexported fields }
StructChan is a close() safe struct chan
func NewStructChan ¶
func NewStructChan(buffer int) *StructChan
NewStructChan takes a buffer length and returns a buffered StructChan
func (*StructChan) Close ¶
func (c *StructChan) Close()
Close safely closes the embedded channel once to prevent a panic if it is called multiple times.