msg

package
v0.0.0-...-8cfe5f7 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2020 License: GPL-3.0 Imports: 3 Imported by: 18

Documentation

Overview

Package msg provides means for client and server to communicate.

Index

Constants

View Source
const (
	// Status
	RespError   = "error"
	RespSuccess = "success"
	// Type
	RespStartTask   = "start"
	RespStopTask    = "stop"
	RespCurrentTask = "current"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	Op          string            `json:"operation"`    // The operation to perform
	Flags       map[string]bool   `json:"flags"`        // Possible flags
	Opts        map[string]string `json:"options"`      // Possible options
	TaskNames   []string          `json:"tasks"`        // The tasks for any related requests
	Body        [][]string        `json:"body"`         // The body containing the command information
	Quantities  []Quantity        `json:"quantifiers"`  // Quantifiers, e.g. for queries
	QueryParams []QueryParam      `json:"query_params"` // The parameters for a query
}

type Quantity

type Quantity struct {
	Type  string
	Elems []string
}

TODO: Doc comments. This one is important.

type QueryParam

type QueryParam []string

type Response

type Response struct {
	Status string     `json:"status"`
	Error  string     `json:"error"`
	Body   [][]string `json:"body"`
}

Response represents a server's answer to a client's request.

func (*Response) AddAbortedTask

func (r *Response) AddAbortedTask(task Task)

func (*Response) AddCurrentTask

func (r *Response) AddCurrentTask(task Task)

func (*Response) AddPong

func (r *Response) AddPong()

func (*Response) AddQuerySummaries

func (r *Response) AddQuerySummaries(sum []Summary)

Create a response containing the given query summaries.

func (*Response) AddShutdownMessage

func (r *Response) AddShutdownMessage()

func (*Response) AddStartedTask

func (r *Response) AddStartedTask(task Task)

func (*Response) AddStoppedTask

func (r *Response) AddStoppedTask(task Task)

func (*Response) Err

func (r *Response) Err() error

The error encapsulated in the response, if any.

func (*Response) Failed

func (r *Response) Failed() bool

func (*Response) SetError

func (r *Response) SetError(err error)

func (*Response) SetListening

func (r *Response) SetListening()

type Summary

type Summary struct {
	Task    string
	Details Quantity
	Total   time.Duration
	Start   time.Time
	End     time.Time
}

Summary represents all relevant information concerning a single request

type Task

type Task struct {
	Name     string
	Started  time.Time
	Ended    time.Time
	HasEnded bool
}

Type representing a named task with start and end times.

func FreshTask

func FreshTask(name string) Task

func IdleTask

func IdleTask() Task

func NewTask

func NewTask(name string) *Task

Initiate a new task, started just now.

func (*Task) IsRunning

func (t *Task) IsRunning() bool

func (*Task) Stop

func (t *Task) Stop()

Stop the task.

Jump to

Keyboard shortcuts

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