dataaccess

package
v0.4.6-dev.7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Contains the data access layer, used by the API to interact with the database.

The current implementation is 100% in local memory. The database support will be added later.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Updates

func Updates() <-chan State

Updates returns a channel that blocks emits a signal whenever the data access layer state changes, typically on startup and whenever the configuration changes. Upon creation, it will emit the current state, so it never blocks.

Types

type DataAccess

type DataAccess interface {
	Initialize() error

	BundleCreate(bundle data.Bundle) error
	BundleDelete(name string, version string) error
	BundleDisable(name string, version string) error
	BundleEnable(name string, version string) error
	BundleEnabledVersion(name string) (string, error)
	BundleExists(name string, version string) (bool, error)
	BundleGet(name string, version string) (data.Bundle, error)
	BundleList() ([]data.Bundle, error)
	BundleListVersions(name string) ([]data.Bundle, error)
	BundleUpdate(bundle data.Bundle) error

	GroupAddUser(groupname string, username string) error
	GroupCreate(group rest.Group) error
	GroupDelete(groupname string) error
	GroupExists(groupname string) (bool, error)
	GroupGet(groupname string) (rest.Group, error)
	GroupGrantRole() error
	GroupList() ([]rest.Group, error)
	GroupRemoveUser(groupname string, username string) error
	GroupRevokeRole() error
	GroupUpdate(rest.Group) error
	GroupUserList(groupname string) ([]rest.User, error)
	GroupUserAdd(groupname string, user string) error
	GroupUserDelete(groupname string, username string) error

	TokenEvaluate(token string) bool
	TokenGenerate(username string, duration time.Duration) (rest.Token, error)
	TokenInvalidate(token string) error
	TokenRetrieveByUser(username string) (rest.Token, error)
	TokenRetrieveByToken(token string) (rest.Token, error)

	UserAuthenticate(username string, password string) (bool, error)
	UserCreate(user rest.User) error
	UserDelete(username string) error
	UserExists(username string) (bool, error)
	UserGet(username string) (rest.User, error)
	UserGetByEmail(email string) (rest.User, error)
	UserGroupList(username string) ([]rest.Group, error)
	UserGroupAdd(username string, groupname string) error
	UserGroupDelete(username string, groupname string) error
	UserList() ([]rest.User, error)
	UserUpdate(user rest.User) error
}

DataAccess represents a common DataAccessObject, backed either by a database or an in-memory datastore.

func Get

func Get() (DataAccess, error)

Get provides an interface to the data access layer. If the state is not 'initialized', this will return an error.

type State

type State byte

State represents a possible state of the data access layer.

const (
	// StateUninitialized is the default state of the data access
	// layer, before initializtion begins.
	StateUninitialized State = iota

	// StateInitializing indicates that the data access layer is
	// initializing, either because it's new or because something has
	// changed (config updated, database disconnected, etc)
	StateInitializing

	// StateInitialized indicates the data access layer is fully
	// initialized and (presumably) functional.
	StateInitialized

	// StateError indicated that some kind of error is preventing the
	// data access layer from initializing correctly.
	StateError
)

func CurrentState

func CurrentState() State

CurrentState returns the current state of the data access layer.

func (State) String

func (s State) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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