database

package
v0.0.0-...-0e3bbc5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Success message code for everything went fine
	Success Severity = "success"
	// Info message code if command went fine but there were expected errors
	Info Severity = "info"
	// Warn message code if command went fine but there were unexpected errors
	Warn Severity = "warning"
	// Error message code if command went wrong
	Error Severity = "danger"
	// UserCreated is a message that indicates that a database user has been create sucessfully
	UserCreated string = "user %s created"
	// UserAlreadyExists is a message that indicates that the requested database user already exists
	UserAlreadyExists string = "user %s already exists: %s"
	// UserNotExists is a message that indicates that a database user could not be find in database
	UserNotExists string = "user %s does not exists: %s"
	// UserDropped is a message that indicates that a database user has been successfully been dropped
	UserDropped string = "user %s has been dropped"
	// NameMaxLength is a message that will show the restriction for length for database names
	NameMaxLength string = "database name length has to be equal or less than %d"
)

Variables

This section is empty.

Functions

func ParseVersion

func ParseVersion(db string) int

ParseVersion will parse the input and return a suitable database. returns 0 if database is not registered.

Types

type Database

type Database interface {
	DbAPI
	// contains filtered or unexported methods
}

Database is an interface that hold information of the configuration of the database and the API interface

func GetDatabase

func GetDatabase(m int) (Database, error)

GetDatabase is used get the API of the requested database

type DbAPI

type DbAPI interface {
	// CreateUser generates a new database user
	CreateUser(username string, password string) ([]Message, error)
	// DropUser will drop the requested database user
	DropUser(username string) ([]Message, error)
	// RecreateUser will sequentially call DropUser and CreateUser
	RecreateUser(username string, password string) ([]Message, error)
	// ListUsers will list all database excluding system internal users
	ListUsers() ([]SystemUser, error)
}

DbAPI is the interface every database will implement

type Message

type Message struct {
	Severity Severity `json:"severity"`
	Content  string   `json:"content"`
}

Message struct will be used to structure the output so that frontend can parse it

type Severity

type Severity string

Severity represents the status code of a command

type SystemUser

type SystemUser struct {
	Username string `json:"username"`
}

SystemUser json struct represents a database user

Jump to

Keyboard shortcuts

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