requestmanager

package
v1.10.3-0...-638a6e7 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StreamMonitorInterval monitors stream connections every 1000 milliseconds
	StreamMonitorInterval = 1000 * time.Millisecond

	// NoStreamTimeout defines no stream timeout duration
	NoStreamTimeout = 60 * time.Second

	// PendingRequestTimeout is the pending request timeout
	PendingRequestTimeout = 180 * time.Second
)

TODO: determine the values in production environment

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")

	// ErrNoAvailableStream indicates that a request cannot be processed
	// because there are no active streams available.
	ErrNoAvailableStream = errors.New("no available stream")
)

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 RequestErrorSeverity

type RequestErrorSeverity int

RequestErrorSeverity represents how a request error should affect the stream.

const (
	// RequestErrorSkip means the error is not the stream's fault
	// (system-level: stream busy, queue full, no available streams).
	RequestErrorSkip RequestErrorSeverity = iota

	// RequestErrorLow means the stream had a transient problem
	// (timeout, write failure, peer error response).
	RequestErrorLow

	// RequestErrorCritical means the stream has a fundamental problem
	// (protocol mismatch, malformed response).
	RequestErrorCritical
)

func ClassifyRequestError

func ClassifyRequestError(err error) RequestErrorSeverity

ClassifyRequestError classifies request-level errors by severity. Unlike ClassifyStreamError (transport-level), this handles errors from DoRequest and protocol response parsing.

type RequestManager

type RequestManager interface {
	p2ptypes.LifeCycle
	Requester
	Deliverer
}

RequestManager manages over the requests

func NewRequestManager

func NewRequestManager(sm streammanager.ReaderSubscriber, pid sttypes.ProtoID) 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