database

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Database management for the Fish node

Index

Constants

View Source
const (
	ObjectApplication            = "Application"
	ObjectApplicationResource    = "ApplicationResource"
	ObjectApplicationState       = "ApplicationState"
	ObjectApplicationTask        = "ApplicationTask"
	ObjectAuthentication         = "Authentication"
	ObjectCpuInfo                = "CpuInfo"
	ObjectDiskUsage              = "DiskUsage"
	ObjectFieldUiConfig          = "FieldUiConfig"
	ObjectGateProxySSHAccess     = "GateProxySSHAccess"
	ObjectHostInfo               = "HostInfo"
	ObjectImage                  = "Image"
	ObjectJWTToken               = "JWTToken"
	ObjectLabel                  = "Label"
	ObjectLabelDefinition        = "LabelDefinition"
	ObjectMemoryInfo             = "MemoryInfo"
	ObjectNetworkInterface       = "NetworkInterface"
	ObjectNode                   = "Node"
	ObjectNodeDefinition         = "NodeDefinition"
	ObjectPermission             = "Permission"
	ObjectResources              = "Resources"
	ObjectResourcesDisk          = "ResourcesDisk"
	ObjectRole                   = "Role"
	ObjectRoleBasedAccessControl = "RoleBasedAccessControl"
	ObjectStreamCreated          = "StreamCreated"
	ObjectStreamError            = "StreamError"
	ObjectSubscribeConfig        = "SubscribeConfig"
	ObjectUiConfig               = "UiConfig"
	ObjectUser                   = "User"
	ObjectUserConfig             = "UserConfig"
	ObjectUserGroup              = "UserGroup"
	ObjectUserSession            = "UserSession"
	ObjectVote                   = "Vote"
)

ObjectTypes - list of all object types in the system

Variables

View Source
var ErrObjectNotFound = bitcask.ErrObjectNotFound

Functions

This section is empty.

Types

type ApplicationResourceSubscriptionEvent added in v0.9.0

type ApplicationResourceSubscriptionEvent = SubscriptionEvent[*typesv2.ApplicationResource]

ApplicationResourceSubscriptionEvent represents an ApplicationResource change event

type ApplicationStateSubscriptionEvent added in v0.9.0

type ApplicationStateSubscriptionEvent = SubscriptionEvent[*typesv2.ApplicationState]

ApplicationStateSubscriptionEvent represents an ApplicationState change event

type ApplicationSubscriptionEvent added in v0.9.0

type ApplicationSubscriptionEvent = SubscriptionEvent[*typesv2.Application]

ApplicationSubscriptionEvent represents an Application change event

type ApplicationTaskSubscriptionEvent added in v0.9.0

type ApplicationTaskSubscriptionEvent = SubscriptionEvent[*typesv2.ApplicationTask]

ApplicationTaskSubscriptionEvent represents an ApplicationTask change event

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(ctx context.Context, a *typesv2.Application) error

func (*Database) ApplicationDeallocate

func (d *Database) ApplicationDeallocate(ctx context.Context, appUID typesv2.ApplicationUID, requestor string) (*typesv2.ApplicationState, error)

func (*Database) ApplicationDelete

func (d *Database) ApplicationDelete(ctx context.Context, uid typesv2.ApplicationUID) error

func (*Database) ApplicationGet

func (d *Database) ApplicationGet(ctx context.Context, uid typesv2.ApplicationUID) (*typesv2.Application, error)

func (*Database) ApplicationIsAllocated

func (d *Database) ApplicationIsAllocated(ctx context.Context, appUID typesv2.ApplicationUID) error

func (*Database) ApplicationList

func (d *Database) ApplicationList(ctx context.Context) ([]typesv2.Application, error)

func (*Database) ApplicationResourceCreate

func (d *Database) ApplicationResourceCreate(ctx context.Context, r *typesv2.ApplicationResource) error

func (*Database) ApplicationResourceDelete

func (d *Database) ApplicationResourceDelete(ctx context.Context, uid typesv2.ApplicationResourceUID) error

func (*Database) ApplicationResourceGet

func (d *Database) ApplicationResourceGet(ctx context.Context, uid typesv2.ApplicationResourceUID) (*typesv2.ApplicationResource, error)

func (*Database) ApplicationResourceGetByApplication

func (d *Database) ApplicationResourceGetByApplication(ctx context.Context, appUID typesv2.ApplicationUID) (*typesv2.ApplicationResource, error)

func (*Database) ApplicationResourceGetByIP

func (d *Database) ApplicationResourceGetByIP(ctx context.Context, ip string) (*typesv2.ApplicationResource, error)

func (*Database) ApplicationResourceList

func (d *Database) ApplicationResourceList(ctx context.Context) ([]typesv2.ApplicationResource, error)

func (*Database) ApplicationResourceListNode

func (d *Database) ApplicationResourceListNode(ctx context.Context, nodeUID typesv2.NodeUID) ([]typesv2.ApplicationResource, error)

func (*Database) ApplicationResourceSave

func (d *Database) ApplicationResourceSave(ctx context.Context, res *typesv2.ApplicationResource) error

func (*Database) ApplicationStateCreate

func (d *Database) ApplicationStateCreate(ctx context.Context, as *typesv2.ApplicationState) error

func (*Database) ApplicationStateDelete

func (d *Database) ApplicationStateDelete(ctx context.Context, uid typesv2.ApplicationStateUID) error

func (*Database) ApplicationStateGet

func (d *Database) ApplicationStateGet(ctx context.Context, uid typesv2.ApplicationStateUID) (*typesv2.ApplicationState, error)

func (*Database) ApplicationStateGetByApplication

func (d *Database) ApplicationStateGetByApplication(ctx context.Context, appUID typesv2.ApplicationUID) (*typesv2.ApplicationState, error)

func (*Database) ApplicationStateIsActive

func (d *Database) ApplicationStateIsActive(status typesv2.ApplicationState_Status) bool

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

func (*Database) ApplicationStateIsDead added in v0.8.3

func (*Database) ApplicationStateIsDead(status typesv2.ApplicationState_Status) bool

ApplicationStateIsDead returns false if Status in ERROR or DEALLOCATED state

func (*Database) ApplicationStateList

func (d *Database) ApplicationStateList(ctx context.Context) ([]typesv2.ApplicationState, error)

func (*Database) ApplicationStateListByApplication

func (d *Database) ApplicationStateListByApplication(ctx context.Context, appUID typesv2.ApplicationUID) ([]typesv2.ApplicationState, error)

func (*Database) ApplicationStateListLatest

func (d *Database) ApplicationStateListLatest(ctx context.Context) ([]typesv2.ApplicationState, error)

func (*Database) ApplicationStateListNewElected added in v0.8.3

func (d *Database) ApplicationStateListNewElected(ctx context.Context) ([]typesv2.ApplicationState, error)

func (*Database) ApplicationStateNewCount added in v0.8.3

func (d *Database) ApplicationStateNewCount(ctx context.Context, appUID typesv2.ApplicationUID) uint

func (*Database) ApplicationTaskCreate

func (d *Database) ApplicationTaskCreate(ctx context.Context, at *typesv2.ApplicationTask) error

func (*Database) ApplicationTaskDelete

func (d *Database) ApplicationTaskDelete(ctx context.Context, uid typesv2.ApplicationTaskUID) error

func (*Database) ApplicationTaskGet

func (d *Database) ApplicationTaskGet(ctx context.Context, uid typesv2.ApplicationTaskUID) (*typesv2.ApplicationTask, error)

func (*Database) ApplicationTaskList

func (d *Database) ApplicationTaskList(ctx context.Context) ([]typesv2.ApplicationTask, error)

func (*Database) ApplicationTaskListByApplication

func (d *Database) ApplicationTaskListByApplication(ctx context.Context, appUID typesv2.ApplicationUID) ([]typesv2.ApplicationTask, error)

func (*Database) ApplicationTaskListByApplicationAndWhen

func (d *Database) ApplicationTaskListByApplicationAndWhen(ctx context.Context, appUID typesv2.ApplicationUID, when typesv2.ApplicationState_Status) ([]typesv2.ApplicationTask, error)

func (*Database) ApplicationTaskSave

func (d *Database) ApplicationTaskSave(ctx context.Context, at *typesv2.ApplicationTask) error

func (*Database) CompactDB

func (d *Database) CompactDB(ctx context.Context) 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) EnrichUserWithGroupConfig added in v0.10.0

func (d *Database) EnrichUserWithGroupConfig(ctx context.Context, user *typesv2.User)

func (*Database) GateProxySSHAccessCreate added in v0.9.0

func (d *Database) GateProxySSHAccessCreate(ra *typesv2.GateProxySSHAccess) error

GateProxySSHAccessCreate makes new ResourceAccess

func (*Database) GateProxySSHAccessDelete added in v0.9.0

func (d *Database) GateProxySSHAccessDelete(uid typesv2.GateProxySSHAccessUID) error

GateProxySSHAccessDelete removes ResourceAccess by UID

func (*Database) GateProxySSHAccessDeleteByResource added in v0.9.0

func (d *Database) GateProxySSHAccessDeleteByResource(appresUID typesv2.ApplicationResourceUID) error

GateProxySSHAccessDeleteByResource removes ResourceAccess by ResourceUID

func (*Database) GateProxySSHAccessList added in v0.9.0

func (d *Database) GateProxySSHAccessList() (ra []typesv2.GateProxySSHAccess, err error)

GateProxySSHAccessList returns a list of all known GateProxySSHAccess objects

func (*Database) GateProxySSHAccessUseKey added in v0.9.1

func (d *Database) GateProxySSHAccessUseKey(username string, key string) (*typesv2.GateProxySSHAccess, error)

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

func (*Database) GateProxySSHAccessUsePasswordHash added in v0.9.1

func (d *Database) GateProxySSHAccessUsePasswordHash(username string, hash string) (*typesv2.GateProxySSHAccess, error)

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

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() typesv2.Node

GetNode returns current Fish node spec

func (*Database) GetNodeAddress added in v0.9.0

func (d *Database) GetNodeAddress() string

GetNodeAddress returns node external address

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() typesv2.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(ctx context.Context, l *typesv2.Label) error

func (*Database) LabelDelete

func (d *Database) LabelDelete(ctx context.Context, uid typesv2.LabelUID) error

func (*Database) LabelGet

func (d *Database) LabelGet(ctx context.Context, uid typesv2.LabelUID) (*typesv2.Label, error)

func (*Database) LabelList

func (d *Database) LabelList(ctx context.Context, filters LabelListParams) ([]typesv2.Label, error)

func (*Database) LabelSave added in v0.10.0

func (d *Database) LabelSave(ctx context.Context, l *typesv2.Label) error

func (*Database) MergeUserConfigWithGroups added in v0.10.0

func (d *Database) MergeUserConfigWithGroups(ctx context.Context, user *typesv2.User, groups []*typesv2.UserGroup) *typesv2.UserConfig

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(ctx context.Context) ([]typesv2.Node, error)

func (*Database) NodeCreate

func (d *Database) NodeCreate(ctx context.Context, n *typesv2.Node) error

func (*Database) NodeGet

func (d *Database) NodeGet(ctx context.Context, name string) (*typesv2.Node, error)

func (*Database) NodeList

func (d *Database) NodeList(ctx context.Context) ([]typesv2.Node, error)

func (*Database) NodePing

func (d *Database) NodePing(ctx context.Context) error

func (*Database) NodeSave

func (d *Database) NodeSave(ctx context.Context, node *typesv2.Node) error

func (*Database) RoleCreate added in v0.9.0

func (d *Database) RoleCreate(ctx context.Context, r *typesv2.Role) error

func (*Database) RoleDelete added in v0.9.0

func (d *Database) RoleDelete(ctx context.Context, name string) error

func (*Database) RoleGet added in v0.9.0

func (d *Database) RoleGet(ctx context.Context, name string) (*typesv2.Role, error)

func (*Database) RoleList added in v0.9.0

func (d *Database) RoleList(ctx context.Context) ([]typesv2.Role, error)

func (*Database) RoleSave added in v0.9.0

func (d *Database) RoleSave(ctx context.Context, r *typesv2.Role) error

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) Set

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

Set puts value in database

func (*Database) SetNode

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

SetNode puts current node in the memory storage

func (*Database) Shutdown

func (d *Database) Shutdown(ctx context.Context) error

func (*Database) SubscribeApplication added in v0.9.0

func (d *Database) SubscribeApplication(ctx context.Context, ch chan ApplicationSubscriptionEvent)

func (*Database) SubscribeApplicationResource added in v0.9.0

func (d *Database) SubscribeApplicationResource(ctx context.Context, ch chan ApplicationResourceSubscriptionEvent)

func (*Database) SubscribeApplicationState added in v0.8.3

func (d *Database) SubscribeApplicationState(ctx context.Context, ch chan ApplicationStateSubscriptionEvent)

func (*Database) SubscribeApplicationTask added in v0.8.3

func (d *Database) SubscribeApplicationTask(ctx context.Context, ch chan ApplicationTaskSubscriptionEvent)

func (*Database) SubscribeLabel added in v0.9.0

func (d *Database) SubscribeLabel(ctx context.Context, ch chan LabelSubscriptionEvent)

func (*Database) SubscribeNode added in v0.9.0

func (d *Database) SubscribeNode(ctx context.Context, ch chan NodeSubscriptionEvent)

func (*Database) SubscribeRole added in v0.9.0

func (d *Database) SubscribeRole(ctx context.Context, ch chan RoleSubscriptionEvent)

func (*Database) SubscribeUser added in v0.9.0

func (d *Database) SubscribeUser(ctx context.Context, ch chan UserSubscriptionEvent)

func (*Database) SubscribeUserGroup added in v0.10.0

func (d *Database) SubscribeUserGroup(ctx context.Context, ch chan UserGroupSubscriptionEvent)

func (*Database) UnsubscribeApplication added in v0.9.0

func (d *Database) UnsubscribeApplication(ctx context.Context, ch chan ApplicationSubscriptionEvent)

func (*Database) UnsubscribeApplicationResource added in v0.9.0

func (d *Database) UnsubscribeApplicationResource(ctx context.Context, ch chan ApplicationResourceSubscriptionEvent)

func (*Database) UnsubscribeApplicationState added in v0.9.0

func (d *Database) UnsubscribeApplicationState(ctx context.Context, ch chan ApplicationStateSubscriptionEvent)

func (*Database) UnsubscribeApplicationTask added in v0.9.0

func (d *Database) UnsubscribeApplicationTask(ctx context.Context, ch chan ApplicationTaskSubscriptionEvent)

func (*Database) UnsubscribeLabel added in v0.9.0

func (d *Database) UnsubscribeLabel(ctx context.Context, ch chan LabelSubscriptionEvent)

func (*Database) UnsubscribeNode added in v0.9.0

func (d *Database) UnsubscribeNode(ctx context.Context, ch chan NodeSubscriptionEvent)

func (*Database) UnsubscribeRole added in v0.9.0

func (d *Database) UnsubscribeRole(ctx context.Context, ch chan RoleSubscriptionEvent)

func (*Database) UnsubscribeUser added in v0.9.0

func (d *Database) UnsubscribeUser(ctx context.Context, ch chan UserSubscriptionEvent)

func (*Database) UnsubscribeUserGroup added in v0.10.0

func (d *Database) UnsubscribeUserGroup(ctx context.Context, ch chan UserGroupSubscriptionEvent)

func (*Database) UserAuth

func (d *Database) UserAuth(ctx context.Context, name string, password string) *typesv2.User

func (*Database) UserCreate

func (d *Database) UserCreate(ctx context.Context, u *typesv2.User) error

func (*Database) UserDelete

func (d *Database) UserDelete(ctx context.Context, name string) error

func (*Database) UserGet

func (d *Database) UserGet(ctx context.Context, name string) (*typesv2.User, error)

func (*Database) UserGroupCreate added in v0.10.0

func (d *Database) UserGroupCreate(ctx context.Context, g *typesv2.UserGroup) error

func (*Database) UserGroupDelete added in v0.10.0

func (d *Database) UserGroupDelete(ctx context.Context, name string) error

func (*Database) UserGroupGet added in v0.10.0

func (d *Database) UserGroupGet(ctx context.Context, name string) (*typesv2.UserGroup, error)

func (*Database) UserGroupList added in v0.10.0

func (d *Database) UserGroupList(ctx context.Context) ([]typesv2.UserGroup, error)

func (*Database) UserGroupListByUser added in v0.10.0

func (d *Database) UserGroupListByUser(ctx context.Context, userName string) ([]*typesv2.UserGroup, error)

func (*Database) UserGroupSave added in v0.10.0

func (d *Database) UserGroupSave(ctx context.Context, g *typesv2.UserGroup) error

func (*Database) UserList

func (d *Database) UserList(ctx context.Context) ([]typesv2.User, error)

func (*Database) UserNew

func (d *Database) UserNew(ctx context.Context, name string, password string) (string, *typesv2.User, error)

func (*Database) UserSave

func (d *Database) UserSave(ctx context.Context, u *typesv2.User) error

type LabelListParams added in v0.9.0

type LabelListParams struct {
	Name    *string
	Version *string
}

LabelListParams reflection of RPC LabelServiceListRequest to pass to database function LabelList

type LabelSubscriptionEvent added in v0.9.0

type LabelSubscriptionEvent = SubscriptionEvent[*typesv2.Label]

LabelSubscriptionEvent represents a Label change event

type NodeSubscriptionEvent added in v0.9.0

type NodeSubscriptionEvent = SubscriptionEvent[*typesv2.Node]

NodeSubscriptionEvent represents a Node change event

type RoleSubscriptionEvent added in v0.9.0

type RoleSubscriptionEvent = SubscriptionEvent[*typesv2.Role]

RoleSubscriptionEvent represents a Role change event

type SubscriptionEvent added in v0.9.0

type SubscriptionEvent[T any] struct {
	ChangeType aquariumv2.ChangeType
	Object     T
}

SubscriptionEvent represents a database change event with change type

func NewCreateEvent added in v0.9.0

func NewCreateEvent[T any](obj T) SubscriptionEvent[T]

Helper functions to create events

func NewRemoveEvent added in v0.9.0

func NewRemoveEvent[T any](obj T) SubscriptionEvent[T]

func NewUpdateEvent added in v0.9.0

func NewUpdateEvent[T any](obj T) SubscriptionEvent[T]

type UserGroupSubscriptionEvent added in v0.10.0

type UserGroupSubscriptionEvent = SubscriptionEvent[*typesv2.UserGroup]

UserGroupSubscriptionEvent represents a UserGroup change event

type UserSubscriptionEvent added in v0.9.0

type UserSubscriptionEvent = SubscriptionEvent[*typesv2.User]

UserSubscriptionEvent represents a User change event

Jump to

Keyboard shortcuts

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