Documentation ¶
Overview ¶
Package dbconfigs is reusable by vt tools to load the db configs file.
Index ¶
- Variables
- func GetSubprocessFlags() []string
- func InitConnectionParams(cp *mysql.ConnectionParams, socketFile string) error
- func MysqlParams(cp *mysql.ConnectionParams) (mysql.ConnectionParams, error)
- func RegisterFlags()
- type CredentialsServer
- type DBConfig
- type DBConfigs
- type FileCredentialsServer
Constants ¶
This section is empty.
Variables ¶
var AllCredentialsServers = make(map[string]CredentialsServer)
AllCredentialsServers contains all the known CredentialsServer implementations. Note we will only access this after flags have been parsed.
var DefaultDBConfigs = DBConfigs{ App: DBConfig{ ConnectionParams: mysql.ConnectionParams{ Uname: "vt_app", Charset: "utf8", }, }, Dba: mysql.ConnectionParams{ Uname: "vt_dba", Charset: "utf8", }, Repl: mysql.ConnectionParams{ Uname: "vt_repl", Charset: "utf8", }, }
Offer a default config.
var ( // error returned by credential server when the user doesn't exist ErrUnknownUser = errors.New("unknown user") )
Functions ¶
func GetSubprocessFlags ¶
func GetSubprocessFlags() []string
func InitConnectionParams ¶
func InitConnectionParams(cp *mysql.ConnectionParams, socketFile string) error
InitConnectionParams may overwrite the socket file, and refresh the password to check that works.
func MysqlParams ¶
func MysqlParams(cp *mysql.ConnectionParams) (mysql.ConnectionParams, error)
returns a copy of our ConnectionParams that we can use to connect, after going through the CredentialsServer.
Types ¶
type CredentialsServer ¶
type CredentialsServer interface { // GetUserAndPassword returns the user / password to use for a given // user. May return ErrUnknownUser. The user might be altered // to support versioned users. // Note this call needs to be thread safe, as we may call this from // multiple go routines. GetUserAndPassword(user string) (string, string, error) // GetSubprocessFlags returns the flags to send to a subprocess // to initialize the exact same CredentialsServer GetSubprocessFlags() []string }
CredentialsServer is the interface for a credential server
func GetCredentialsServer ¶
func GetCredentialsServer() CredentialsServer
GetCredentialsServer returns the current CredentialsServer. Only valid after flag.Init was called.
type DBConfig ¶
type DBConfig struct { mysql.ConnectionParams Keyspace string Shard string EnableRowcache bool EnableInvalidator bool }
DBConfig encapsulates a ConnectionParams object and adds a keyspace and a shard.
type DBConfigs ¶
type DBConfigs struct { App DBConfig Dba mysql.ConnectionParams Repl mysql.ConnectionParams }
DBConfigs is all we need for a smart tablet server: - DBConfig for the query engine, running for the specified keyspace / shard - Dba access for any dba-type operation (db creation, replication, ...) - Replication access to change master
type FileCredentialsServer ¶
type FileCredentialsServer struct {
// contains filtered or unexported fields
}
FileCredentialsServer is a simple implementation of CredentialsServer using a json file. Protected by mu.
func (*FileCredentialsServer) GetSubprocessFlags ¶
func (fcs *FileCredentialsServer) GetSubprocessFlags() []string
func (*FileCredentialsServer) GetUserAndPassword ¶
func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, string, error)