core

package
v1.0.0-alpha8 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 7 Imported by: 17

Documentation

Index

Constants

View Source
const (
	IN  int = 0
	OUT     = 1
	ERR     = 2
	ENV     = 3
)
View Source
const (
	WAITING int = 0
	RUNNING     = 1
	SUCCESS     = 2
	FAILED      = 3
)
View Source
const (
	PENDING  int = 0
	APPROVED     = 1
	REJECTED     = 2
)

Variables

This section is empty.

Functions

func ConvertColonyArrayToJSON

func ConvertColonyArrayToJSON(colonies []*Colony) (string, error)

func ConvertCronArrayToJSON

func ConvertCronArrayToJSON(crons []*Cron) (string, error)

func ConvertGeneratorArrayToJSON

func ConvertGeneratorArrayToJSON(generators []*Generator) (string, error)

func ConvertProcessArrayToJSON

func ConvertProcessArrayToJSON(processes []*Process) (string, error)

func ConvertProcessGraphArrayToJSON

func ConvertProcessGraphArrayToJSON(processGraphs []*ProcessGraph) (string, error)

func ConvertRuntimeArrayToJSON

func ConvertRuntimeArrayToJSON(runtimes []*Runtime) (string, error)

func GenerateRandomID

func GenerateRandomID() string

func IsAttributeArraysEqual

func IsAttributeArraysEqual(attributes1 []Attribute, attributes2 []Attribute) bool

func IsColonyArraysEqual

func IsColonyArraysEqual(colonies1 []*Colony, colonies2 []*Colony) bool

func IsCronArraysEqual

func IsCronArraysEqual(crons1 []*Cron, crons2 []*Cron) bool

func IsGeneratorArraysEqual

func IsGeneratorArraysEqual(generators1 []*Generator, generators2 []*Generator) bool

func IsProcessArraysEqual

func IsProcessArraysEqual(processes1 []*Process, processes2 []*Process) bool

func IsProcessGraphArraysEqual

func IsProcessGraphArraysEqual(processGraphs1 []*ProcessGraph, processGraphs2 []*ProcessGraph) bool

func IsRuntimeArraysEqual

func IsRuntimeArraysEqual(runtimes1 []*Runtime, runtimes2 []*Runtime) bool

Types

type Attribute

type Attribute struct {
	ID                   string `json:"attributeid"`
	TargetID             string `json:"targetid"`
	TargetColonyID       string `json:"targetcolonyid"`
	TargetProcessGraphID string `json:"targetprocessgraphid"`
	AttributeType        int    `json:"attributetype"`
	Key                  string `json:"key"`
	Value                string `json:"value"`
}

func ConvertJSONToAttribute

func ConvertJSONToAttribute(jsonString string) (Attribute, error)

func CreateAttribute

func CreateAttribute(targetID string,
	targetColonyID string,
	targetProcessGraphID string,
	attributeType int,
	key string,
	value string) Attribute

func (*Attribute) Equals

func (attribute *Attribute) Equals(attribute2 Attribute) bool

func (*Attribute) GenerateID

func (attribute *Attribute) GenerateID()

func (*Attribute) SetValue

func (attribute *Attribute) SetValue(value string)

func (*Attribute) ToJSON

func (attribute *Attribute) ToJSON() (string, error)

type Code

type Code struct {
	ID     string `json:"codeid"`
	Name   string `json:"name"`
	Bundle []byte `json:"bundle"`
	Script string `json:"script"`
}

type Colony

type Colony struct {
	ID   string `json:"colonyid"`
	Name string `json:"name"`
}

func ConvertJSONToColony

func ConvertJSONToColony(jsonString string) (*Colony, error)

func ConvertJSONToColonyArray

func ConvertJSONToColonyArray(jsonString string) ([]*Colony, error)

func CreateColony

func CreateColony(id string, name string) *Colony

func (*Colony) Equals

func (colony *Colony) Equals(colony2 *Colony) bool

func (*Colony) SetID

func (colony *Colony) SetID(id string)

func (*Colony) ToJSON

func (colony *Colony) ToJSON() (string, error)

type Conditions

type Conditions struct {
	ColonyID     string   `json:"colonyid"`
	RuntimeIDs   []string `json:"runtimeids"`
	RuntimeType  string   `json:"runtimetype"`
	Dependencies []string `json:"dependencies"`
}

type Cron

type Cron struct {
	ID                      string    `json:"cronid"`
	ColonyID                string    `json:"colonyid"`
	Name                    string    `json:"name"`
	CronExpression          string    `json:"cronexpression"`
	Interval                int       `json:"interval"`
	Random                  bool      `json:"random"`
	NextRun                 time.Time `json:"nextrun"`
	LastRun                 time.Time `json:"lastrun"`
	WorkflowSpec            string    `json:"workflowspec"`
	PrevProcessGraphID      string    `json:"prevprocessgraphid"`
	WaitForPrevProcessGraph bool      `json:"waitforprevprocessgraph"`
}

func ConvertJSONToCron

func ConvertJSONToCron(jsonString string) (*Cron, error)

func ConvertJSONToCronArray

func ConvertJSONToCronArray(jsonString string) ([]*Cron, error)

func CreateCron

func CreateCron(colonyID string, name string, cronExpression string, interval int, random bool, workflowSpec string) *Cron

func (*Cron) Equals

func (cron *Cron) Equals(cron2 *Cron) bool

func (*Cron) HasExpired

func (cron *Cron) HasExpired() bool

func (*Cron) ToJSON

func (cron *Cron) ToJSON() (string, error)

type Data

type Data struct {
	Label string `json:"label"`
}

type Edge

type Edge struct {
	ID       string `json:"id"`
	Source   string `json:"source"`
	Target   string `json:"target"`
	Animated bool   `json:"animated"`
}

type Failure

type Failure struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

func ConvertJSONToFailure

func ConvertJSONToFailure(jsonString string) (*Failure, error)

func CreateFailure

func CreateFailure(status int, message string) *Failure

func (*Failure) Equals

func (failure *Failure) Equals(failure2 *Failure) bool

func (*Failure) ToJSON

func (failure *Failure) ToJSON() (string, error)

type Generator

type Generator struct {
	ID           string    `json:"generatorid"`
	ColonyID     string    `json:"colonyid"`
	Name         string    `json:"name"`
	WorkflowSpec string    `json:"workflowspec"`
	Trigger      int       `json:"trigger"`
	LastRun      time.Time `json:"lastrun"`
}

func ConvertJSONToGenerator

func ConvertJSONToGenerator(jsonString string) (*Generator, error)

func ConvertJSONToGeneratorArray

func ConvertJSONToGeneratorArray(jsonString string) ([]*Generator, error)

func CreateGenerator

func CreateGenerator(colonyID string, name string, workflowSpec string, trigger int) *Generator

func (*Generator) Equals

func (generator *Generator) Equals(generator2 *Generator) bool

func (*Generator) ToJSON

func (generator *Generator) ToJSON() (string, error)

type GeneratorArg

type GeneratorArg struct {
	ID          string
	GeneratorID string
	ColonyID    string
	Arg         string
}

func CreateGeneratorArg

func CreateGeneratorArg(generatorID string, colonyID string, arg string) *GeneratorArg

type Location

type Location struct {
	Long float64 `json:"long"`
	Lat  float64 `json:"lat"`
}

type Node

type Node struct {
	ID       string   `json:"id"`
	Data     Data     `json:"data"`
	Position Position `json:"position"`
	Type     string   `json:"type"`
	Style    Style    `json:"style"`
}

type Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
}

type Process

type Process struct {
	ID                string      `json:"processid"`
	AssignedRuntimeID string      `json:"assignedruntimeid"`
	IsAssigned        bool        `json:"isassigned"`
	State             int         `json:"state"`
	SubmissionTime    time.Time   `json:"submissiontime"`
	StartTime         time.Time   `json:"starttime"`
	EndTime           time.Time   `json:"endtime"`
	WaitDeadline      time.Time   `json:"waitdeadline"`
	ExecDeadline      time.Time   `json:"execdeadline"`
	Retries           int         `json:"retries"`
	Attributes        []Attribute `json:"attributes"`
	ProcessSpec       ProcessSpec `json:"spec"`
	WaitForParents    bool        `json:"waitforparents"`
	Parents           []string    `json:"parents"`
	Children          []string    `json:"children"`
	ProcessGraphID    string      `json:"processgraphid"`
	Input             []string    `json:"in"`
	Output            []string    `json:"out"`
	Errors            []string    `json:"errors"`
}

func ConvertJSONToProcess

func ConvertJSONToProcess(jsonString string) (*Process, error)

func ConvertJSONToProcessArray

func ConvertJSONToProcessArray(jsonString string) ([]*Process, error)

func CreateProcess

func CreateProcess(processSpec *ProcessSpec) *Process

func CreateProcessFromDB

func CreateProcessFromDB(processSpec *ProcessSpec,
	id string,
	assignedRuntimeID string,
	isAssigned bool,
	state int,
	submissionTime time.Time,
	startTime time.Time,
	endTime time.Time,
	waitDeadline time.Time,
	execDeadline time.Time,
	errors []string,
	retries int,
	attributes []Attribute) *Process

func (*Process) AddChild

func (process *Process) AddChild(childID string)

func (*Process) AddParent

func (process *Process) AddParent(parentID string)

func (*Process) Assign

func (process *Process) Assign()

func (*Process) Clone

func (process *Process) Clone() *Process

func (*Process) Equals

func (process *Process) Equals(process2 *Process) bool

func (*Process) ProcessingTime

func (process *Process) ProcessingTime() time.Duration

func (*Process) SetAssignedRuntimeID

func (process *Process) SetAssignedRuntimeID(runtimeID string)

func (*Process) SetAttributes

func (process *Process) SetAttributes(attributes []Attribute)

func (*Process) SetEndTime

func (process *Process) SetEndTime(endTime time.Time)

func (*Process) SetProcessGraphID

func (process *Process) SetProcessGraphID(processGraphID string)

func (*Process) SetStartTime

func (process *Process) SetStartTime(startTime time.Time)

func (*Process) SetState

func (process *Process) SetState(state int)

func (*Process) SetSubmissionTime

func (process *Process) SetSubmissionTime(submissionTime time.Time)

func (*Process) ToJSON

func (process *Process) ToJSON() (string, error)

func (*Process) Unassign

func (process *Process) Unassign()

func (*Process) WaitingTime

func (process *Process) WaitingTime() time.Duration

type ProcessGraph

type ProcessGraph struct {
	ID             string    `json:"processgraphid"`
	ColonyID       string    `json:"colonyid"`
	Roots          []string  `json:"rootprocessids"`
	State          int       `json:"state"`
	SubmissionTime time.Time `json:"submissiontime"`
	StartTime      time.Time `json:"starttime"`
	EndTime        time.Time `json:"endtime"`
	ProcessIDs     []string  `json:"processids"`
	Nodes          []Node    `json:"nodes"`
	Edges          []Edge    `json:"edges"`
	// contains filtered or unexported fields
}

func ConvertJSONToProcessGraph

func ConvertJSONToProcessGraph(jsonString string) (*ProcessGraph, error)

func ConvertJSONToProcessGraphArray

func ConvertJSONToProcessGraphArray(jsonString string) ([]*ProcessGraph, error)

func ConvertJSONToProcessGraphWithStorage

func ConvertJSONToProcessGraphWithStorage(jsonString string) (*ProcessGraph, error)

func CreateProcessGraph

func CreateProcessGraph(colonyID string) (*ProcessGraph, error)

func (*ProcessGraph) AddRoot

func (graph *ProcessGraph) AddRoot(processID string)

func (*ProcessGraph) Depth

func (graph *ProcessGraph) Depth(childProcessID string) (int, error)

func (*ProcessGraph) Equals

func (graph *ProcessGraph) Equals(graph2 *ProcessGraph) bool

func (*ProcessGraph) FailedProcesses

func (graph *ProcessGraph) FailedProcesses() (int, error)

func (*ProcessGraph) GetRoot

func (graph *ProcessGraph) GetRoot(childProcessID string) (*Process, error)

func (*ProcessGraph) Iterate

func (graph *ProcessGraph) Iterate(visitFunc func(process *Process) error) error

func (*ProcessGraph) Leaves

func (graph *ProcessGraph) Leaves() ([]string, error)

func (*ProcessGraph) Processes

func (graph *ProcessGraph) Processes() (int, error)

func (*ProcessGraph) Resolve

func (graph *ProcessGraph) Resolve() error

func (*ProcessGraph) RunningProcesses

func (graph *ProcessGraph) RunningProcesses() (int, error)

func (*ProcessGraph) SetStorage

func (graph *ProcessGraph) SetStorage(storage ProcessGraphStorage)

func (*ProcessGraph) SuccessfulProcesses

func (graph *ProcessGraph) SuccessfulProcesses() (int, error)

func (*ProcessGraph) ToJSON

func (graph *ProcessGraph) ToJSON() (string, error)

func (*ProcessGraph) UpdateProcessIDs

func (graph *ProcessGraph) UpdateProcessIDs() error

func (*ProcessGraph) WaitForParents

func (graph *ProcessGraph) WaitForParents() (int, error)

func (*ProcessGraph) WaitProcesses

func (graph *ProcessGraph) WaitProcesses() (int, error)

type ProcessGraphStorage

type ProcessGraphStorage interface {
	GetProcessByID(processID string) (*Process, error)
	SetProcessState(processID string, state int) error
	SetWaitForParents(processID string, waitForParent bool) error
	SetProcessGraphState(processGraphID string, state int) error
}

type ProcessSpec

type ProcessSpec struct {
	Name        string            `json:"name"`
	Func        string            `json:"func"`
	Args        []string          `json:"args"`
	Priority    int               `json:"priority"`
	MaxWaitTime int               `json:"maxwaittime"`
	MaxExecTime int               `json:"maxexectime"`
	MaxRetries  int               `json:"maxretries"`
	Conditions  Conditions        `json:"conditions"`
	Env         map[string]string `json:"env"`
}

func ConvertJSONToProcessSpec

func ConvertJSONToProcessSpec(jsonString string) (*ProcessSpec, error)

func CreateEmptyProcessSpec

func CreateEmptyProcessSpec() *ProcessSpec

func CreateProcessSpec

func CreateProcessSpec(name string, fn string, args []string, colonyID string, runtimeIDs []string, runtimeType string, maxWaitTime int, maxExecTime int, maxRetries int, env map[string]string, dependencies []string, priority int) *ProcessSpec

func (*ProcessSpec) AddDependency

func (processSpec *ProcessSpec) AddDependency(dependency string)

func (*ProcessSpec) Equals

func (processSpec *ProcessSpec) Equals(processSpec2 *ProcessSpec) bool

func (*ProcessSpec) ToJSON

func (processSpec *ProcessSpec) ToJSON() (string, error)

type Runtime

type Runtime struct {
	ID                string    `json:"runtimeid"`
	RuntimeType       string    `json:"runtimetype"`
	Name              string    `json:"name"`
	ColonyID          string    `json:"colonyid"`
	CPU               string    `json:"cpu"`
	Cores             int       `json:"cores"`
	Mem               int       `json:"mem"`
	GPU               string    `json:"gpu"`
	GPUs              int       `json:"gpus"`
	State             int       `json:"state"`
	CommissionTime    time.Time `json:"commissiontime"`
	LastHeardFromTime time.Time `json:"lastheardfromtime"`
	Location          Location  `json:"location"`
}

func ConvertJSONToRuntime

func ConvertJSONToRuntime(jsonString string) (*Runtime, error)

func ConvertJSONToRuntimeArray

func ConvertJSONToRuntimeArray(jsonString string) ([]*Runtime, error)

func CreateRuntime

func CreateRuntime(id string,
	runtimeType string,
	name string,
	colonyID string,
	cpu string,
	cores int,
	mem int,
	gpu string,
	gpus int,
	commissionTime time.Time,
	lastHeardFromTime time.Time) *Runtime

func CreateRuntimeFromDB

func CreateRuntimeFromDB(id string,
	runtimeType string,
	name string,
	colonyID string,
	cpu string,
	cores int,
	mem int,
	gpu string,
	gpus int,
	state int,
	commissionTime time.Time,
	lastHeardFromTime time.Time) *Runtime

func (*Runtime) Approve

func (runtime *Runtime) Approve()

func (*Runtime) Equals

func (runtime *Runtime) Equals(runtime2 *Runtime) bool

func (*Runtime) IsApproved

func (runtime *Runtime) IsApproved() bool

func (*Runtime) IsPending

func (runtime *Runtime) IsPending() bool

func (*Runtime) IsRejected

func (runtime *Runtime) IsRejected() bool

func (*Runtime) Reject

func (runtime *Runtime) Reject()

func (*Runtime) SetColonyID

func (runtime *Runtime) SetColonyID(colonyID string)

func (*Runtime) SetID

func (runtime *Runtime) SetID(id string)

func (*Runtime) ToJSON

func (runtime *Runtime) ToJSON() (string, error)

type Statistics

type Statistics struct {
	Colonies            int `json:"colonies"`
	Runtimes            int `json:"runtimes"`
	WaitingProcesses    int `json:"waitingprocesses"`
	RunningProcesses    int `json:"runningprocesses"`
	SuccessfulProcesses int `json:"successfulprocesses"`
	FailedProcesses     int `json:"failedprocesses"`
	WaitingWorkflows    int `json:"waitingworkflows"`
	RunningWorkflows    int `json:"runningworkflows"`
	SuccessfulWorkflows int `json:"successfulworkflows"`
	FailedWorkflows     int `json:"failedworkflows"`
}

func ConvertJSONToStatistics

func ConvertJSONToStatistics(jsonString string) (*Statistics, error)

func CreateStatistics

func CreateStatistics(colonies int,
	runtimes int,
	waitingProcesses int,
	runningProcesses int,
	successfulProcesses int,
	failedProcesses int,
	waitingWorkflows int,
	runningWorkflows int,
	successfulWorkflows int,
	failedWorkflows int) *Statistics

func (*Statistics) Equals

func (stat *Statistics) Equals(stat2 *Statistics) bool

func (*Statistics) ToJSON

func (stat *Statistics) ToJSON() (string, error)

type Style

type Style struct {
	Color      string `json:"color"`
	Background string `json:"background"`
}

type WorkflowSpec

type WorkflowSpec struct {
	ColonyID     string        `json:"colonyid"`
	ProcessSpecs []ProcessSpec `json:"processspecs"`
}

func ConvertJSONToWorkflowSpec

func ConvertJSONToWorkflowSpec(jsonString string) (*WorkflowSpec, error)

func CreateWorkflowSpec

func CreateWorkflowSpec(colonyID string) *WorkflowSpec

func (*WorkflowSpec) AddProcessSpec

func (workflowSpec *WorkflowSpec) AddProcessSpec(processSpec *ProcessSpec)

func (*WorkflowSpec) Equals

func (workflowSpec *WorkflowSpec) Equals(workflowSpec2 *WorkflowSpec) bool

func (*WorkflowSpec) ToJSON

func (workflowSpec *WorkflowSpec) ToJSON() (string, error)

Jump to

Keyboard shortcuts

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