Documentation
¶
Overview ¶
Package fish core defines all the internals of the Fish processes
Index ¶
- Constants
- type ClusterInterface
- type Config
- type ConfigDriver
- type Fish
- func (f *Fish) ApplicationCreate(a *types.Application) error
- func (f *Fish) ApplicationDelete(uid types.ApplicationUID) (err error)
- func (f *Fish) ApplicationGet(uid types.ApplicationUID) (a *types.Application, err error)
- func (f *Fish) ApplicationIsAllocated(appUID types.ApplicationUID) (err error)
- func (f *Fish) ApplicationList() (as []types.Application, err error)
- func (f *Fish) ApplicationListGetStatusNew() (as []types.Application, err error)
- func (f *Fish) ApplicationResourceAccessCreate(ra *types.ApplicationResourceAccess) error
- func (f *Fish) ApplicationResourceAccessDelete(uid types.ApplicationResourceAccessUID) error
- func (f *Fish) ApplicationResourceAccessDeleteByResource(appresUID types.ApplicationResourceUID) error
- func (f *Fish) ApplicationResourceAccessList() (ra []types.ApplicationResourceAccess, err error)
- func (f *Fish) ApplicationResourceAccessSingleUseKey(username string, key string) (*types.ApplicationResourceAccess, error)
- func (f *Fish) ApplicationResourceAccessSingleUsePasswordHash(username string, hash string) (*types.ApplicationResourceAccess, error)
- func (f *Fish) ApplicationResourceCreate(r *types.ApplicationResource) error
- func (f *Fish) ApplicationResourceDelete(uid types.ApplicationResourceUID) error
- func (f *Fish) ApplicationResourceGet(uid types.ApplicationResourceUID) (res *types.ApplicationResource, err error)
- func (f *Fish) ApplicationResourceGetByApplication(appUID types.ApplicationUID) (res *types.ApplicationResource, err error)
- func (f *Fish) ApplicationResourceGetByIP(ip string) (res *types.ApplicationResource, err error)
- func (f *Fish) ApplicationResourceList() (rs []types.ApplicationResource, err error)
- func (f *Fish) ApplicationResourceListNode(nodeUID types.NodeUID) (rs []types.ApplicationResource, err error)
- func (f *Fish) ApplicationResourceSave(res *types.ApplicationResource) error
- func (f *Fish) ApplicationStateCreate(as *types.ApplicationState) error
- func (f *Fish) ApplicationStateDelete(uid types.ApplicationStateUID) (err error)
- func (f *Fish) ApplicationStateGet(uid types.ApplicationStateUID) (as *types.ApplicationState, err error)
- func (f *Fish) ApplicationStateGetByApplication(appUID types.ApplicationUID) (state *types.ApplicationState, err error)
- func (*Fish) ApplicationStateIsActive(status types.ApplicationStatus) bool
- func (f *Fish) ApplicationStateList() (ass []types.ApplicationState, err error)
- func (f *Fish) ApplicationStateListByApplication(appUID types.ApplicationUID) (states []types.ApplicationState, err error)
- func (f *Fish) ApplicationStateListLatest() (out []types.ApplicationState, err error)
- func (f *Fish) ApplicationTaskCreate(at *types.ApplicationTask) error
- func (f *Fish) ApplicationTaskDelete(uid types.ApplicationTaskUID) (err error)
- func (f *Fish) ApplicationTaskGet(uid types.ApplicationTaskUID) (at *types.ApplicationTask, err error)
- func (f *Fish) ApplicationTaskList() (at []types.ApplicationTask, err error)
- func (f *Fish) ApplicationTaskListByApplication(uid types.ApplicationUID) (at []types.ApplicationTask, err error)
- func (f *Fish) ApplicationTaskListByApplicationAndWhen(appUID types.ApplicationUID, when types.ApplicationStatus) (at []types.ApplicationTask, err error)
- func (f *Fish) ApplicationTaskSave(at *types.ApplicationTask) error
- func (f *Fish) CleanupDB()
- func (f *Fish) Close()
- func (f *Fish) CompactDB()
- func (f *Fish) GetCfg() Config
- func (f *Fish) GetLocation() string
- func (f *Fish) GetNode() *types.Node
- func (f *Fish) GetNodeUID() types.ApplicationUID
- func (f *Fish) Init() error
- func (f *Fish) LabelCreate(l *types.Label) error
- func (f *Fish) LabelDelete(uid types.LabelUID) error
- func (f *Fish) LabelGet(uid types.LabelUID) (label *types.Label, err error)
- func (f *Fish) LabelList(filters types.LabelListGetParams) (labels []types.Label, err error)
- func (f *Fish) LabelListName(name string) (labels []types.Label, err error)
- func (f *Fish) MaintenanceSet(value bool)
- func (f *Fish) NewUID() uuid.UUID
- func (f *Fish) NodeActiveList() (ns []types.Node, err error)
- func (f *Fish) NodeCreate(n *types.Node) error
- func (f *Fish) NodeGet(name string) (node *types.Node, err error)
- func (f *Fish) NodeList() (ns []types.Node, err error)
- func (f *Fish) NodePing(node *types.Node) error
- func (f *Fish) NodeSave(node *types.Node) error
- func (f *Fish) ServiceMappingByApplicationAndDest(appUID types.ApplicationUID, dest string) string
- func (f *Fish) ServiceMappingCreate(sm *types.ServiceMapping) error
- func (f *Fish) ServiceMappingDelete(uid types.ServiceMappingUID) error
- func (f *Fish) ServiceMappingGet(uid types.ServiceMappingUID) (sm *types.ServiceMapping, err error)
- func (f *Fish) ServiceMappingList() (sms []types.ServiceMapping, err error)
- func (f *Fish) ServiceMappingListByApplication(appUID types.ApplicationUID) (sms []types.ServiceMapping, err error)
- func (f *Fish) ServiceMappingSave(sm *types.ServiceMapping) error
- func (f *Fish) ShutdownDelaySet(delay time.Duration)
- func (f *Fish) ShutdownSet(value bool)
- func (f *Fish) StorageVotesAdd(votes []types.Vote)
- func (f *Fish) UserAuth(name string, password string) *types.User
- func (f *Fish) UserCreate(u *types.User) error
- func (f *Fish) UserDelete(name string) error
- func (f *Fish) UserGet(name string) (u *types.User, err error)
- func (f *Fish) UserList() (us []types.User, err error)
- func (f *Fish) UserNew(name string, password string) (string, *types.User, error)
- func (f *Fish) UserSave(u *types.User) error
- func (f *Fish) VoteActiveList() (votes []types.Vote)
- func (*Fish) VoteCreate(appUID types.ApplicationUID) types.Vote
Constants ¶
const DefaultDBCleanupDelay = 10 * time.Minute
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
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 ¶
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 (*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) GetLocation ¶ added in v0.8.0
GetLocation returns node location
func (*Fish) GetNodeUID ¶
func (f *Fish) GetNodeUID() types.ApplicationUID
GetNodeUID returns node UID
func (*Fish) LabelCreate ¶
LabelCreate makes new Label
func (*Fish) LabelDelete ¶
LabelDelete deletes the Label by UID
func (*Fish) LabelListName ¶ added in v0.8.0
func (*Fish) MaintenanceSet ¶ added in v0.7.0
MaintenanceSet sets/unsets the maintenance mode which will not allow to accept the additional Applications
func (*Fish) NodeActiveList ¶
NodeActiveList lists all the nodes in the cluster
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
ShutdownDelaySet set of how much time to wait before executing the node shutdown operation
func (*Fish) ShutdownSet ¶ added in v0.7.0
ShutdownSet tells node it need to execute graceful shutdown operation
func (*Fish) StorageVotesAdd ¶ added in v0.8.0
StorageVotesAdd puts received votes from the cluster to the list
func (*Fish) VoteActiveList ¶ added in v0.8.0
VoteAll returns active and related storage votes
func (*Fish) VoteCreate ¶
func (*Fish) VoteCreate(appUID types.ApplicationUID) types.Vote
VoteCreate makes new Vote