database

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Database management for the Fish node

Index

Constants

This section is empty.

Variables

View Source
var ErrObjectNotFound = bitcask.ErrObjectNotFound

Functions

This section is empty.

Types

type Database

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

Database implements necessary functions to manipulate the internal database

func New

func New(path string) (*Database, error)

Init creates the database object by provided path

func (*Database) ApplicationCreate

func (d *Database) ApplicationCreate(a *types.Application) error

ApplicationCreate makes new Application

func (*Database) ApplicationDeallocate

func (d *Database) ApplicationDeallocate(appUID types.ApplicationUID, requestor string) (*types.ApplicationState, error)

ApplicationDeallocate helps with creating deallocate/recalled state for the Application

func (*Database) ApplicationDelete

func (d *Database) ApplicationDelete(uid types.ApplicationUID) (err error)

ApplicationDelete removes the Application

func (*Database) ApplicationGet

func (d *Database) ApplicationGet(uid types.ApplicationUID) (a *types.Application, err error)

ApplicationGet returns Application by UID

func (*Database) ApplicationIsAllocated

func (d *Database) ApplicationIsAllocated(appUID types.ApplicationUID) (err error)

ApplicationIsAllocated returns if specific Application is allocated

func (*Database) ApplicationList

func (d *Database) ApplicationList() (as []types.Application, err error)

ApplicationFind lists Applications by filter

func (*Database) ApplicationResourceAccessCreate

func (d *Database) ApplicationResourceAccessCreate(ra *types.ApplicationResourceAccess) error

ApplicationResourceAccessCreate makes new ResourceAccess

func (*Database) ApplicationResourceAccessDelete

func (d *Database) ApplicationResourceAccessDelete(uid types.ApplicationResourceAccessUID) error

ApplicationResourceAccessDelete removes ResourceAccess by UID

func (*Database) ApplicationResourceAccessDeleteByResource

func (d *Database) ApplicationResourceAccessDeleteByResource(appresUID types.ApplicationResourceUID) error

ApplicationResourceAccessDeleteByResource removes ResourceAccess by ResourceUID

func (*Database) ApplicationResourceAccessKey added in v0.8.3

func (d *Database) ApplicationResourceAccessKey(username string, key string) (*types.ApplicationResourceAccess, error)

ApplicationResourceAccessSingleUseKey retrieves the key from the database *AND* deletes it. Users must request a new resource access to connect again.

func (*Database) ApplicationResourceAccessList

func (d *Database) ApplicationResourceAccessList() (ra []types.ApplicationResourceAccess, err error)

ApplicationResourceAccessList returns a list of all known ApplicationResourceAccess objects

func (*Database) ApplicationResourceAccessPasswordHash added in v0.8.3

func (d *Database) ApplicationResourceAccessPasswordHash(username string, hash string) (*types.ApplicationResourceAccess, error)

ApplicationResourceAccessPasswordHash retrieves the password hash from the database *AND* deletes it. Users must request a new Resource Access to connect again.

func (*Database) ApplicationResourceCreate

func (d *Database) ApplicationResourceCreate(r *types.ApplicationResource) error

ApplicationResourceCreate makes new Resource

func (*Database) ApplicationResourceDelete

func (d *Database) ApplicationResourceDelete(uid types.ApplicationResourceUID) error

ApplicationResourceDelete removes Resource

func (*Database) ApplicationResourceGet

func (d *Database) ApplicationResourceGet(uid types.ApplicationResourceUID) (res *types.ApplicationResource, err error)

ApplicationResourceGet returns Resource by it's UID

func (*Database) ApplicationResourceGetByApplication

func (d *Database) ApplicationResourceGetByApplication(appUID types.ApplicationUID) (res *types.ApplicationResource, err error)

ApplicationResourceGetByApplication returns ApplicationResource by ApplicationUID

func (*Database) ApplicationResourceGetByIP

func (d *Database) ApplicationResourceGetByIP(ip string) (res *types.ApplicationResource, err error)

ApplicationResourceGetByIP returns Resource by it's IP address

func (*Database) ApplicationResourceList

func (d *Database) ApplicationResourceList() (rs []types.ApplicationResource, err error)

ApplicationResourceList returns a list of all known ApplicationResource objects

func (*Database) ApplicationResourceListNode

func (d *Database) ApplicationResourceListNode(nodeUID types.NodeUID) (rs []types.ApplicationResource, err error)

ApplicationResourceListNode returns list of resources for provided NodeUID

func (*Database) ApplicationResourceSave

func (d *Database) ApplicationResourceSave(res *types.ApplicationResource) error

ApplicationResourceSave stores ApplicationResource

func (*Database) ApplicationStateCreate

func (d *Database) ApplicationStateCreate(as *types.ApplicationState) error

ApplicationStateCreate makes new ApplicationState

func (*Database) ApplicationStateDelete

func (d *Database) ApplicationStateDelete(uid types.ApplicationStateUID) (err error)

ApplicationStateDelete removes the ApplicationState

func (*Database) ApplicationStateGet

func (d *Database) ApplicationStateGet(uid types.ApplicationStateUID) (as *types.ApplicationState, err error)

ApplicationStateGet returns specific ApplicationState

func (*Database) ApplicationStateGetByApplication

func (d *Database) ApplicationStateGetByApplication(appUID types.ApplicationUID) (state *types.ApplicationState, err error)

ApplicationStateGetByApplication returns latest ApplicationState of requested ApplicationUID

func (*Database) ApplicationStateIsActive

func (d *Database) ApplicationStateIsActive(status types.ApplicationStatus) bool

ApplicationStateIsActive returns false if Status in ERROR, RECALLED, DEALLOCATE or DEALLOCATED state

func (*Database) ApplicationStateIsDead added in v0.8.3

func (*Database) ApplicationStateIsDead(status types.ApplicationStatus) bool

ApplicationStateIsDead returns false if Status in ERROR, RECALLED or DEALLOCATED state

func (*Database) ApplicationStateList

func (d *Database) ApplicationStateList() (ass []types.ApplicationState, err error)

ApplicationStateList returns list of ApplicationStates

func (*Database) ApplicationStateListByApplication

func (d *Database) ApplicationStateListByApplication(appUID types.ApplicationUID) (states []types.ApplicationState, err error)

ApplicationStateListByApplication returns all ApplicationStates with ApplicationUID

func (*Database) ApplicationStateListLatest

func (d *Database) ApplicationStateListLatest() (out []types.ApplicationState, err error)

ApplicationStateListLatest returns list of latest ApplicationState per Application

func (*Database) ApplicationStateListNewElected added in v0.8.3

func (d *Database) ApplicationStateListNewElected() (ass []types.ApplicationState, err error)

ApplicationStateListNewElected returns new and elected Applications

func (*Database) ApplicationStateNewCount added in v0.8.3

func (d *Database) ApplicationStateNewCount(appUID types.ApplicationUID) (count uint)

ApplicationStateNewCount returns amount of NEW states of the Application, to get amount of tries

func (*Database) ApplicationTaskCreate

func (d *Database) ApplicationTaskCreate(at *types.ApplicationTask) error

ApplicationTaskCreate makes a new ApplicationTask

func (*Database) ApplicationTaskDelete

func (d *Database) ApplicationTaskDelete(uid types.ApplicationTaskUID) (err error)

ApplicationTaskDelete removes the ApplicationTask

func (*Database) ApplicationTaskGet

func (d *Database) ApplicationTaskGet(uid types.ApplicationTaskUID) (at *types.ApplicationTask, err error)

ApplicationTaskGet returns the ApplicationTask by ApplicationTaskUID

func (*Database) ApplicationTaskList

func (d *Database) ApplicationTaskList() (at []types.ApplicationTask, err error)

ApplicationTaskList returns all known ApplicationTasks

func (*Database) ApplicationTaskListByApplication

func (d *Database) ApplicationTaskListByApplication(uid types.ApplicationUID) (at []types.ApplicationTask, err error)

ApplicationTaskFindByApplication allows to find all the ApplicationTasks by ApplicationUID

func (*Database) ApplicationTaskListByApplicationAndWhen

func (d *Database) ApplicationTaskListByApplicationAndWhen(appUID types.ApplicationUID, when types.ApplicationStatus) (at []types.ApplicationTask, err error)

ApplicationTaskListByApplicationAndWhen returns list of ApplicationTasks by ApplicationUID and When it need to be executed

func (*Database) ApplicationTaskSave

func (d *Database) ApplicationTaskSave(at *types.ApplicationTask) error

ApplicationTaskSave stores the ApplicationTask

func (*Database) CompactDB

func (d *Database) CompactDB() error

CompactDB runs stale Applications and data removing

func (*Database) Del

func (d *Database) Del(prefix, key string) error

Del removes key from DB

func (*Database) Get

func (d *Database) Get(prefix, key string, obj any) error

Get returns data by key

func (*Database) GetNode

func (d *Database) GetNode() *types.Node

GetNode returns current Fish node spec

func (*Database) GetNodeLocation

func (d *Database) GetNodeLocation() string

GetNodeLocation returns current node location

func (*Database) GetNodeName

func (d *Database) GetNodeName() string

GetNodeName returns current node name

func (*Database) GetNodeUID

func (d *Database) GetNodeUID() types.NodeUID

GetNodeUID returns node UID

func (*Database) Has

func (d *Database) Has(prefix, key string) (bool, error)

Has checks if the key exists

func (*Database) LabelCreate

func (d *Database) LabelCreate(l *types.Label) error

LabelCreate makes new Label

func (*Database) LabelDelete

func (d *Database) LabelDelete(uid types.LabelUID) error

LabelDelete deletes the Label by UID

func (*Database) LabelGet

func (d *Database) LabelGet(uid types.LabelUID) (label *types.Label, err error)

LabelGet returns Label by UID

func (*Database) LabelList

func (d *Database) LabelList(filters types.LabelListGetParams) (labels []types.Label, err error)

LabelFind returns list of Labels that fits filters

func (*Database) LabelListName

func (d *Database) LabelListName(name string) (labels []types.Label, err error)

func (*Database) NewUID

func (d *Database) NewUID() uuid.UUID

NewUID Creates new UID with 6 starting bytes of Node UID as prefix

func (*Database) NodeActiveList

func (d *Database) NodeActiveList() (ns []types.Node, err error)

NodeActiveList lists all the nodes in the cluster

func (*Database) NodeCreate

func (d *Database) NodeCreate(n *types.Node) error

NodeCreate makes new Node

func (*Database) NodeGet

func (d *Database) NodeGet(name string) (node *types.Node, err error)

NodeGet returns Node by it's unique name

func (*Database) NodeList

func (d *Database) NodeList() (ns []types.Node, err error)

NodeFind returns list of Nodes that fits filter

func (*Database) NodePing

func (d *Database) NodePing(node *types.Node) error

NodePing updates Node and shows that it's active

func (*Database) NodeSave

func (d *Database) NodeSave(node *types.Node) error

NodeSave stores Node

func (*Database) Scan

func (d *Database) Scan(prefix string, f func(string) error) error

Scan iterates over key prefixes and executing the provided function for each one

func (*Database) ServiceMappingByApplicationAndDest

func (d *Database) ServiceMappingByApplicationAndDest(appUID types.ApplicationUID, dest string) string

ServiceMappingByApplicationAndDest is trying to find the ServiceMapping record with Application and Location The application in priority, location - secondary priority, if no such records found - default will be used.

func (*Database) ServiceMappingCreate

func (d *Database) ServiceMappingCreate(sm *types.ServiceMapping) error

ServiceMappingCreate makes new ServiceMapping

func (*Database) ServiceMappingDelete

func (d *Database) ServiceMappingDelete(uid types.ServiceMappingUID) error

ServiceMappingDelete removes ServiceMapping

func (*Database) ServiceMappingGet

func (d *Database) ServiceMappingGet(uid types.ServiceMappingUID) (sm *types.ServiceMapping, err error)

ServiceMappingGet returns ServiceMapping by UID

func (*Database) ServiceMappingList

func (d *Database) ServiceMappingList() (sms []types.ServiceMapping, err error)

ServiceMappingFind returns list of ServiceMappings that fits the filter

func (*Database) ServiceMappingListByApplication

func (d *Database) ServiceMappingListByApplication(appUID types.ApplicationUID) (sms []types.ServiceMapping, err error)

ServiceMappingByApplication returns ServiceMapping list with specified ApplicationUID

func (*Database) ServiceMappingSave

func (d *Database) ServiceMappingSave(sm *types.ServiceMapping) error

ServiceMappingSave stores ServiceMapping

func (*Database) Set

func (d *Database) Set(prefix, key string, obj any) error

Set puts value in database

func (*Database) SetNode

func (d *Database) SetNode(node types.Node)

SetNode puts current node in the memory storage

func (*Database) Shutdown

func (d *Database) Shutdown() error

Shutdown compacts database backend and closes it

func (*Database) SubscribeApplicationState added in v0.8.3

func (d *Database) SubscribeApplicationState(ch chan *types.ApplicationState)

func (*Database) SubscribeApplicationTask added in v0.8.3

func (d *Database) SubscribeApplicationTask(ch chan *types.ApplicationTask)

func (*Database) UserAuth

func (d *Database) UserAuth(name string, password string) *types.User

UserAuth returns User if name and password are correct

func (*Database) UserCreate

func (d *Database) UserCreate(u *types.User) error

UserCreate makes new User

func (*Database) UserDelete

func (d *Database) UserDelete(name string) error

UserDelete removes User

func (*Database) UserGet

func (d *Database) UserGet(name string) (u *types.User, err error)

UserGet returns User by unique name

func (*Database) UserList

func (d *Database) UserList() (us []types.User, err error)

UserList returns list of users

func (*Database) UserNew

func (d *Database) UserNew(name string, password string) (string, *types.User, error)

UserNew makes new User

func (*Database) UserSave

func (d *Database) UserSave(u *types.User) error

UserSave stores User

Jump to

Keyboard shortcuts

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