connectivity

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStreamOffline       = errors.New("stream is Offline")
	ErrNoWorkersAvailable  = errors.New("no workers available")
	ErrWorkerDoesNotExists = errors.New("workers does not exists")
)

Functions

This section is empty.

Types

type ConnectivityInfo

type ConnectivityInfo struct {
	Address string `json:"address"`
	Version string `json:"version"`
	Type    string `json:"type"`
}

type Manager

type Manager struct {
	ID string
	// contains filtered or unexported fields
}

func NewManager

func NewManager(id string, logger *zap.Logger) *Manager

NewManager is Manager constructor

func (*Manager) AddTransport

func (m *Manager) AddTransport(c structs.ConnTransport) error

AddTransport for connectivity

func (*Manager) AttachToMux

func (m *Manager) AttachToMux(mux *http.ServeMux)

func (*Manager) GetAllWorkers

func (m *Manager) GetAllWorkers() map[string]structs.WorkerNetworkStatic

GetAllWorkers returns static list of workers

func (*Manager) GetWorkers

func (m *Manager) GetWorkers(kind string) []structs.WorkerInfo

GetWorkers gets workers of kind

func (*Manager) Register

func (m *Manager) Register(id, network, chain string, connInfo structs.WorkerConnection) error

Register new worker in Manager

func (*Manager) Send

func (m *Manager) Send(trs []structs.TaskRequest) (*structs.Await, error)

Send sends a set of requests

func (*Manager) Unregister

func (m *Manager) Unregister(id, kind, chain, version string) error

Unregister unregistring worker

type Network

type Network struct {
	// contains filtered or unexported fields
}

type PingInfo

type PingInfo struct {
	ID           string           `json:"id"`
	Network      string           `json:"network"`
	ChainID      string           `json:"chain_id"`
	Connectivity ConnectivityInfo `json:"connectivity"`
}

PingInfo contract is defined here

type RoundRobinWorkers

type RoundRobinWorkers struct {
	// contains filtered or unexported fields
}

func NewRoundRobinWorkers

func NewRoundRobinWorkers() *RoundRobinWorkers

func (*RoundRobinWorkers) AddWorker

func (rrw *RoundRobinWorkers) AddWorker(id string, stream *structs.StreamAccess) error

func (*RoundRobinWorkers) BringOnline

func (rrw *RoundRobinWorkers) BringOnline(id string) error

BringOnline Brings worker Online, removing duplicates

func (*RoundRobinWorkers) Close

func (rrw *RoundRobinWorkers) Close(id string) error

Close closes worker of given id

func (*RoundRobinWorkers) GetWorker

func (rrw *RoundRobinWorkers) GetWorker(id string) (twi structs.TaskWorkerInfo, ok bool)

func (*RoundRobinWorkers) GetWorkers

GetWorkers returns current workers information

func (*RoundRobinWorkers) Ping

func (rrw *RoundRobinWorkers) Ping(ctx context.Context, id string) (time.Duration, error)

func (*RoundRobinWorkers) Reconnect

func (rrw *RoundRobinWorkers) Reconnect(ctx context.Context, logger *zap.Logger, id string) error

Reconnect reconnects stream if exists

func (*RoundRobinWorkers) SendNext

func (rrw *RoundRobinWorkers) SendNext(tr structs.TaskRequest, aw *structs.Await) (failedWorkerID string, err error)

func (*RoundRobinWorkers) SendToWorker added in v0.4.0

func (rrw *RoundRobinWorkers) SendToWorker(id string, tr structs.TaskRequest, aw *structs.Await) error

SendToWoker sends task to worker

type WorkersPool

type WorkersPool interface {
	AddWorker(id string, stream *structs.StreamAccess) error
	SendNext(tr structs.TaskRequest, aw *structs.Await) (failedWorkerID string, err error)
	Ping(ctx context.Context, id string) (time.Duration, error)
	Close(id string) error
	BringOnline(id string) error
	Reconnect(ctx context.Context, logger *zap.Logger, id string) error
	GetWorker(id string) (twi structs.TaskWorkerInfo, ok bool)
	GetWorkers() structs.TaskWorkerRecordInfo
	SendToWorker(id string, tr structs.TaskRequest, aw *structs.Await) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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