github.com/blend/go-sdk@v1.20220411.3/db/constants.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package db
     9  
    10  import (
    11  	"time"
    12  )
    13  
    14  const (
    15  	// DefaultEngine is the default database engine.
    16  	DefaultEngine = "pgx" // "postgres"
    17  
    18  	// EnvVarDBEngine is the environment variable used to set the Go `sql` driver.
    19  	EnvVarDBEngine = "DB_ENGINE"
    20  	// EnvVarDatabaseURL is the environment variable used to set the entire
    21  	// database connection string.
    22  	EnvVarDatabaseURL = "DATABASE_URL"
    23  	// EnvVarDBHost is the environment variable used to set the host in a
    24  	// database connection string.
    25  	EnvVarDBHost = "DB_HOST"
    26  	// EnvVarDBPort is the environment variable used to set the port in a
    27  	// database connection string.
    28  	EnvVarDBPort = "DB_PORT"
    29  	// EnvVarDBName is the environment variable used to set the database name
    30  	// in a database connection string.
    31  	EnvVarDBName = "DB_NAME"
    32  	// EnvVarDBSchema is the environment variable used to set the database
    33  	// schema in a database connection string.
    34  	EnvVarDBSchema = "DB_SCHEMA"
    35  	// EnvVarDBApplicationName is the environment variable used to set the
    36  	// `application_name` configuration parameter in a `lib/pq` connection
    37  	// string.
    38  	//
    39  	// See: https://www.postgresql.org/docs/12/runtime-config-logging.html#GUC-APPLICATION-NAME
    40  	EnvVarDBApplicationName = "DB_APPLICATION_NAME"
    41  	// EnvVarDBUser is the environment variable used to set the user in a
    42  	// database connection string.
    43  	EnvVarDBUser = "DB_USER"
    44  	// EnvVarDBPassword is the environment variable used to set the password
    45  	// in a database connection string.
    46  	EnvVarDBPassword = "DB_PASSWORD"
    47  	// EnvVarDBConnectTimeout is is the environment variable used to set the
    48  	// connect timeout in a database connection string.
    49  	EnvVarDBConnectTimeout = "DB_CONNECT_TIMEOUT"
    50  	// EnvVarDBLockTimeout is is the environment variable used to set the lock
    51  	// timeout on a database config.
    52  	EnvVarDBLockTimeout = "DB_LOCK_TIMEOUT"
    53  	// EnvVarDBStatementTimeout is is the environment variable used to set the
    54  	// statement timeout on a database config.
    55  	EnvVarDBStatementTimeout = "DB_STATEMENT_TIMEOUT"
    56  	// EnvVarDBSSLMode is the environment variable used to set the SSL mode in
    57  	// a database connection string.
    58  	EnvVarDBSSLMode = "DB_SSLMODE"
    59  	// EnvVarDBIdleConnections is the environment variable used to set the
    60  	// maximum number of idle connections allowed in a connection pool.
    61  	EnvVarDBIdleConnections = "DB_IDLE_CONNECTIONS"
    62  	// EnvVarDBMaxConnections is the environment variable used to set the
    63  	// maximum number of connections allowed in a connection pool.
    64  	EnvVarDBMaxConnections = "DB_MAX_CONNECTIONS"
    65  	// EnvVarDBMaxLifetime is the environment variable used to set the maximum
    66  	// lifetime of a connection in a connection pool.
    67  	EnvVarDBMaxLifetime = "DB_MAX_LIFETIME"
    68  	// EnvVarDBMaxIdleTime is the environment variable used to set the maximum
    69  	// time a connection can be idle.
    70  	EnvVarDBMaxIdleTime = "DB_MAX_IDLE_TIME"
    71  	// EnvVarDBBufferPoolSize is the environment variable used to set the buffer
    72  	// pool size on a connection in a connection pool.
    73  	EnvVarDBBufferPoolSize = "DB_BUFFER_POOL_SIZE"
    74  	// EnvVarDBDialect is the environment variable used to set the dialect
    75  	// on a connection configuration (e.g. `postgres` or `cockroachdb`).
    76  	EnvVarDBDialect = "DB_DIALECT"
    77  
    78  	// DefaultHost is the default database hostname, typically used
    79  	// when developing locally.
    80  	DefaultHost = "localhost"
    81  	// DefaultPort is the default postgres port.
    82  	DefaultPort = "5432"
    83  	// DefaultDatabase is the default database to connect to, we use
    84  	// `postgres` to not pollute the template databases.
    85  	DefaultDatabase = "postgres"
    86  
    87  	// DefaultSchema is the default schema to connect to
    88  	DefaultSchema = "public"
    89  
    90  	// SSLModeDisable is an ssl mode.
    91  	// Postgres Docs: "I don't care about security, and I don't want to pay the overhead of encryption."
    92  	SSLModeDisable = "disable"
    93  	// SSLModeAllow is an ssl mode.
    94  	// Postgres Docs: "I don't care about security, but I will pay the overhead of encryption if the server insists on it."
    95  	SSLModeAllow = "allow"
    96  	// SSLModePrefer is an ssl mode.
    97  	// Postgres Docs: "I don't care about encryption, but I wish to pay the overhead of encryption if the server supports it"
    98  	SSLModePrefer = "prefer"
    99  	// SSLModeRequire is an ssl mode.
   100  	// Postgres Docs: "I want my data to be encrypted, and I accept the overhead. I trust that the network will make sure I always connect to the server I want."
   101  	SSLModeRequire = "require"
   102  	// SSLModeVerifyCA is an ssl mode.
   103  	// Postgres Docs: "I want my data encrypted, and I accept the overhead. I want to be sure that I connect to a server that I trust."
   104  	SSLModeVerifyCA = "verify-ca"
   105  	// SSLModeVerifyFull is an ssl mode.
   106  	// Postgres Docs: "I want my data encrypted, and I accept the overhead. I want to be sure that I connect to a server I trust, and that it's the one I specify."
   107  	SSLModeVerifyFull = "verify-full"
   108  
   109  	// DefaultConnectTimeout is the default connect timeout.
   110  	DefaultConnectTimeout = 5 * time.Second
   111  
   112  	// DefaultIdleConnections is the default number of idle connections.
   113  	DefaultIdleConnections = 16
   114  	// DefaultMaxConnections is the default maximum number of connections.
   115  	DefaultMaxConnections = 32
   116  	// DefaultMaxLifetime is the default maximum lifetime of driver connections.
   117  	DefaultMaxLifetime = time.Duration(0)
   118  	// DefaultMaxIdleTime is the default maximum idle time of driver connections.
   119  	DefaultMaxIdleTime = time.Duration(0)
   120  	// DefaultBufferPoolSize is the default number of buffer pool entries to maintain.
   121  	DefaultBufferPoolSize = 1024
   122  )