Documentation
¶
Index ¶
Constants ¶
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 ¶
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 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 ¶
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.