worker

package
v0.0.0-...-a2df99d Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 12 Imported by: 0

README

  • a worker represents a physical or a virtuel machine
  • a worker is the worker component of the orchestration system that runs on that machine (physical or vm)
flowchart TB
  subgraph Galago
    direction TB
    subgraph OrchestrationSystem
      direction TB
      Manager --> Worker1
      Manager --> Worker2
      Manager --> Worker3
    end
    
    direction BT
    subgraph Front
      direction BT
      LoadBalancer --> Worker1
      LoadBalancer --> Worker2
      LoadBalancer --> Worker3
    end

  end

it's the software that runs on a node

Roles:

  • Run tasks as Wasm "runners" (define what is a runner => go program with runtime that load the wasm file)
  • Accept tasks to run from a manager
  • Provide statistics to the manager for the purpose of scheduling tasks)
  • Keep track of its tasks and their state

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	Address  string
	Port     string
	Worker   *Worker
	Router   *chi.Mux
	Settings settings.Settings
}

func (*Api) AddTaskHandler

func (a *Api) AddTaskHandler(responseWriter http.ResponseWriter, request *http.Request)

func (*Api) GetDefaultRevisionsListHandler

func (a *Api) GetDefaultRevisionsListHandler(responseWriter http.ResponseWriter, request *http.Request)

func (*Api) GetFunctionsListHandler

func (a *Api) GetFunctionsListHandler(responseWriter http.ResponseWriter, request *http.Request)

func (*Api) GetTaskInfoHandler

func (a *Api) GetTaskInfoHandler(responseWriter http.ResponseWriter, request *http.Request)

func (*Api) GetTasksListHandler

func (a *Api) GetTasksListHandler(responseWriter http.ResponseWriter, request *http.Request)

func (*Api) InitRouter

func (a *Api) InitRouter()

func (*Api) Start

func (a *Api) Start()

func (*Api) StopTaskHandler

func (a *Api) StopTaskHandler(responseWriter http.ResponseWriter, request *http.Request)

func (*Api) SwitchFunctionRevisionHandler

func (a *Api) SwitchFunctionRevisionHandler(responseWriter http.ResponseWriter, request *http.Request)

type ErrResponse

type ErrResponse struct {
	HTTPStatusCode int
	Message        string
}

type Worker

type Worker struct {
	Queue     queue.Queue
	TasksDb   map[uuid.UUID]*task.Task
	TaskCount int // keep track of tasks a worker has at any given time
	Name      string
}

func (*Worker) AddTask

func (worker *Worker) AddTask(t *task.Task)

func (*Worker) Metrics

func (worker *Worker) Metrics()

func (*Worker) PersistTask

func (worker *Worker) PersistTask(t *task.Task)

func (*Worker) RunTask

func (worker *Worker) RunTask() task.WasmRunnerResult

- Pull a task of the queue - Convert it from an interface to a task.Task type // ??? 🤔 - Retrieve the task from the workers's Db - Check if the state transition is valid - If the task from the queue is in a state "Scheduled", call StartTask - If the task from the queue is in a state "Completed", call StopTask - Else, there is an invalid transition, so retuen an error

func (*Worker) StartTask

func (worker *Worker) StartTask(t *task.Task) task.WasmRunnerResult

- Update the StartTime field on the task t. - Call the Run() method on the Worker struct. - Check if there were any errors in starting the task. - Save the updated task t to the worker’s Db field. - Return the result of the operation.

func (*Worker) StopTask

func (worker *Worker) StopTask(t *task.Task) task.WasmRunnerResult

- Call the Stop() method on the Worker struct. - Check if there were any errors in stopping the task. - Update the FinishTime field on the task t. - Save the updated task t to the worker’s Db field. - Print an informative message and return the result of the operation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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