s/DatabaseType/Database/

This commit is contained in:
Brian Kassouf
2017-04-24 13:59:12 -07:00
parent 4315e68971
commit f6b96ccfa2
9 changed files with 26 additions and 26 deletions

View File

@@ -41,12 +41,12 @@ func Backend(conf *logical.BackendConfig) *databaseBackend {
}
b.logger = conf.Logger
b.connections = make(map[string]dbplugin.DatabaseType)
b.connections = make(map[string]dbplugin.Database)
return &b
}
type databaseBackend struct {
connections map[string]dbplugin.DatabaseType
connections map[string]dbplugin.Database
logger log.Logger
*framework.Backend
@@ -62,13 +62,13 @@ func (b *databaseBackend) closeAllDBs() {
db.Close()
}
b.connections = nil
b.connections = make(map[string]dbplugin.Database)
}
// This function is used to retrieve a database object either from the cached
// connection map or by using the database config in storage. The caller of this
// function needs to hold the backend's lock.
func (b *databaseBackend) getOrCreateDBObj(s logical.Storage, name string) (dbplugin.DatabaseType, error) {
func (b *databaseBackend) getOrCreateDBObj(s logical.Storage, name string) (dbplugin.Database, error) {
// if the object already is built and cached, return it
db, ok := b.connections[name]
if ok {

View File

@@ -29,7 +29,7 @@ func (dc *DatabasePluginClient) Close() error {
// newPluginClient returns a databaseRPCClient with a connection to a running
// plugin. The client is wrapped in a DatabasePluginClient object to ensure the
// plugin is killed on call of Close().
func newPluginClient(sys pluginutil.Wrapper, pluginRunner *pluginutil.PluginRunner) (DatabaseType, error) {
func newPluginClient(sys pluginutil.Wrapper, pluginRunner *pluginutil.PluginRunner) (Database, error) {
// pluginMap is the map of plugins we can dispense.
var pluginMap = map[string]plugin.Plugin{
"database": new(DatabasePlugin),
@@ -65,7 +65,7 @@ func newPluginClient(sys pluginutil.Wrapper, pluginRunner *pluginutil.PluginRunn
// ---- RPC client domain ----
// databasePluginRPCClient implements DatabaseType and is used on the client to
// databasePluginRPCClient implements Database and is used on the client to
// make RPC calls to a plugin.
type databasePluginRPCClient struct {
client *rpc.Client

View File

@@ -9,10 +9,10 @@ import (
// ---- Tracing Middleware Domain ----
// databaseTracingMiddleware wraps a implementation of DatabaseType and executes
// databaseTracingMiddleware wraps a implementation of Database and executes
// trace logging on function call.
type databaseTracingMiddleware struct {
next DatabaseType
next Database
logger log.Logger
typeStr string
@@ -79,10 +79,10 @@ func (mw *databaseTracingMiddleware) Close() (err error) {
// ---- Metrics Middleware Domain ----
// databaseMetricsMiddleware wraps an implementation of DatabaseTypes and on
// databaseMetricsMiddleware wraps an implementation of Databases and on
// function call logs metrics about this instance.
type databaseMetricsMiddleware struct {
next DatabaseType
next Database
typeStr string
}

View File

@@ -10,8 +10,8 @@ import (
log "github.com/mgutz/logxi/v1"
)
// DatabaseType is the interface that all database objects must implement.
type DatabaseType interface {
// Database is the interface that all database objects must implement.
type Database interface {
Type() (string, error)
CreateUser(statements Statements, usernamePrefix string, expiration time.Time) (username string, password string, err error)
RenewUser(statements Statements, username string, expiration time.Time) error
@@ -31,24 +31,24 @@ type Statements struct {
// PluginFactory is used to build plugin database types. It wraps the database
// object in a logging and metrics middleware.
func PluginFactory(pluginName string, sys pluginutil.LookWrapper, logger log.Logger) (DatabaseType, error) {
func PluginFactory(pluginName string, sys pluginutil.LookWrapper, logger log.Logger) (Database, error) {
// Look for plugin in the plugin catalog
pluginRunner, err := sys.LookupPlugin(pluginName)
if err != nil {
return nil, err
}
var db DatabaseType
var db Database
if pluginRunner.Builtin {
// Plugin is builtin so we can retrieve an instance of the interface
// from the pluginRunner. Then cast it to a DatabaseType.
// from the pluginRunner. Then cast it to a Database.
dbRaw, err := pluginRunner.BuiltinFactory()
if err != nil {
return nil, fmt.Errorf("error getting plugin type: %s", err)
}
var ok bool
db, ok = dbRaw.(DatabaseType)
db, ok = dbRaw.(Database)
if !ok {
return nil, fmt.Errorf("unsuported database type: %s", pluginName)
}
@@ -95,7 +95,7 @@ var handshakeConfig = plugin.HandshakeConfig{
// DatabasePlugin implements go-plugin's Plugin interface. It has methods for
// retrieving a server and a client instance of the plugin.
type DatabasePlugin struct {
impl DatabaseType
impl Database
}
func (d DatabasePlugin) Server(*plugin.MuxBroker) (interface{}, error) {

View File

@@ -8,9 +8,9 @@ import (
)
// NewPluginServer is called from within a plugin and wraps the provided
// DatabaseType implementation in a databasePluginRPCServer object and starts a
// Database implementation in a databasePluginRPCServer object and starts a
// RPC server.
func NewPluginServer(db DatabaseType) {
func NewPluginServer(db Database) {
dbPlugin := &DatabasePlugin{
impl: db,
}
@@ -35,10 +35,10 @@ func NewPluginServer(db DatabaseType) {
// ---- RPC server domain ----
// databasePluginRPCServer implements an RPC version of DatabaseType and is run
// inside a plugin. It wraps an underlying implementation of DatabaseType.
// databasePluginRPCServer implements an RPC version of Database and is run
// inside a plugin. It wraps an underlying implementation of Database.
type databasePluginRPCServer struct {
impl DatabaseType
impl Database
}
func (ds *databasePluginRPCServer) Type(_ struct{}, resp *string) error {

View File

@@ -16,7 +16,7 @@ var (
respErrEmptyName = logical.ErrorResponse("Empty name attribute given")
)
// DatabaseConfig is used by the Factory function to configure a DatabaseType
// DatabaseConfig is used by the Factory function to configure a Database
// object.
type DatabaseConfig struct {
PluginName string `json:"plugin_name" structs:"plugin_name" mapstructure:"plugin_name"`

View File

@@ -15,7 +15,7 @@ import (
const msSQLTypeName = "mssql"
// MSSQL is an implementation of DatabaseType interface
// MSSQL is an implementation of Database interface
type MSSQL struct {
connutil.ConnectionProducer
credsutil.CredentialsProducer

View File

@@ -9,7 +9,7 @@ var (
errNotInitialized = errors.New("connection has not been initalized")
)
// ConnectionProducer can be used as an embeded interface in the DatabaseType
// ConnectionProducer can be used as an embeded interface in the Database
// definition. It implements the methods dealing with individual database
// connections and is used in all the builtin database types.
type ConnectionProducer interface {

View File

@@ -2,7 +2,7 @@ package credsutil
import "time"
// CredentialsProducer can be used as an embeded interface in the DatabaseType
// CredentialsProducer can be used as an embeded interface in the Database
// definition. It implements the methods for generating user information for a
// particular database type and is used in all the builtin database types.
type CredentialsProducer interface {