dbconfigs

package
v0.0.0-...-d271c08 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2014 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package dbconfigs is reusable by vt tools to load the db configs file.

Index

Constants

This section is empty.

Variables

View Source
var AllCredentialsServers = make(map[string]CredentialsServer)

AllCredentialsServers contains all the known CredentialsServer implementations. Note we will only access this after flags have been parsed.

View Source
var DefaultDBConfigs = DBConfigs{
	App: DBConfig{
		ConnectionParams: mysql.ConnectionParams{
			Uname:   "vt_app",
			Charset: "utf8",
		},
	},
	Dba: mysql.ConnectionParams{
		Uname:   "vt_dba",
		Charset: "utf8",
	},
	Filtered: mysql.ConnectionParams{
		Uname:   "vt_filtered",
		Charset: "utf8",
	},
	Repl: mysql.ConnectionParams{
		Uname:   "vt_repl",
		Charset: "utf8",
	},
}

Offer a default config.

View Source
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

returns a copy of our ConnectionParams that we can use to connect, after going through the CredentialsServer.

func RegisterFlags

func RegisterFlags()

vttablet will register client, dba and repl.

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.

func (*DBConfig) String

func (d *DBConfig) String() string

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) (*DBConfigs, error)

Initialize app, dba, filterec and repl configs

func (*DBConfigs) Redact

func (dbcfgs *DBConfigs) Redact()

This will remove the password, so the object can be logged

func (*DBConfigs) String

func (dbcfgs *DBConfigs) String() string

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL