fish

package
v0.8.1 Latest Latest
Warning

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

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

Documentation

Overview

Package fish core defines all the internals of the Fish processes

Index

Constants

View Source
const DefaultDBCleanupDelay = 10 * time.Minute
View Source
const ElectionRoundTime = 30

ElectionRoundTime defines how long the voting round will take in seconds - so cluster nodes will be able to interchange their responses

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterInterface added in v0.8.0

type ClusterInterface interface {
	// Requesting send of Vote to cluster, since it's not a part of DB
	SendVote(vote *types.Vote) error
}

ClusterInterface defines required functions for Fish to run on the cluster

type Config

type Config struct {
	Directory string `json:"directory"` // Where to store database and other useful data (if relative - to CWD)

	APIAddress        string         `json:"api_address"`         // Where to serve Web UI, API & Meta API
	ProxySocksAddress string         `json:"proxy_socks_address"` // Where to serve SOCKS5 proxy for the allocated resources
	ProxySSHAddress   string         `json:"proxy_ssh_address"`   // Where to serve SSH proxy for the allocated resources
	NodeAddress       string         `json:"node_address"`        // What is the external address of the node
	CPULimit          uint16         `json:"cpu_limit"`           // How many CPU threads Node allowed to use (serve API, ...)
	MemTarget         util.HumanSize `json:"mem_target"`          // What's the target memory utilization by the Node (GC target where it becomes more aggressive)
	ClusterJoin       []string       `json:"cluster_join"`        // The node addresses to join the cluster

	TLSKey   string `json:"tls_key"`    // TLS PEM private key (if relative - to directory)
	TLSCrt   string `json:"tls_crt"`    // TLS PEM public certificate (if relative - to directory)
	TLSCaCrt string `json:"tls_ca_crt"` // TLS PEM certificate authority certificate (if relative - to directory)

	NodeName        string   `json:"node_name"`        // Last resort in case you need to override the default host node name
	NodeLocation    string   `json:"node_location"`    // Specify cluster node location for multi-dc configurations
	NodeIdentifiers []string `json:"node_identifiers"` // The list of node identifiers which could be used to find the right Node for Resource
	NodeSlotsLimit  uint     `json:"node_slots_limit"` // Limits the amount of Applications to be executed simultaneously on the node

	NodeSSHKey string `json:"ssh_key"` // The SSH RSA identity private key for the fish node (if relative - to directory)

	DefaultResourceLifetime string `json:"default_resource_lifetime"` // Sets the lifetime of the resource which will be used if label definition one is not set

	DBCleanupDelay string `json:"db_cleanup_delay"` // Defines the database item cleanup delay when Applciation reached the end of life (by error or deallocated)

	DisableAuth bool `json:"disable_auth"` // WARNING! For performance testing only

	// Configuration for the node drivers, if defined - only the listed plugins will be loaded
	// Each configuration could instantinate the same driver multiple times by adding instance name
	// separated from driver by slash symbol (like "<driver>/prod" - will create "prod" instance).
	Drivers []ConfigDriver `json:"drivers"`
}

Config defines Fish node configuration

func (*Config) ReadConfigFile

func (c *Config) ReadConfigFile(cfgPath string) error

ReadConfigFile needed to read the config file

type ConfigDriver

type ConfigDriver struct {
	Name string            `json:"name"`
	Cfg  util.UnparsedJSON `json:"cfg"`
}

ConfigDriver helper to store driver config without parsing it right away

type Fish

type Fish struct {

	// Signal to stop the fish
	Quit chan os.Signal
	// contains filtered or unexported fields
}

Fish structure is used to store the node internal state

func New

func New(db *bitcask.Bitcask, cfg *Config) (*Fish, error)

New creates new Fish node

func (*Fish) ApplicationCreate

func (f *Fish) ApplicationCreate(a *types.Application) error

ApplicationCreate makes new Applciation

func (*Fish) ApplicationDelete added in v0.8.0

func (f *Fish) ApplicationDelete(uid types.ApplicationUID) (err error)

ApplicationDelete removes the Application

func (*Fish) ApplicationGet

func (f *Fish) ApplicationGet(uid types.ApplicationUID) (a *types.Application, err error)

ApplicationGet returns Application by UID

func (*Fish) ApplicationIsAllocated

func (f *Fish) ApplicationIsAllocated(appUID types.ApplicationUID) (err error)

ApplicationIsAllocated returns if specific Application is allocated

func (*Fish) ApplicationList added in v0.8.0

func (f *Fish) ApplicationList() (as []types.Application, err error)

ApplicationFind lists Applications by filter

func (*Fish) ApplicationListGetStatusNew

func (f *Fish) ApplicationListGetStatusNew() (as []types.Application, err error)

ApplicationListGetStatusNew returns new Applications

func (*Fish) ApplicationResourceAccessCreate added in v0.8.0

func (f *Fish) ApplicationResourceAccessCreate(ra *types.ApplicationResourceAccess) error

ApplicationResourceAccessCreate makes new ResourceAccess

func (*Fish) ApplicationResourceAccessDelete added in v0.8.0

func (f *Fish) ApplicationResourceAccessDelete(uid types.ApplicationResourceAccessUID) error

ApplicationResourceAccessDelete removes ResourceAccess by UID

func (*Fish) ApplicationResourceAccessDeleteByResource added in v0.8.0

func (f *Fish) ApplicationResourceAccessDeleteByResource(appresUID types.ApplicationResourceUID) error

ApplicationResourceAccessDeleteByResource removes ResourceAccess by ResourceUID

func (*Fish) ApplicationResourceAccessList added in v0.8.0

func (f *Fish) ApplicationResourceAccessList() (ra []types.ApplicationResourceAccess, err error)

ApplicationResourceAccessList returns a list of all known ApplicationResourceAccess objects

func (*Fish) ApplicationResourceAccessSingleUseKey added in v0.8.0

func (f *Fish) ApplicationResourceAccessSingleUseKey(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 (*Fish) ApplicationResourceAccessSingleUsePasswordHash added in v0.8.0

func (f *Fish) ApplicationResourceAccessSingleUsePasswordHash(username string, hash string) (*types.ApplicationResourceAccess, error)

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

func (*Fish) ApplicationResourceCreate added in v0.8.0

func (f *Fish) ApplicationResourceCreate(r *types.ApplicationResource) error

ApplicationResourceCreate makes new Resource

func (*Fish) ApplicationResourceDelete added in v0.8.0

func (f *Fish) ApplicationResourceDelete(uid types.ApplicationResourceUID) error

ApplicationResourceDelete removes Resource

func (*Fish) ApplicationResourceGet added in v0.8.0

func (f *Fish) ApplicationResourceGet(uid types.ApplicationResourceUID) (res *types.ApplicationResource, err error)

ApplicationResourceGet returns Resource by it's UID

func (*Fish) ApplicationResourceGetByApplication added in v0.8.0

func (f *Fish) ApplicationResourceGetByApplication(appUID types.ApplicationUID) (res *types.ApplicationResource, err error)

ApplicationResourceGetByApplication returns ApplicationResource by ApplicationUID

func (*Fish) ApplicationResourceGetByIP added in v0.8.0

func (f *Fish) ApplicationResourceGetByIP(ip string) (res *types.ApplicationResource, err error)

ApplicationResourceGetByIP returns Resource by it's IP address

func (*Fish) ApplicationResourceList added in v0.8.0

func (f *Fish) ApplicationResourceList() (rs []types.ApplicationResource, err error)

ApplicationResourceList returns a list of all known ApplicationResource objects

func (*Fish) ApplicationResourceListNode added in v0.8.0

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

ApplicationResourceListNode returns list of resources for provided NodeUID

func (*Fish) ApplicationResourceSave added in v0.8.0

func (f *Fish) ApplicationResourceSave(res *types.ApplicationResource) error

ApplicationResourceSave stores ApplicationResource

func (*Fish) ApplicationStateCreate

func (f *Fish) ApplicationStateCreate(as *types.ApplicationState) error

ApplicationStateCreate makes new ApplicationState

func (*Fish) ApplicationStateDelete added in v0.8.0

func (f *Fish) ApplicationStateDelete(uid types.ApplicationStateUID) (err error)

ApplicationStateDelete removes the ApplicationState

func (*Fish) ApplicationStateGet

func (f *Fish) ApplicationStateGet(uid types.ApplicationStateUID) (as *types.ApplicationState, err error)

ApplicationStateGet returns specific ApplicationState

func (*Fish) ApplicationStateGetByApplication

func (f *Fish) ApplicationStateGetByApplication(appUID types.ApplicationUID) (state *types.ApplicationState, err error)

ApplicationStateGetByApplication returns latest ApplicationState of requested ApplicationUID

func (*Fish) ApplicationStateIsActive

func (*Fish) ApplicationStateIsActive(status types.ApplicationStatus) bool

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

func (*Fish) ApplicationStateList

func (f *Fish) ApplicationStateList() (ass []types.ApplicationState, err error)

ApplicationStateList returns list of ApplicationStates

func (*Fish) ApplicationStateListByApplication added in v0.8.0

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

ApplicationStateListByApplication returns all ApplicationStates with ApplicationUID

func (*Fish) ApplicationStateListLatest added in v0.8.0

func (f *Fish) ApplicationStateListLatest() (out []types.ApplicationState, err error)

ApplicationStateListLatest returns list of latest ApplicationState per Application

func (*Fish) ApplicationTaskCreate added in v0.6.0

func (f *Fish) ApplicationTaskCreate(at *types.ApplicationTask) error

ApplicationTaskCreate makes a new ApplicationTask

func (*Fish) ApplicationTaskDelete added in v0.8.0

func (f *Fish) ApplicationTaskDelete(uid types.ApplicationTaskUID) (err error)

ApplicationTaskDelete removes the ApplicationTask

func (*Fish) ApplicationTaskGet added in v0.6.0

func (f *Fish) ApplicationTaskGet(uid types.ApplicationTaskUID) (at *types.ApplicationTask, err error)

ApplicationTaskGet returns the ApplicationTask by ApplicationTaskUID

func (*Fish) ApplicationTaskList added in v0.8.0

func (f *Fish) ApplicationTaskList() (at []types.ApplicationTask, err error)

ApplicationTaskList returns all known ApplicationTasks

func (*Fish) ApplicationTaskListByApplication added in v0.8.0

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

ApplicationTaskFindByApplication allows to find all the ApplicationTasks by ApplciationUID

func (*Fish) ApplicationTaskListByApplicationAndWhen added in v0.6.0

func (f *Fish) 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 (*Fish) ApplicationTaskSave added in v0.6.0

func (f *Fish) ApplicationTaskSave(at *types.ApplicationTask) error

ApplicationTaskSave stores the ApplicationTask

func (*Fish) CleanupDB added in v0.8.0

func (f *Fish) CleanupDB()

CleanupDB removing stale Applications and data from database to keep it slim

func (*Fish) Close

func (f *Fish) Close()

Close tells the node that the Fish execution need to be stopped

func (*Fish) CompactDB added in v0.8.0

func (f *Fish) CompactDB()

CompactDB runs stale Applications and data removing

func (*Fish) GetCfg added in v0.8.0

func (f *Fish) GetCfg() Config

GetCfg returns fish configuration

func (*Fish) GetLocation added in v0.8.0

func (f *Fish) GetLocation() string

GetLocation returns node location

func (*Fish) GetNode added in v0.7.0

func (f *Fish) GetNode() *types.Node

GetNode returns Fish node spec

func (*Fish) GetNodeUID

func (f *Fish) GetNodeUID() types.ApplicationUID

GetNodeUID returns node UID

func (*Fish) Init

func (f *Fish) Init() error

Init initializes the Fish node

func (*Fish) LabelCreate

func (f *Fish) LabelCreate(l *types.Label) error

LabelCreate makes new Label

func (*Fish) LabelDelete

func (f *Fish) LabelDelete(uid types.LabelUID) error

LabelDelete deletes the Label by UID

func (*Fish) LabelGet

func (f *Fish) LabelGet(uid types.LabelUID) (label *types.Label, err error)

LabelGet returns Label by UID

func (*Fish) LabelList added in v0.8.0

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

LabelFind returns list of Labels that fits filters

func (*Fish) LabelListName added in v0.8.0

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

func (*Fish) MaintenanceSet added in v0.7.0

func (f *Fish) MaintenanceSet(value bool)

MaintenanceSet sets/unsets the maintenance mode which will not allow to accept the additional Applications

func (*Fish) NewUID

func (f *Fish) NewUID() uuid.UUID

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

func (*Fish) NodeActiveList

func (f *Fish) NodeActiveList() (ns []types.Node, err error)

NodeActiveList lists all the nodes in the cluster

func (*Fish) NodeCreate

func (f *Fish) NodeCreate(n *types.Node) error

NodeCreate makes new Node

func (*Fish) NodeGet

func (f *Fish) NodeGet(name string) (node *types.Node, err error)

NodeGet returns Node by it's unique name

func (*Fish) NodeList added in v0.8.0

func (f *Fish) NodeList() (ns []types.Node, err error)

NodeFind returns list of Nodes that fits filter

func (*Fish) NodePing

func (f *Fish) NodePing(node *types.Node) error

NodePing updates Node and shows that it's active

func (*Fish) NodeSave

func (f *Fish) NodeSave(node *types.Node) error

NodeSave stores Node

func (*Fish) ServiceMappingByApplicationAndDest added in v0.8.0

func (f *Fish) 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 (*Fish) ServiceMappingCreate

func (f *Fish) ServiceMappingCreate(sm *types.ServiceMapping) error

ServiceMappingCreate makes new ServiceMapping

func (*Fish) ServiceMappingDelete

func (f *Fish) ServiceMappingDelete(uid types.ServiceMappingUID) error

ServiceMappingDelete removes ServiceMapping

func (*Fish) ServiceMappingGet

func (f *Fish) ServiceMappingGet(uid types.ServiceMappingUID) (sm *types.ServiceMapping, err error)

ServiceMappingGet returns ServiceMapping by UID

func (*Fish) ServiceMappingList added in v0.8.0

func (f *Fish) ServiceMappingList() (sms []types.ServiceMapping, err error)

ServiceMappingFind returns list of ServiceMappings that fits the filter

func (*Fish) ServiceMappingListByApplication added in v0.8.0

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

ServiceMappingByApplication returns ServiceMapping list with specified ApplicationUID

func (*Fish) ServiceMappingSave

func (f *Fish) ServiceMappingSave(sm *types.ServiceMapping) error

ServiceMappingSave stores ServiceMapping

func (*Fish) ShutdownDelaySet added in v0.7.0

func (f *Fish) ShutdownDelaySet(delay time.Duration)

ShutdownDelaySet set of how much time to wait before executing the node shutdown operation

func (*Fish) ShutdownSet added in v0.7.0

func (f *Fish) ShutdownSet(value bool)

ShutdownSet tells node it need to execute graceful shutdown operation

func (*Fish) StorageVotesAdd added in v0.8.0

func (f *Fish) StorageVotesAdd(votes []types.Vote)

StorageVotesAdd puts received votes from the cluster to the list

func (*Fish) UserAuth

func (f *Fish) UserAuth(name string, password string) *types.User

UserAuth returns User if name and password are correct

func (*Fish) UserCreate

func (f *Fish) UserCreate(u *types.User) error

UserCreate makes new User

func (*Fish) UserDelete

func (f *Fish) UserDelete(name string) error

UserDelete removes User

func (*Fish) UserGet

func (f *Fish) UserGet(name string) (u *types.User, err error)

UserGet returns User by unique name

func (*Fish) UserList added in v0.8.0

func (f *Fish) UserList() (us []types.User, err error)

UserList returns list of users

func (*Fish) UserNew

func (f *Fish) UserNew(name string, password string) (string, *types.User, error)

UserNew makes new User

func (*Fish) UserSave

func (f *Fish) UserSave(u *types.User) error

UserSave stores User

func (*Fish) VoteActiveList added in v0.8.0

func (f *Fish) VoteActiveList() (votes []types.Vote)

VoteAll returns active and related storage votes

func (*Fish) VoteCreate

func (*Fish) VoteCreate(appUID types.ApplicationUID) types.Vote

VoteCreate makes new Vote

Jump to

Keyboard shortcuts

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