Documentation ¶
Overview ¶
nolint
Index ¶
- Variables
- type DecayingTagSpec
- type Handler
- type Host
- type Opt
- func WithDecayingTag(tag DecayingTagSpec) Opt
- func WithHardTimeout(timeout time.Duration) Opt
- func WithLog(log log.Log) Opt
- func WithMetrics() Opt
- func WithQueueSize(size int) Opt
- func WithRequestSizeLimit(limit int) Opt
- func WithRequestsPerInterval(n int, interval time.Duration) Opt
- func WithTimeout(timeout time.Duration) Opt
- type Response
- type Server
Constants ¶
This section is empty.
Variables ¶
var ErrNotConnected = errors.New("peer is not connected")
ErrNotConnected is returned when peer is not connected.
Functions ¶
This section is empty.
Types ¶
type DecayingTagSpec ¶ added in v1.3.10
type Host ¶ added in v1.0.0
type Host interface { SetStreamHandler(protocol.ID, network.StreamHandler) NewStream(context.Context, peer.ID, ...protocol.ID) (network.Stream, error) Network() network.Network ConnManager() connmgr.ConnManager }
Host is a subset of libp2p Host interface that needs to be implemented to be usable with server.
type Opt ¶ added in v1.0.0
type Opt func(s *Server)
Opt is a type to configure a server.
func WithDecayingTag ¶ added in v1.3.10
func WithDecayingTag(tag DecayingTagSpec) Opt
func WithHardTimeout ¶ added in v1.3.6
WithHardTimeout configures the hard timeout for requests. Requests are terminated if they take longer than the specified duration.
func WithMetrics ¶ added in v1.3.0
func WithMetrics() Opt
WithMetrics will enable metrics collection in the server.
func WithQueueSize ¶ added in v1.3.0
WithQueueSize parametrize number of message that will be kept in queue and eventually processed by server. Otherwise stream is closed immediately.
Size of the queue should be set to account for maximum expected latency, such as if expected latency is 10s and server processes 1000 requests per second size should be 100.
Defaults to 100.
func WithRequestSizeLimit ¶ added in v1.0.0
func WithRequestsPerInterval ¶ added in v1.3.0
WithRequestsPerInterval parametrizes server rate limit to limit maximum amount of bandwidth that this handler can consume.
Defaults to 100 requests per second.
func WithTimeout ¶ added in v1.0.0
WithTimeout configures stream timeout. The requests are terminated when no data is received or sent for the specified duration.
type Response ¶ added in v1.0.0
type Response struct { Data []byte `scale:"max=89128960"` // 85 MiB Error string `scale:"max=1024"` // TODO(mafa): make error code instead of string }
Response is a server response.
func (*Response) DecodeScale ¶ added in v1.0.0
func (*Response) EncodeScale ¶ added in v1.0.0
type Server ¶ added in v1.0.0
type Server struct {
// contains filtered or unexported fields
}
Server for the Handler.