Documentation ¶
Overview ¶
Package dbconfigs is reusable by vt tools to load the db configs file.
Index ¶
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{}
Offer a default config.
var ( // ErrUnknownUser is returned by credential server when the // user doesn't exist ErrUnknownUser = errors.New("unknown user") )
Functions ¶
func MysqlParams ¶
func MysqlParams(cp *mysql.ConnectionParams) (mysql.ConnectionParams, error)
MysqlParams 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) }
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 DBConfigFlag ¶
type DBConfigFlag int
DBConfigFlag describes which flags we need
const ( EmptyConfig DBConfigFlag = 0 AppConfig DBConfigFlag = 1 << iota DbaConfig FilteredConfig ReplConfig )
config flags
func RegisterFlags ¶
func RegisterFlags(flags DBConfigFlag) DBConfigFlag
RegisterFlags registers the flags for the given DBConfigFlag. For instance, vttablet will register client, dba and repl. Returns all registered flags.
type DBConfigs ¶
type DBConfigs struct { App DBConfig Dba mysql.ConnectionParams Filtered 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, ...) - Filtered access for filtered replication - Replication access to change master
func Init ¶
func Init(socketFile string, flags DBConfigFlag) (*DBConfigs, error)
Init will initialize app, dba, filterec and repl configs
type DbConfigName ¶
type DbConfigName string
DbConfigName describes which DB config we should use
const AppConfigName DbConfigName = "app"
Regular app config
const DbaConfigName DbConfigName = "dba"
DBA config
const FilteredConfigName DbConfigName = "filtered"
Config for filtered replication
const ReplConfigName DbConfigName = "repl"
Config for replication
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) GetUserAndPassword ¶
func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, string, error)
GetUserAndPassword is part of the CredentialsServer interface