dbplugin

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(db Database, tlsProvider func() (*tls.Config, error))

Serve is called from within a plugin and wraps the provided Database implementation in a databasePluginRPCServer object and starts a RPC server.

Types

type CreateUserRequest

type CreateUserRequest struct {
	Statements     Statements
	UsernameConfig UsernameConfig
	Expiration     time.Time
}

type CreateUserResponse

type CreateUserResponse struct {
	Username string
	Password string
}

type Database

type Database interface {
	Type() (string, error)
	CreateUser(statements Statements, usernameConfig UsernameConfig, expiration time.Time) (username string, password string, err error)
	RenewUser(statements Statements, username string, expiration time.Time) error
	RevokeUser(statements Statements, username string) error

	Initialize(config map[string]interface{}, verifyConnection bool) error
	Close() error
}

Database is the interface that all database objects must implement.

func PluginFactory

func PluginFactory(pluginName string, sys pluginutil.LookRunnerUtil, logger log.Logger) (Database, error)

PluginFactory is used to build plugin database types. It wraps the database object in a logging and metrics middleware.

type DatabasePlugin

type DatabasePlugin struct {
	// contains filtered or unexported fields
}

DatabasePlugin implements go-plugin's Plugin interface. It has methods for retrieving a server and a client instance of the plugin.

func (DatabasePlugin) Client

func (DatabasePlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (DatabasePlugin) Server

func (d DatabasePlugin) Server(*plugin.MuxBroker) (interface{}, error)

type DatabasePluginClient

type DatabasePluginClient struct {
	sync.Mutex
	// contains filtered or unexported fields
}

DatabasePluginClient embeds a databasePluginRPCClient and wraps it's Close method to also call Kill() on the plugin.Client.

func (*DatabasePluginClient) Close

func (dc *DatabasePluginClient) Close() error

func (DatabasePluginClient) CreateUser

func (dr DatabasePluginClient) CreateUser(statements Statements, usernameConfig UsernameConfig, expiration time.Time) (username string, password string, err error)

func (DatabasePluginClient) Initialize

func (dr DatabasePluginClient) Initialize(conf map[string]interface{}, verifyConnection bool) error

func (DatabasePluginClient) RenewUser

func (dr DatabasePluginClient) RenewUser(statements Statements, username string, expiration time.Time) error

func (DatabasePluginClient) RevokeUser

func (dr DatabasePluginClient) RevokeUser(statements Statements, username string) error

func (DatabasePluginClient) Type

func (dr DatabasePluginClient) Type() (string, error)

type InitializeRequest

type InitializeRequest struct {
	Config           map[string]interface{}
	VerifyConnection bool
}

type RenewUserRequest

type RenewUserRequest struct {
	Statements Statements
	Username   string
	Expiration time.Time
}

type RevokeUserRequest

type RevokeUserRequest struct {
	Statements Statements
	Username   string
}

type Statements

type Statements struct {
	CreationStatements   string `json:"creation_statments" mapstructure:"creation_statements" structs:"creation_statments"`
	RevocationStatements string `json:"revocation_statements" mapstructure:"revocation_statements" structs:"revocation_statements"`
	RollbackStatements   string `json:"rollback_statements" mapstructure:"rollback_statements" structs:"rollback_statements"`
	RenewStatements      string `json:"renew_statements" mapstructure:"renew_statements" structs:"renew_statements"`
}

Statements set in role creation and passed into the database type's functions.

type UsernameConfig added in v0.7.3

type UsernameConfig struct {
	DisplayName string
	RoleName    string
}

UsernameConfig is used to configure prefixes for the username to be generated.

Jump to

Keyboard shortcuts

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