Documentation
¶
Overview ¶
Package postgres provides functions to handle postgres in cnpg clusters
Index ¶
- Constants
- func BumpPostgresImageMajorVersion(postgresImage string) (string, error)
- func CountReplicas(ctx context.Context, crudClient client.Client, ...) (int, error)
- func GetCurrentTimestamp(ctx context.Context, crudClient client.Client, ...) (string, error)
- func RunExecOverForward(ctx context.Context, crudClient client.Client, ...) (sql.Result, error)
- func RunQueryRowOverForward(ctx context.Context, crudClient client.Client, ...) (*sql.Row, error)
- type PSQLForwardConnection
- func ForwardPSQLConnection(ctx context.Context, crudClient client.Client, ...) (*PSQLForwardConnection, *sql.DB, error)
- func ForwardPSQLConnectionWithCreds(ctx context.Context, crudClient client.Client, ...) (*PSQLForwardConnection, *sql.DB, error)
- func ForwardPSQLServiceConnection(ctx context.Context, kubeInterface kubernetes.Interface, ...) (*PSQLForwardConnection, *sql.DB, error)
Constants ¶
const ( // PGLocalSocketDir is the directory containing the PostgreSQL local socket PGLocalSocketDir = "/controller/run" // AppUser for app user AppUser = "app" // PostgresUser for postgres user PostgresUser = "postgres" // AppDBName database name app AppDBName = "app" // PostgresDBName database name postgres PostgresDBName = "postgres" // TablespaceDefaultName is the default tablespace location TablespaceDefaultName = "pg_default" )
Variables ¶
This section is empty.
Functions ¶
func BumpPostgresImageMajorVersion ¶
BumpPostgresImageMajorVersion returns a postgresImage incrementing the major version of the argument (if available)
func CountReplicas ¶
func CountReplicas( ctx context.Context, crudClient client.Client, kubeInterface kubernetes.Interface, restConfig *rest.Config, pod *corev1.Pod, retryTimeout int, ) (int, error)
CountReplicas counts the number of replicas attached to an instance
func GetCurrentTimestamp ¶
func GetCurrentTimestamp( ctx context.Context, crudClient client.Client, kubeInterface kubernetes.Interface, restConfig *rest.Config, namespace, clusterName string, ) (string, error)
GetCurrentTimestamp getting current time stamp from postgres server
func RunExecOverForward ¶
func RunExecOverForward( ctx context.Context, crudClient client.Client, kubeInterface kubernetes.Interface, restConfig *rest.Config, namespace, clusterName, dbname, secretSuffix, query string, ) (sql.Result, error)
RunExecOverForward runs Exec with a given query, returning the Result of the SQL command
func RunQueryRowOverForward ¶
func RunQueryRowOverForward( ctx context.Context, crudClient client.Client, kubeInterface kubernetes.Interface, restConfig *rest.Config, namespace, clusterName, dbname, secretSuffix, query string, ) (*sql.Row, error)
RunQueryRowOverForward runs QueryRow with a given query, returning the Row of the SQL command
Types ¶
type PSQLForwardConnection ¶
type PSQLForwardConnection struct {
// contains filtered or unexported fields
}
PSQLForwardConnection manages the creation of a port-forwarding to open a new database connection
func ForwardPSQLConnection ¶
func ForwardPSQLConnection( ctx context.Context, crudClient client.Client, kubeInterface kubernetes.Interface, restConfig *rest.Config, namespace, clusterName, dbname, secretSuffix string, ) (*PSQLForwardConnection, *sql.DB, error)
ForwardPSQLConnection simplifies the creation of forwarded connection to PostgreSQL cluster
func ForwardPSQLConnectionWithCreds ¶
func ForwardPSQLConnectionWithCreds( ctx context.Context, crudClient client.Client, kubeInterface kubernetes.Interface, restConfig *rest.Config, namespace, clusterName, dbname, userApp, passApp string, ) (*PSQLForwardConnection, *sql.DB, error)
ForwardPSQLConnectionWithCreds creates a forwarded connection to a PostgreSQL cluster using the given credentials
func ForwardPSQLServiceConnection ¶
func ForwardPSQLServiceConnection( ctx context.Context, kubeInterface kubernetes.Interface, restConfig *rest.Config, namespace, serviceName, dbname, userApp, passApp string, ) (*PSQLForwardConnection, *sql.DB, error)
ForwardPSQLServiceConnection creates a forwarded connection to a PostgreSQL service using the given credentials
func (*PSQLForwardConnection) Close ¶
func (psqlc *PSQLForwardConnection) Close()
Close will stop the port-forwarding and exit
func (*PSQLForwardConnection) GetPooler ¶
func (psqlc *PSQLForwardConnection) GetPooler() pool.Pooler
GetPooler returns the connection Pooler