database

package
v0.0.0-...-c6c26d7 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConnector

type DBConnector struct {
	Database        interfaces.Database
	SessionDatabase interfaces.Database
	Params          *Params
	StopRequest     chan struct{}
	// contains filtered or unexported fields
}

DBConnector describes the structure of the database and implements the Database interface.

func NewDatabaseConnector

func NewDatabaseConnector(env string, dbParams *Params, l logging.Logger) (*DBConnector, error)

NewDatabaseConnector return database connector with session connector. Initialize memory db if databaseProvider in-memory.

func (*DBConnector) CheckFile

func (db *DBConnector) CheckFile(filename string) bool

CheckFile check file in database.

func (*DBConnector) Close

func (db *DBConnector) Close()

Close connector.

func (*DBConnector) CreateAppModule

func (db *DBConnector) CreateAppModule(name, comment string,
	initialStatus bool) (*interfaces.AppModuleEntry, error)

CreateAppModule creates module with given parameters.

func (*DBConnector) CreateAppModules

func (db *DBConnector) CreateAppModules() error

CreateAppModules creates app modules.

func (*DBConnector) CreateSession

func (db *DBConnector) CreateSession(username string, expire int64) (*interfaces.SessionEntry, error)

CreateSession creates session with given parameters.

func (*DBConnector) CreateTask

func (db *DBConnector) CreateTask(Resource, Name,
	resources, initiatorID string, onlyResource, selectedResource bool) (*interfaces.TaskEntry, error)

CreateTask creates task with given parameters.

func (*DBConnector) CreateUser

func (db *DBConnector) CreateUser(username, password,
	fullName string, isAdmin, isBlocked bool) (*interfaces.UserEntry, error)

CreateUser creates user with given parameters.

func (*DBConnector) DeleteExpireSession

func (db *DBConnector) DeleteExpireSession() error

DeleteExpireSession delete all expire session.

func (*DBConnector) DeleteSessionByUUID

func (db *DBConnector) DeleteSessionByUUID(uuid string) error

DeleteSessionByUUID delete session by given uuid.

func (*DBConnector) DeleteUserByID

func (db *DBConnector) DeleteUserByID(id string) error

DeleteUserByID delete user by given id.

func (*DBConnector) DownloadFile

func (db *DBConnector) DownloadFile(filename string) []byte

DownloadFile downloads file from database.

func (*DBConnector) GetAllAppModules

func (db *DBConnector) GetAllAppModules() ([]interfaces.AppModuleEntry, error)

GetAllAppModules return all modules.

func (*DBConnector) GetAllTasks

func (db *DBConnector) GetAllTasks() ([]interfaces.TaskEntry, error)

GetAllTasks return all tasks.

func (*DBConnector) GetAllUsers

func (db *DBConnector) GetAllUsers() ([]interfaces.UserEntry, error)

GetAllUsers return all users.

func (*DBConnector) GetAppModuleByID

func (db *DBConnector) GetAppModuleByID(id string) (*interfaces.AppModuleEntry, error)

GetAppModuleByID return module by given id.

func (*DBConnector) GetAppModuleByName

func (db *DBConnector) GetAppModuleByName(name string) (*interfaces.AppModuleEntry, error)

GetAppModuleByName return module by given name.

func (*DBConnector) GetLastCompleteTaskByResourceAndName

func (db *DBConnector) GetLastCompleteTaskByResourceAndName(resource, name string) (*interfaces.TaskEntry, error)

GetLastCompleteTaskByResourceAndName return last completed task for given resource.

func (*DBConnector) GetSessionByUUID

func (db *DBConnector) GetSessionByUUID(uuid string) (*interfaces.SessionEntry, error)

GetSessionByUUID return session by given uuid.

func (*DBConnector) GetTaskByID

func (db *DBConnector) GetTaskByID(id string) (*interfaces.TaskEntry, error)

GetTaskByID return task by given id.

func (*DBConnector) GetUserByID

func (db *DBConnector) GetUserByID(id string) (*interfaces.UserEntry, error)

GetUserByID return user by given id.

func (*DBConnector) GetUserByUsername

func (db *DBConnector) GetUserByUsername(name string) (*interfaces.UserEntry, error)

GetUserByUsername return user by given name.

func (*DBConnector) GetWaitingTask

func (db *DBConnector) GetWaitingTask() (*interfaces.TaskEntry, error)

GetWaitingTask return one task with 'waiting' status.

func (*DBConnector) UpdateAppModuleByID

func (db *DBConnector) UpdateAppModuleByID(id string, entry *interfaces.AppModuleEntry) error

UpdateAppModuleByID update module by given id.

func (*DBConnector) UpdateSessionByUUID

func (db *DBConnector) UpdateSessionByUUID(uuid string, user *interfaces.SessionEntry) error

UpdateSessionByUUID update session by given uuid.

func (*DBConnector) UpdateTaskStatusAtStartup

func (db *DBConnector) UpdateTaskStatusAtStartup() error

UpdateTaskStatusAtStartup update tasks with status 'InProgress' to 'Error'.

func (*DBConnector) UpdateTaskStatusByID

func (db *DBConnector) UpdateTaskStatusByID(id string, newStatus string) error

UpdateTaskStatusByID update task status by given id.

func (*DBConnector) UpdateUserByID

func (db *DBConnector) UpdateUserByID(id string, user *interfaces.UserEntry) error

UpdateUserByID update user by given id.

func (*DBConnector) UploadFile

func (db *DBConnector) UploadFile(path, filename string) error

UploadFile uploads file to database.

func (*DBConnector) СheckIfTaskAlreadyCreate

func (db *DBConnector) СheckIfTaskAlreadyCreate(resource, name string) bool

СheckIfTaskAlreadyCreate checks for the existence of a task with an error or completed status.

type Params

type Params struct {
	Host             string
	Port             string
	User             string
	Password         string
	Name             string
	DatabaseProvider string
	SessionProvider  string
}

Params describes database parameters.

func NewParams

func NewParams() *Params

NewParams return empty database params.

func (*Params) ConstructDSN

func (d *Params) ConstructDSN() string

ConstructDSN from parameters into string.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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