client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBufferFull is thrown when the channel buffer is full.
	ErrBufferFull = errors.New("buffer is full")

	// ErrCannotPauseDuringActiveTransfer is thrown when the user attempts to pause a runner
	// during an active transfer.
	ErrCannotPauseDuringActiveTransfer = errors.New("cannot pause during an active transfer")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	Transfer() transfer.Transfer
	Info() Info
	Claims() jwt.Claims
	Heartbeat() Heartbeat
	Paused() bool
	ToggleState() (state State, err error)

	// Consume & Produce
	Produce(operation *grpc_runner_v1.OperationResponse) (err error)
	Consume() <-chan *grpc_runner_v1.OperationResponse
}

func New

func New(claims *claims.RunnerClaims) Client

type Heartbeat

type Heartbeat interface {
	Verify(timestamp time.Time) (ok bool)
	Set(timestamp time.Time)
	Get() (timestamp time.Time, ok bool)
	Latency() float64
}

Heartbeat defines the heart beating of a client. When a heartbeat is verified, the latency get's calculated (the time it took to receive and calculate the beat).

type Info

type Info struct {
	State    State             `json:"state"`
	Transfer *domain.AnimeBase `json:"transfer,omitempty"`
	Name     string            `json:"name"`
	User     string            `json:"user"`
	Hostname string            `json:"hostname"`
	Ident    string            `json:"ident"`
	Docker   bool              `json:"docker"`
	Latency  float64           `json:"ms"`
}

func (Info) String

func (i Info) String() string

type State

type State int32
const (
	State_Unknown State = 0
	State_Wait    State = 1
	State_Pause   State = 2
	State_Run     State = 3
)

func GetState

func GetState(state string) State

func (State) MarshalJSON

func (s State) MarshalJSON() ([]byte, error)

func (State) String

func (s State) String() string

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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