database

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeDatabase added in v1.9.0

type AttributeDatabase interface {
	AddAttribute(attribute core.Attribute) error
	AddAttributes(attribute []core.Attribute) error
	GetAttributeByID(attributeID string) (core.Attribute, error)
	GetAttributesByColonyName(colonyName string) ([]core.Attribute, error)
	GetAttribute(targetID string, key string, attributeType int) (core.Attribute, error)
	GetAttributes(targetID string) ([]core.Attribute, error)
	GetAttributesByType(targetID string, attributeType int) ([]core.Attribute, error)
	UpdateAttribute(attribute core.Attribute) error
	RemoveAttributeByID(attributeID string) error
	RemoveAllAttributesByColonyName(colonyName string) error
	RemoveAllAttributesByColonyNameWithState(colonyName string, state int) error
	RemoveAllAttributesByProcessGraphID(processGraphID string) error
	RemoveAllAttributesInProcessGraphsByColonyName(colonyName string) error
	RemoveAllAttributesInProcessGraphsByColonyNameWithState(colonyName string, state int) error
	RemoveAttributesByTargetID(targetID string, attributeType int) error
	RemoveAllAttributesByTargetID(targetID string) error
	RemoveAllAttributes() error
}

type BlueprintDatabase added in v1.9.3

type BlueprintDatabase interface {
	// BlueprintDefinition methods
	AddBlueprintDefinition(sd *core.BlueprintDefinition) error
	GetBlueprintDefinitionByID(id string) (*core.BlueprintDefinition, error)
	GetBlueprintDefinitionByName(namespace, name string) (*core.BlueprintDefinition, error)
	GetBlueprintDefinitions() ([]*core.BlueprintDefinition, error)
	GetBlueprintDefinitionsByNamespace(namespace string) ([]*core.BlueprintDefinition, error)
	GetBlueprintDefinitionsByGroup(group string) ([]*core.BlueprintDefinition, error)
	GetBlueprintDefinitionByKind(kind string) (*core.BlueprintDefinition, error)
	UpdateBlueprintDefinition(sd *core.BlueprintDefinition) error
	RemoveBlueprintDefinitionByID(id string) error
	RemoveBlueprintDefinitionByName(namespace, name string) error
	CountBlueprintDefinitions() (int, error)

	// Blueprint methods
	AddBlueprint(blueprint *core.Blueprint) error
	GetBlueprintByID(id string) (*core.Blueprint, error)
	GetBlueprintByName(namespace, name string) (*core.Blueprint, error)
	GetBlueprints() ([]*core.Blueprint, error)
	GetBlueprintsByNamespace(namespace string) ([]*core.Blueprint, error)
	GetBlueprintsByKind(kind string) ([]*core.Blueprint, error)
	GetBlueprintsByNamespaceAndKind(namespace, kind string) ([]*core.Blueprint, error)
	GetBlueprintsByNamespaceKindAndLocation(namespace, kind, locationName string) ([]*core.Blueprint, error)
	UpdateBlueprint(blueprint *core.Blueprint) error
	UpdateBlueprintStatus(id string, status map[string]interface{}) error
	RemoveBlueprintByID(id string) error
	RemoveBlueprintByName(namespace, name string) error
	RemoveBlueprintsByNamespace(namespace string) error
	CountBlueprints() (int, error)
	CountBlueprintsByNamespace(namespace string) (int, error)

	// BlueprintHistory methods
	AddBlueprintHistory(history *core.BlueprintHistory) error
	GetBlueprintHistory(blueprintID string, limit int) ([]*core.BlueprintHistory, error)
	GetBlueprintHistoryByGeneration(blueprintID string, generation int64) (*core.BlueprintHistory, error)
	RemoveBlueprintHistory(blueprintID string) error
}

type ColonyDatabase added in v1.9.0

type ColonyDatabase interface {
	AddColony(colony *core.Colony) error
	GetColonies() ([]*core.Colony, error)
	GetColonyByID(id string) (*core.Colony, error)
	GetColonyByName(name string) (*core.Colony, error)
	RenameColony(colonyName string, newColonyName string) error
	RemoveColonyByName(colonyName string) error
	CountColonies() (int, error)
}

type CronDatabase added in v1.9.0

type CronDatabase interface {
	AddCron(cron *core.Cron) error
	UpdateCron(cronID string, nextRun time.Time, lastRun time.Time, lastProcessGraphID string) error
	GetCronByID(cronID string) (*core.Cron, error)
	GetCronByName(colonyName string, cronName string) (*core.Cron, error)
	FindCronsByColonyName(colonyName string, count int) ([]*core.Cron, error)
	FindAllCrons() ([]*core.Cron, error)
	RemoveCronByID(cronID string) error
	RemoveAllCronsByColonyName(colonyName string) error
}

type DatabaseConfig added in v1.9.0

type DatabaseConfig struct {
	Type        DatabaseType
	Host        string
	Port        int
	User        string
	Password    string
	Name        string
	Prefix      string
	TimescaleDB bool

	DataDir string // Future use
}

type DatabaseCore added in v1.9.0

type DatabaseCore interface {
	Close()
	Initialize() error
	Drop() error
	Lock(timeout int) error
	Unlock() error
	ApplyRetentionPolicy(retentionPeriod int64) error
}

type DatabaseType added in v1.9.0

type DatabaseType string
const (
	PostgreSQL DatabaseType = "postgresql"
)

type ExecutorDatabase added in v1.9.0

type ExecutorDatabase interface {
	AddExecutor(executor *core.Executor) error
	SetAllocations(colonyName string, executorName string, allocations core.Allocations) error
	GetExecutors() ([]*core.Executor, error)
	GetExecutorByID(executorID string) (*core.Executor, error)
	GetExecutorsByColonyName(colonyName string) ([]*core.Executor, error)
	GetExecutorByName(colonyName string, executorName string) (*core.Executor, error)
	GetExecutorsByBlueprintID(blueprintID string) ([]*core.Executor, error)
	ApproveExecutor(executor *core.Executor) error
	RejectExecutor(executor *core.Executor) error
	MarkAlive(executor *core.Executor) error
	RemoveExecutorByName(colonyName string, executorName string) error
	RemoveExecutorsByColonyName(colonyName string) error
	CountExecutors() (int, error)
	CountExecutorsByColonyName(colonyName string) (int, error)
	CountExecutorsByColonyNameAndState(colonyName string, state int) (int, error)
	UpdateExecutorCapabilities(colonyName string, executorName string, capabilities core.Capabilities) error
}

type FileDatabase added in v1.9.0

type FileDatabase interface {
	AddFile(file *core.File) error
	GetFileByID(colonyName string, fileID string) (*core.File, error)
	GetLatestFileByName(colonyName string, label string, name string) ([]*core.File, error)
	GetFileByName(colonyName string, label string, name string) ([]*core.File, error)
	GetFilenamesByLabel(colonyName string, label string) ([]string, error)
	GetFileDataByLabel(colonyName string, label string) ([]*core.FileData, error)
	RemoveFileByID(colonyName string, fileID string) error
	RemoveFileByName(colonyName string, label string, name string) error
	GetFileLabels(colonyName string) ([]*core.Label, error)
	GetFileLabelsByName(colonyName string, name string, exact bool) ([]*core.Label, error)
	CountFilesWithLabel(colonyName string, label string) (int, error)
	CountFiles(colonyName string) (int, error)
}

type FunctionDatabase added in v1.9.0

type FunctionDatabase interface {
	AddFunction(function *core.Function) error
	GetFunctionByID(functionID string) (*core.Function, error)
	GetFunctionsByExecutorName(colonyName string, executorName string) ([]*core.Function, error)
	GetFunctionsByColonyName(colonyName string) ([]*core.Function, error)
	GetFunctionsByExecutorAndName(colonyName string, executorName string, name string) (*core.Function, error)
	UpdateFunctionStats(colonyName string, executorName string, name string, counter int, minWaitTime float64, maxWaitTime float64, minExecTime float64, maxExecTime float64, avgWaitTime float64, avgExecTime float64) error
	RemoveFunctionByID(functionID string) error
	RemoveFunctionByName(colonyName string, executorName string, name string) error
	RemoveFunctionsByExecutorName(colonyName string, executorName string) error
	RemoveFunctionsByColonyName(colonyName string) error
	RemoveFunctions() error
}

type GeneratorDatabase added in v1.9.0

type GeneratorDatabase interface {
	AddGenerator(generator *core.Generator) error
	SetGeneratorLastRun(generatorID string) error
	SetGeneratorFirstPack(generatorID string) error
	GetGeneratorByID(generatorID string) (*core.Generator, error)
	GetGeneratorByName(colonyName string, name string) (*core.Generator, error)
	FindGeneratorsByColonyName(colonyName string, count int) ([]*core.Generator, error)
	FindAllGenerators() ([]*core.Generator, error)
	RemoveGeneratorByID(generatorID string) error
	RemoveAllGeneratorsByColonyName(colonyName string) error
	AddGeneratorArg(generatorArg *core.GeneratorArg) error
	GetGeneratorArgs(generatorID string, count int) ([]*core.GeneratorArg, error)
	CountGeneratorArgs(generatorID string) (int, error)
	RemoveGeneratorArgByID(generatorArgsID string) error
	RemoveAllGeneratorArgsByGeneratorID(generatorID string) error
	RemoveAllGeneratorArgsByColonyName(generatorID string) error
}

type LocationDatabase added in v1.9.6

type LocationDatabase interface {
	AddLocation(location *core.Location) error
	GetLocationsByColonyName(colonyName string) ([]*core.Location, error)
	GetLocationByID(locationID string) (*core.Location, error)
	GetLocationByName(colonyName string, name string) (*core.Location, error)
	RemoveLocationByID(locationID string) error
	RemoveLocationByName(colonyName string, name string) error
	RemoveLocationsByColonyName(colonyName string) error
}

type LogDatabase added in v1.9.0

type LogDatabase interface {
	AddLog(processID string, colonyName string, executorName string, timestamp int64, msg string) error
	GetLogsByProcessID(processID string, limit int) ([]*core.Log, error)
	GetLogsByProcessIDSince(processID string, limit int, since int64) ([]*core.Log, error)
	GetLogsByProcessIDLatest(processID string, limit int) ([]*core.Log, error)
	GetLogsByExecutor(executorName string, limit int) ([]*core.Log, error)
	GetLogsByExecutorSince(executorName string, limit int, since int64) ([]*core.Log, error)
	GetLogsByExecutorLatest(executorName string, limit int) ([]*core.Log, error)
	RemoveLogsByColonyName(colonyName string) error
	CountLogs(colonyName string) (int, error)
	SearchLogs(colonyName string, text string, days int, count int) ([]*core.Log, error)
}

type ProcessDatabase added in v1.9.0

type ProcessDatabase interface {
	AddProcess(process *core.Process) error
	GetProcesses() ([]*core.Process, error)
	GetProcessByID(processID string) (*core.Process, error)
	FindProcessesByColonyName(colonyName string, seconds int, state int) ([]*core.Process, error)
	FindProcessesByExecutorID(colonyName string, executorID string, seconds int, state int) ([]*core.Process, error)
	FindWaitingProcesses(colonyName string, executorType string, label string, initiator string, count int) ([]*core.Process, error)
	FindRunningProcesses(colonyName string, executorType string, label string, initiator string, count int) ([]*core.Process, error)
	FindSuccessfulProcesses(colonyName string, executorType string, label string, initiator string, count int) ([]*core.Process, error)
	FindFailedProcesses(colonyName string, executorType string, label string, initiator string, count int) ([]*core.Process, error)
	FindAllRunningProcesses() ([]*core.Process, error)
	FindAllWaitingProcesses() ([]*core.Process, error)
	FindCandidates(colonyName string, executorType string, executorLocationName string, cpu int64, memory int64, storage int64, nodes int, processes int, processesPerNode int, count int) ([]*core.Process, error)
	FindCandidatesByName(colonyName string, executorName string, executorType string, executorLocationName string, cpu int64, memory int64, storage int64, nodes int, processes int, processesPerNode int, count int) ([]*core.Process, error)
	RemoveProcessByID(processID string) error
	RemoveAllProcesses() error
	RemoveAllWaitingProcessesByColonyName(colonyName string) error
	RemoveAllRunningProcessesByColonyName(colonyName string) error
	RemoveAllSuccessfulProcessesByColonyName(colonyName string) error
	RemoveAllFailedProcessesByColonyName(colonyName string) error
	RemoveAllProcessesByColonyName(colonyName string) error
	RemoveAllProcessesByProcessGraphID(processGraphID string) error
	RemoveAllProcessesInProcessGraphsByColonyName(colonyName string) error
	ResetProcess(process *core.Process) error
	SetInput(processID string, output []interface{}) error
	SetOutput(processID string, output []interface{}) error
	SetErrors(processID string, errs []string) error
	SetProcessState(processID string, state int) error
	SetParents(processID string, parents []string) error
	SetChildren(processID string, children []string) error
	SetWaitForParents(processID string, waitingForParent bool) error
	Assign(executorID string, process *core.Process) error
	SelectAndAssign(colonyName string, executorID string, executorName string, executorType string, executorLocation string, cpu int64, memory int64, storage int64, nodes int, processes int, processesPerNode int, count int) (*core.Process, error)
	Unassign(process *core.Process) error
	MarkSuccessful(processID string) (float64, float64, error)
	MarkFailed(processID string, errs []string) error
	CountProcesses() (int, error)
	CountWaitingProcesses() (int, error)
	CountRunningProcesses() (int, error)
	CountSuccessfulProcesses() (int, error)
	CountFailedProcesses() (int, error)
	CountWaitingProcessesByColonyName(colonyName string) (int, error)
	CountRunningProcessesByColonyName(colonyName string) (int, error)
	CountSuccessfulProcessesByColonyName(colonyName string) (int, error)
	CountFailedProcessesByColonyName(colonyName string) (int, error)
}

type ProcessGraphDatabase added in v1.9.0

type ProcessGraphDatabase interface {
	AddProcessGraph(processGraph *core.ProcessGraph) error
	GetProcessGraphByID(processGraphID string) (*core.ProcessGraph, error)
	SetProcessGraphState(processGraphID string, state int) error
	FindWaitingProcessGraphs(colonyName string, count int) ([]*core.ProcessGraph, error)
	FindRunningProcessGraphs(colonyName string, count int) ([]*core.ProcessGraph, error)
	FindSuccessfulProcessGraphs(colonyName string, count int) ([]*core.ProcessGraph, error)
	FindFailedProcessGraphs(colonyName string, count int) ([]*core.ProcessGraph, error)
	RemoveProcessGraphByID(processGraphID string) error
	RemoveAllProcessGraphsByColonyName(colonyName string) error
	RemoveAllWaitingProcessGraphsByColonyName(colonyName string) error
	RemoveAllRunningProcessGraphsByColonyName(colonyName string) error
	RemoveAllSuccessfulProcessGraphsByColonyName(colonyName string) error
	RemoveAllFailedProcessGraphsByColonyName(colonyName string) error
	CountWaitingProcessGraphs() (int, error)
	CountRunningProcessGraphs() (int, error)
	CountSuccessfulProcessGraphs() (int, error)
	CountFailedProcessGraphs() (int, error)
	CountWaitingProcessGraphsByColonyName(colonyName string) (int, error)
	CountRunningProcessGraphsByColonyName(colonyName string) (int, error)
	CountSuccessfulProcessGraphsByColonyName(colonyName string) (int, error)
	CountFailedProcessGraphsByColonyName(colonyName string) (int, error)
}

type ProcessLookup added in v1.7.7

type ProcessLookup interface {
	FindCandidates(colonyName string, executorType string, executorLocationName string, cpu int64, memory int64, storage int64, nodes int, processes int, processesPerNode int, count int) ([]*core.Process, error)
	FindCandidatesByName(colonyName string, executorName string, executorType string, executorLocationName string, cpu int64, memory int64, storage int64, nodes int, processes int, processesPerNode int, count int) ([]*core.Process, error)
}

type SecurityDatabase added in v1.9.0

type SecurityDatabase interface {
	SetServerID(oldServerID, newServerID string) error
	GetServerID() (string, error)
	ChangeColonyID(colonyName string, oldColonyID, newColonyID string) error
	ChangeUserID(colonyName string, oldUserID, newUserID string) error
	ChangeExecutorID(colonyName string, oldExecutorID, newExecutorID string) error
}

type SnapshotDatabase added in v1.9.0

type SnapshotDatabase interface {
	CreateSnapshot(colonyName string, label string, name string) (*core.Snapshot, error)
	GetSnapshotByID(colonNamey string, snapshotID string) (*core.Snapshot, error)
	GetSnapshotsByColonyName(colonyName string) ([]*core.Snapshot, error)
	RemoveSnapshotByID(colonyName string, snapshotID string) error
	GetSnapshotByName(colonyName string, name string) (*core.Snapshot, error)
	RemoveSnapshotByName(colonyName string, name string) error
	RemoveSnapshotsByColonyName(colonyName string) error
}

type UserDatabase added in v1.9.0

type UserDatabase interface {
	AddUser(user *core.User) error
	GetUsersByColonyName(colonyName string) ([]*core.User, error)
	GetUserByID(colonyName string, userID string) (*core.User, error)
	GetUserByName(colonyName string, name string) (*core.User, error)
	RemoveUserByID(colonyName string, userID string) error
	RemoveUserByName(colonyName string, name string) error
	RemoveUsersByColonyName(colonyName string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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