manager

package
v0.0.0-...-f0b9b21 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrNoAvailableClients is thrown when there are no clients to accept the transfer.
	// This is generally thrown when there are either no clients connected or they're all in use.
	ErrNoAvailableClients = Error("no available clients, either they're all in use or none are connected")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailableDo

type AvailableDo func(client client.Client) (err error)

type Error

type Error string

Error is a custom error implementation for the `manager` package in-order to have them stored as constants.

func ErrClientAlreadyConnected

func ErrClientAlreadyConnected(ident string) Error

ErrClientAlreadyConnected is thrown when the client connection is present in the manager.

func ErrClientNotConnected

func ErrClientNotConnected(ident string) Error

ErrClientNotConnected is thrown when the client connection is not present in the manager.

func ErrTransferIsAlreadyActiveAndOwnedBy

func ErrTransferIsAlreadyActiveAndOwnedBy(anime domain.AnimeBase, info client.Info) Error

ErrTransferIsAlreadyActiveAndOwnedBy is thrown when we try to assign a transfer that's already owned by another client.

func (Error) Error

func (e Error) Error() string

type Manager

type Manager interface {
	Info() []client.Info
	Client(claims *claims.RunnerClaims) (client client.Client)
	Connect(claims *claims.RunnerClaims) (connected client.Client, err error)
	Disconnect(claims *claims.RunnerClaims) (err error)
	ToggleState(claims *claims.RunnerClaims) (state client.State, err error)
	Has(claims *claims.RunnerClaims) (ok bool)
	Len() int

	// Owns returns the client that owns the transfer for the requested,
	// owner can be nil if no owner is found.
	Owns(anime domain.AnimeBase) (owner client.Client)

	// AvailableDo will return a client that doesn't have a transfer assigned,
	// for the duration of the available func the manager will have the read lock.
	AvailableDo(anime domain.AnimeBase, fn AvailableDo) (assignee client.Client, err error)
}

func NewManager

func NewManager() Manager

Jump to

Keyboard shortcuts

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