Documentation
¶
Index ¶
- Constants
- func CreateDatabaseIfNotExists(socketAddr SocketAddress, dbName string, certsDir string, insecure bool) error
- func DropAndCreateDatabase(socketAddr SocketAddress, dbName string, certsDir string, insecure bool) error
- func NewDBForTest(t *testing.T) (*sql.DB, func())
- func NewTestServer(t *testing.T) (*testserver.TestServer, error)
- type DBURLParams
- type SocketAddress
Constants ¶
const ( // DefaultPort is the default port on which crdb runs. DefaultPort = 26257 // RootUser is the default user for crdb. RootUser = "root" // RkOwner is the database user that has DDL access to all DBs RkOwner = "rk_owner" // RkUser is the database user that has DML access to all DBs RkUser = "rk_user" // ConnectTimeoutSeconds to establish a connection ConnectTimeoutSeconds = "10" )
Variables ¶
This section is empty.
Functions ¶
func CreateDatabaseIfNotExists ¶
func CreateDatabaseIfNotExists( socketAddr SocketAddress, dbName string, certsDir string, insecure bool, ) error
CreateDatabaseIfNotExists creates a fresh database dbName in the DB at socketAddr, if it doesn't already exist. It also grants DDL privileges to rk_owner, and DML privileges to rk_user. It connects to the DB as root user.
func DropAndCreateDatabase ¶
func DropAndCreateDatabase( socketAddr SocketAddress, dbName string, certsDir string, insecure bool, ) error
DropAndCreateDatabase creates a fresh database dbName in the DB at socketAddr, dropping any existing database of the same name. It also grants DDL privileges to rk_owner, and DML privileges to rk_user. It connects to the DB as root user.
func NewDBForTest ¶
NewDBForTest creates a testing SQL db connection using cockroachdb testserver. This function assumes that a cockroach binary is present in src/go/bin. Returns a sql *DB instance, and a shutdown function. The caller is responsible for executing the returned shutdown function on exit.
func NewTestServer ¶
func NewTestServer(t *testing.T) (*testserver.TestServer, error)
NewTestServer creates a new TestServer, but does not start it. This function assumes that a cockroach binary is present in src/go/bin.
Types ¶
type DBURLParams ¶
type DBURLParams struct { SocketAddr SocketAddress DbName string User string Insecure bool CertsDir string SocketReadTimeout time.Duration SocketWriteTimeout time.Duration }
DBURLParams captures values for various params required to connect to CockroachDB
func DeclareCockroachDbURLFlags ¶
func DeclareCockroachDbURLFlags(f *flag.FlagSet) *DBURLParams
DeclareCockroachDbURLFlags declares flags necessary for passing all information relevant to connecting to CockroachDB
type SocketAddress ¶
A SocketAddress represents the combination of an ip address and a port.
func ParseSocketAddress ¶
func ParseSocketAddress(s string) (SocketAddress, error)
ParseSocketAddress returns the SocketAddress represented by s, which should be formatted as as "<ip>:<port>". If port mapping is not given, default port is assumed
func (SocketAddress) String ¶
func (s SocketAddress) String() string