dipscl

package
v0.0.0-...-03bec22 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client - Dips client instance

func NewClient

func NewClient(host string) (*Client, error)

NewClient - Creates a new Dips client

func (*Client) NewEvent

func (c *Client) NewEvent() *Event

func (*Client) NewEventHandler

func (c *Client) NewEventHandler() *EventHandler

func (*Client) NewJob

func (c *Client) NewJob() *Job

func (*Client) NewJobWorker

func (c *Client) NewJobWorker() *JobWorker

func (*Client) NewTask

func (client *Client) NewTask(service string) *Task

NewTask - Creates a new task to be dispatched to a worker

func (*Client) NewTaskWorker

func (client *Client) NewTaskWorker(service string) *TaskWorker

NewWorker - Creates a new worker service with the given name

type DispatchedTask

type DispatchedTask struct {
	// contains filtered or unexported fields
}

A task that has been dispatched to a worker that awaits a response

func (*DispatchedTask) Await

func (t *DispatchedTask) Await() (*TaskResult, error)

func (*DispatchedTask) Close

func (t *DispatchedTask) Close()

type Event

type Event struct {
	// contains filtered or unexported fields
}

The event to be dispatched

func (*Event) Dispatch

func (e *Event) Dispatch()

Dispatches the event (and never blocks)

func (*Event) Message

func (e *Event) Message(message *MessageEvent) *Event

func (*Event) Status

func (e *Event) Status(status *StatusEvent) *Event

func (*Event) Variable

func (e *Event) Variable(variable *VariableEvent) *Event

type EventHandler

type EventHandler struct {
	// contains filtered or unexported fields
}

func (*EventHandler) HandleMessage

func (h *EventHandler) HandleMessage(message func(*MessageEvent) error) *EventHandler

func (*EventHandler) HandleStatus

func (h *EventHandler) HandleStatus(status func(*StatusEvent) error) *EventHandler

func (*EventHandler) HandleVariable

func (h *EventHandler) HandleVariable(variable func(*VariableEvent) error) *EventHandler

func (*EventHandler) Run

func (h *EventHandler) Run()

Run - Starts a new goroutine for this event handler

type Job

type Job struct {
	// contains filtered or unexported fields
}

func (*Job) Dispatch

func (j *Job) Dispatch()

Dispatches the job (and never blocks)

func (*Job) Job

func (j *Job) Job(job *model.Job) *Job

Job - Sets the job

func (*Job) Name

func (j *Job) Name(name string) *Job

func (*Job) Pipeline

func (j *Job) Pipeline(script string) *Job

func (*Job) Variables

func (j *Job) Variables(variables map[string]interface{}) *Job

Parameters - Sets the input parameters of the job

type JobContext

type JobContext struct {
	Client  *Client
	Worker  *JobWorker
	Request *JobRequest
}

type JobRequest

type JobRequest struct {
	Job *model.Job `json:"job"`
}

type JobWorker

type JobWorker struct {
	// contains filtered or unexported fields
}

func (*JobWorker) Concurrency

func (w *JobWorker) Concurrency(threads int) *JobWorker

func (*JobWorker) Handler

func (w *JobWorker) Handler(handler func(*JobContext) error) *JobWorker

func (*JobWorker) Run

func (w *JobWorker) Run()

Run - Starts a new goroutine for this worker

type MessageEvent

type MessageEvent struct {
	JobId   string
	TaskId  string
	Type    MessageEventType
	Message string
}

type MessageEventType

type MessageEventType uint

the type of the message

const (
	LogDebugMessage MessageEventType = 0
	LogInfoMessage  MessageEventType = 1
	LogWarnMessage  MessageEventType = 2
	LogErrorMessage MessageEventType = 3
	LogCritMessage  MessageEventType = 4

	StdOutMessage MessageEventType = 10
	StdErrMessage MessageEventType = 11
)

type StatusEvent

type StatusEvent struct {
	JobId    string
	TaskId   string
	Type     StatusEventType
	Progress uint
}

type StatusEventType

type StatusEventType uint

the type of the job status update

const (
	// progress update
	ProgressEvent StatusEventType = 1
)

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task - A task instance to be dispatched to a worker

func (*Task) Dispatch

func (t *Task) Dispatch() *DispatchedTask

Dispatches the task (and never blocks)

func (*Task) Job

func (t *Task) Job(job *model.Job) *Task

Job - Sets the job the task belongs to

func (*Task) Name

func (t *Task) Name(name string) *Task

Name - Sets the name of the task

func (*Task) Parameters

func (t *Task) Parameters(params map[string]string) *Task

Parameters - Sets the input parameters of the task

func (*Task) Timeout

func (t *Task) Timeout(timeout time.Duration) *Task

Sets the timeout of the task

type TaskContext

type TaskContext struct {
	Client  *Client
	Request *TaskRequest

	// TODO: configurable environment / filesystem?
	Filesystem  taskfs.FileSystem
	Environment taskenv.Environment
}

TaskContext - The TaskContext that is being sent to the task handler

type TaskRequest

type TaskRequest struct {
	TaskID  string            `json:"id" bson:"id"`
	Timeout time.Duration     `json:"timeout" bson:"timeout"`
	Job     *model.Job        `json:"job" bson:"job"`
	Name    string            `json:"name" bson:"name"`
	Params  map[string]string `json:"params" bson:"params"`
}

TaskRequest - Request to start a task

type TaskResult

type TaskResult struct {
	Error  *string                `json:"error" bson:"error"`
	Output map[string]interface{} `json:"output" bson:"output"`
}

type TaskWorker

type TaskWorker struct {
	// contains filtered or unexported fields
}

TaskWorker - A worker service instance

func (*TaskWorker) Concurrency

func (w *TaskWorker) Concurrency(threads int) *TaskWorker

func (*TaskWorker) Filesystem

func (w *TaskWorker) Filesystem(filesystem string) *TaskWorker

func (*TaskWorker) Handler

func (w *TaskWorker) Handler(handler func(*TaskContext) (map[string]interface{}, error)) *TaskWorker

Handler - Sets the handler for this worker

func (*TaskWorker) Run

func (worker *TaskWorker) Run()

Run - Starts a new goroutine for this worker

type VariableEvent

type VariableEvent struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

Jump to

Keyboard shortcuts

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