dbconfigs

package
v2.0.0-beta.1+incompat... Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2016 License: BSD-3-Clause Imports: 9 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{}

Offer a default config.

View Source
var (

	// ErrUnknownUser is returned by credential server when the
	// user doesn't exist
	ErrUnknownUser = errors.New("unknown user")
)

Functions

func MysqlParams

func MysqlParams(cp *sqldb.ConnParams) (sqldb.ConnParams, error)

MysqlParams returns a copy of our ConnParams 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 {
	sqldb.ConnParams
	Keyspace string
	Shard    string
}

DBConfig encapsulates a ConnParams object and adds a keyspace and a shard.

func (*DBConfig) String

func (d *DBConfig) String() string

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      sqldb.ConnParams
	Filtered sqldb.ConnParams
	Repl     sqldb.ConnParams
}

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

func (*DBConfigs) IsZero

func (dbcfgs *DBConfigs) IsZero() bool

IsZero returns true if DBConfigs was uninitialized.

func (*DBConfigs) Redact

func (dbcfgs *DBConfigs) Redact()

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

func (*DBConfigs) String

func (dbcfgs *DBConfigs) String() string

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

Jump to

Keyboard shortcuts

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