models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelTaskResponse

type CancelTaskResponse struct {
}

CancelTaskResponse represents that a task was canceled

type CreateTaskResponse

type CreateTaskResponse struct {
	ID string `json:"id"`
}

CreateTaskResponse represents a task submitted and approved by the system

type Executor

type Executor struct {
	// Name of the container image
	Image string `json:"image"`
	// A sequence of program arguments to execute, where the first argument is the program to execute
	Command []string `json:"command"`
	// The working directory that the command will be executed in
	WorkDir string `json:"workdir,omitempty"`
	// Path inside the container to a file which will be piped to the executor's stdin
	Stdin string `json:"stdin,omitempty"`
	// Path inside the container to a file where the executor's stdout will be written to
	Stdout string `json:"stdout,omitempty"`
	// Path inside the container to a file where the executor's stderr will be written to
	Stderr string `json:"stderr,omitempty"`
	// Environment variables to set within the container
	Env map[string]string `json:"env,omitempty"`
}

Executor describes a command to be executed, and its environment.

type ExecutorLog

type ExecutorLog struct {
	StartTime time.Time `json:"start_time"`       // Time the executor started
	EndTime   time.Time `json:"end_time"`         // Time the executor ended
	Stdout    string    `json:"stdout,omitempty"` // Stdout content
	Stderr    string    `json:"stderr,omitempty"` // Stderr content
	ExitCode  int       `json:"exit_code"`        // Exit code
}

ExecutorLog represents processing times and logs of an executor

type FileType

type FileType string

FileType can be file or directory

const (
	// File type of Input
	File FileType = "FILE"
	// Directory type of Input
	Directory FileType = "DIRECTORY"
)

type Info

type Info struct {
	CPUCores int     `json:"cpuCores"`
	RAMGb    float64 `json:"ramGb"`
}

Info has the maximum computing resources.

type Input

type Input struct {
	Name        string   `json:"name,omitempty"`
	Description string   `json:"description,omitempty"`
	URL         string   `json:"url"`
	Path        string   `json:"path"`
	Type        FileType `json:"type"`
	Content     string   `json:"content,omitempty"`
}

Input represents an input file to be used by task.

type ListTasksResponse

type ListTasksResponse struct {
	Tasks         []*Task `json:"tasks"`
	NextPageToken string  `json:"next_page_token,omitempty"`
}

ListTasksResponse represents a list of tasks previous submitted to system

type Log

type Log struct {
	// ExecutorLogs for each executor
	ExecutorLogs []*ExecutorLog `json:"logs,omitempty"`
	// Arbitrary logging metadata included by the implementation
	Metadata map[string]string `json:"metadata,omitempty"`
	// When the task started
	StartTime time.Time `json:"start_time"`
	// When the task ended
	EndTime time.Time `json:"end_time"`
	// Information about all output files
	Outputs []*OutputFileLog `json:"outputs,omitempty"`
	// System logs are any logs the system decides are relevant, which are not tied directly to an Executor process
	SystemLogs []string `json:"system_logs,omitempty"`
}

Log represents processing times and logs of a task

type Node

type Node struct {
	ID     string `json:"id" bson:"_id"`
	Host   string `json:"host"`
	Active bool   `json:"active"`
	Info   *Info  `json:"info"`

	// Usage keeps real-time allocated resources in memory. It is not stored in database.
	Usage *Usage `json:"usage" bson:"-"`
}

Node is a computing node that accepts and executes tasks. It has maximum allowed (Info) and real-time allocated computing resources (Usage). Host is used as its unique identifier.

func (*Node) AvailableCPUCores

func (n *Node) AvailableCPUCores() int

AvailableCPUCores returns amount of free CPU cores.

func (*Node) AvailableRAMGb

func (n *Node) AvailableRAMGb() float64

AvailableRAMGb returns amount of free RAM memory in GB.

func (*Node) String

func (n *Node) String() string

type Output

type Output struct {
	Name        string   `json:"name,omitempty"`
	Description string   `json:"description,omitempty"`
	URL         string   `json:"url"`
	Path        string   `json:"path"`
	Type        FileType `json:"type"`
}

Output represents a file generated by task

type OutputFileLog

type OutputFileLog struct {
	URL       string `json:"url"`
	Path      string `json:"path"`
	SizeBytes string `json:"size_bytes"`
}

OutputFileLog represents a log file

type Resources

type Resources struct {
	CPUCores    int      `json:"cpu_cores,omitempty"`
	RAMGb       float64  `json:"ram_gb,omitempty"`
	DiskGb      float64  `json:"disk_gb,omitempty"`
	Zones       []string `json:"zones,omitempty"`
	Preemptible bool     `json:"preemptible,omitempty"`
}

Resources represents computing requirements to run task

type ServiceInfo

type ServiceInfo struct {
	// Returns the name of the service
	Name string `json:"name,omitempty"`
	// Returns a documentation string
	Doc string `json:"doc,omitempty"`
	// Lists some, but not necessarily all, storage locations supported by the service.
	Storage []string `json:"storage,omitempty"`
}

ServiceInfo describes information about the service, such as storage details, resource availability, and other documentation.

type State

type State string

State of a task

const (
	// Unknown means task state is not defined
	Unknown State = "UNKNOWN"
	// Queued means task was submitted and waiting
	Queued State = "QUEUED"
	// Initializing means required files are be gathering before execution
	// for example, downloading Docker image
	Initializing State = "INITIALIZING"
	// Running means tasks is been executed by some worker node
	Running State = "RUNNING"
	// Paused is not used
	Paused State = "PAUSED"
	// Complete means task was terminated successfully, aka 0 return code
	Complete State = "COMPLETE"
	// ExecutorError means something had happen to worker node when running task
	ExecutorError State = "EXECUTOR_ERROR"
	// SystemError means something went wrong with the worker when running task
	SystemError State = "SYSTEM_ERROR"
	// Canceled means task was canceled
	Canceled State = "CANCELED"
)

type Task

type Task struct {
	ID           string            `json:"id" bson:"_id"`
	State        State             `json:"state"`
	Name         string            `json:"name,omitempty"`
	Description  string            `json:"description,omitempty"`
	Inputs       []*Input          `json:"inputs,omitempty"`
	Outputs      []*Output         `json:"outputs,omitempty"`
	Resources    *Resources        `json:"resources,omitempty"`
	Executors    []Executor        `json:"executors"`
	Volumes      []string          `json:"volumes,omitempty"`
	Tags         map[string]string `json:"tags,omitempty,omitempty"`
	Logs         *Log              `json:"logs,omitempty"`
	CreationTime time.Time         `json:"creation_time"`

	// These fields extend TES API allowing client to know which node is processing the task.
	RemoteHost   string `json:"remote_host"`
	RemoteTaskID string `json:"remote_task_id"`
}

Task is a collection of command to be executed to process data

func (*Task) Active

func (t *Task) Active() bool

GetActiveNodes returns true if task state is - Queued - Initializing - Running - Paused

func (*Task) String

func (t *Task) String() string

type Usage

type Usage struct {
	Tasks    int     `json:"tasks"`
	CPUCores int     `json:"cpuCores"`
	RAMGb    float64 `json:"ramGb"`
}

Usage has the amount of computings resources already in use.

type View

type View string

View defines which task field should be returned

const (
	// Minimal returns only task ID and state
	Minimal View = "MINIMAL"
	// Basic returns all fields except
	// - Task.ExecutorLog.Stdout
	// - Task.ExecutorLog.Stderr
	// - Input.Content
	// - TaskLog.SystemLogs
	Basic View = "BASIC"
	// Full returns all fields
	Full View = "FULL"
)

Jump to

Keyboard shortcuts

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