proto

package
v0.0.0-...-b4f7333 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	COMMAND_LEN        = 8
	MESSAGE_TERMINATOR = []byte("\n\r")
)

Functions

func MakeMessageByte

func MakeMessageByte(command, data []byte) []byte

func MakeMessageString

func MakeMessageString(command []byte, data string) []byte

func MakeMessageStruct

func MakeMessageStruct(command []byte, data interface{}) []byte

Types

type Assign

type Assign struct {
	Jobs []Job `json:"jobs"`
}

func (*Assign) Decode

func (assign *Assign) Decode(m Message) error

func (*Assign) Encode

func (assign *Assign) Encode() (Message, error)

type Identify

type Identify struct {
	ID       string
	Capacity uint
}

func (*Identify) Decode

func (id *Identify) Decode(m Message) error

func (*Identify) Encode

func (id *Identify) Encode() (Message, error)

type Job

type Job struct {
	ID          string `json:"id"`
	URL         string `json:"url"`
	Req         int    `json:"req"`
	Concurrency int    `json:"concurrency"`
	Duration    int    `json:"duration"`
	Rate        int    `json:"rate"`
}

type Message

type Message struct {
	Type MessageType
	Data []byte
}

The Message type wraps all messages sent between workers and servers

func (*Message) Read

func (m *Message) Read(reader io.Reader) error

Read a Message from an io.Reader

func (*Message) Write

func (m *Message) Write(writer io.Writer) error

Write a Message to an io.Writer.

type MessageType

type MessageType uint8
const (
	MessageTypeHello MessageType = iota
	MessageTypeIdentify
	MessageTypeAssign
	MessageTypeAlive
	MessageTypeStatus
	MessageTypeAccept
)

type ProtocolObject

type ProtocolObject interface {
	Encode() (Message, error)
	Decode(Message) error
}

type Status

type Status struct {
	// JobQueue of accepted jobs
	JobQueue []Job
	// ActiveJobs are the jobs currently being worked
	ActiveJobs []Job
	// [JobID]: [StatusCode]count
	Results map[string]map[int]int
}

func (*Status) Decode

func (status *Status) Decode(m Message) error

func (*Status) Encode

func (status *Status) Encode() (Message, error)

Jump to

Keyboard shortcuts

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