requestmanager

package
v0.0.0-...-3a5d5d8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrQueueFull is the error happens when the waiting queue is already full
	ErrQueueFull = errors.New("waiting request queue already full")

	// ErrClosed is request error that the module is closed during request
	ErrClosed = errors.New("request manager module closed")
)

Functions

This section is empty.

Types

type Deliverer

type Deliverer interface {
	DeliverResponse(stID sttypes.StreamID, resp sttypes.Response)
}

Deliverer is the interface to deliver a response

type RequestManager

type RequestManager interface {
	p2ptypes.LifeCycle
	Requester
	Deliverer
}

RequestManager manages over the requests

func NewRequestManager

func NewRequestManager(sm streammanager.ReaderSubscriber) RequestManager

NewRequestManager creates a new request manager

type RequestOption

type RequestOption func(*request)

RequestOption is the additional instruction for requests. Currently, two options are supported: 1. WithHighPriority 2. WithBlacklist 3. WithWhitelist

func WithBlacklist

func WithBlacklist(blacklist []sttypes.StreamID) RequestOption

WithBlacklist is the request option not to assign the request to the blacklisted stream ID.

func WithHighPriority

func WithHighPriority() RequestOption

WithHighPriority is the request option to do request with higher priority. High priority requests are done first.

func WithWhitelist

func WithWhitelist(whitelist []sttypes.StreamID) RequestOption

WithWhitelist is the request option to restrict the request to be assigned to the given stream IDs. If a request is not with this option, all streams will be allowed.

type Requester

type Requester interface {
	DoRequest(ctx context.Context, request sttypes.Request, options ...RequestOption) (sttypes.Response, sttypes.StreamID, error)
}

Requester is the interface to do request

Jump to

Keyboard shortcuts

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