Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreEqual ¶
func AreEqual(c *ClientConfig, d *ClientConfig) bool
AreEqual returns true iff the two configurations are equal.
func Open ¶
func Open(ctx context.Context, cfg *ClientConfig) (keyvalue.Connection, error)
Open opens a connection to a MySQL database.
Types ¶
type ClientConfig ¶
type ClientConfig struct { Host string // The host Username string // The user to sign in as Password string // The user's password PasswordSet bool // Is a password set? ConnectTimeout int // Maximum wait for connection, in seconds. Zero means wait indefinitely. RequireSSL bool // Whether or not to require SSL }
ClientConfig describes the configuration options we allow a user to set on a client connection.
Host: If a host name begins with a slash, it specifies Unix-domain communication rather than TCP/IP communication; the value is the name of the directory in which the socket file is stored.
func DefaultConfig ¶
func DefaultConfig() *ClientConfig
DefaultConfig returns a new client configuration initialised with the default values.
The initial default value for the host, username, and password will be read from the environment variables
PCAS_MYSQL_HOST = "hostname[:port]" PCAS_MYSQL_USERNAME = "myname" PCAS_MYSQL_PASSWORD = "mysecret"
respectively on package init.
Note that if PCAS_MYSQL_PASSWORD is set but with value equal to the empty string then it still counts as a valid password, since the empty string is a valid password. You must ensure that PCAS_MYSQL_PASSWORD is unset if you do not want to specify an initial default password.
func SetDefaultConfig ¶
func SetDefaultConfig(c *ClientConfig) *ClientConfig
SetDefaultConfig sets the default client configuration to c and returns the old default configuration. This change will be reflected in future calls to DefaultConfig.
func (*ClientConfig) Copy ¶
func (c *ClientConfig) Copy() *ClientConfig
Copy returns a copy of the configuration.
func (*ClientConfig) Hash ¶
func (c *ClientConfig) Hash() uint32
Hash returns a hash for the configuration.
func (*ClientConfig) Validate ¶
func (c *ClientConfig) Validate() error
Validate validates the client configuration, returning an error if there's a problem.