server

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PING_INTERVAL = 1 * time.Second
)

Functions

This section is empty.

Types

type Metrics

type Metrics interface {
	IncConnections()
}

func NewMetricsStore

func NewMetricsStore() Metrics

type Runtime

type Runtime interface {
	Listen() error
	HandleConnections()
	ControlLoop()
	Close()
	AddWorker(conn net.Conn) *WorkerConnection
	HandleJob(rw http.ResponseWriter, req *http.Request)
	HandleListJobQueue(rw http.ResponseWriter, req *http.Request)
	HandleListWorkers(rw http.ResponseWriter, req *http.Request)
}

func NewRuntime

func NewRuntime(m Metrics, logger zerolog.Logger, port int) Runtime

type WorkerConnection

type WorkerConnection struct {
	Conn     net.Conn
	ID       string
	Capacity uint
	// State
	// - new
	// - hello
	// - alive
	State    string
	LastSeen time.Time
	// Server assigned jobs that have not been accepted or sent
	JobQueue []proto.Job
	// Server assigned jobs that have not been accepted
	AssignJobQueue []proto.Job
	// Jobs accepted by the worker
	AcceptedJobs []proto.Job
	// contains filtered or unexported fields
}

func NewWorkerConnection

func NewWorkerConnection(logger zerolog.Logger, conn net.Conn) *WorkerConnection

NewWorkerConnection handles the connection and state for a worker connection

func (*WorkerConnection) AssignJob

func (wc *WorkerConnection) AssignJob(job proto.Job)

func (*WorkerConnection) Handle

func (wc *WorkerConnection) Handle()

Jump to

Keyboard shortcuts

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