database

package
v0.0.0-...-20ecdb9 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// GetUser returns the user client by user id.
	//
	// retuen nil if the given user can't be found in the database.
	GetUser(userID string) *role.User

	// GetUserList returns a slice contains all users registered in the database.
	GetUserList() []*role.User

	// GetUserListbyGroupID returns a slice contains all users registered for the given group id.
	GetUserListbyGroupID(groupID string) []*role.User

	// GerAdmin returns the admin client by user id.
	//
	// retuen nil if the given user can't be found in the database.
	GetAdmin(userID string) *role.Admin

	// GetAdminList returns the admin client by user id.
	GetAdminList() []*role.Admin

	// GetAdminListbyGroupID returns a slice contains all admins registered for the given group id.
	GetAdminListbyGroupID(groupID string) []*role.Admin

	// GetGroup returns the group client by group id.
	//
	// retuen nil if the given group can't be found in the database.
	GetGroup(groupID string) *group.Group

	// GetGroupList return a slice contains all groups registered in the database.
	GetGroupList() []*group.Group

	// PutAdmin adds given user to database.
	//
	// This will write data form memory to database, and will reload cache.
	PutAdmin(user ...*role.Admin) error

	// PutUser adds given user to database.
	//
	// This will write data form memory to database, and will reload cache.
	PutUser(user ...*role.User) error

	// PutGroup adds given group to database.
	//
	// This will write data form memory to database, and will reload cache.
	PutGroup(group ...*group.Group) error

	// UpdateAdmin adds given user to database.
	//
	// This will write data form memory to database, and will reload cache.
	UpdateAdmin(user ...*role.Admin) error

	// UpdateUser updates given user.
	//
	// This will write data form memory to database, and will reload cache.
	UpdateUser(user ...*role.User) error

	// UpdateGroup updates given group.
	//
	// This will write data form memory to database, and will reload cache.
	UpdateGroup(group ...*group.Group) error

	// CheckPermission return the permission level of given user.
	CheckPermission(userID string) (int, []string)

	// CheckGroup tell if the given group is enabled.
	CheckGroup(groupID string) bool

	// Reload rebuilds database cache form database.
	Reload() error

	// GetUpdateNotifyChan return a read-only channel that will signal when database is updated.
	GetUpdateNotifyChan() <-chan struct{}
}

Database defines the basic abilities of supported datebase.

func Init

func Init(config *config.Config) (database Database, err error)

Init database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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