libp2p.request_response package
Submodules
libp2p.request_response.api module
- class libp2p.request_response.api.RequestContext(peer_id: 'ID', protocol_id: 'TProtocol')
Bases:
object- protocol_id: TProtocol
- class libp2p.request_response.api.RequestResponse(host: IHost)
Bases:
objectSafe, one-shot request/response helper on top of libp2p streams.
- async send_request(peer_id: ID, protocol_ids: Sequence[TProtocol], request: ReqT, codec: RequestResponseCodec[ReqT, RespT], config: RequestResponseConfig | None = None) RespT
- set_handler(protocol_id: TProtocol, handler: Callable[[ReqT, RequestContext], Awaitable[RespT]], codec: RequestResponseCodec[ReqT, RespT], config: RequestResponseConfig | None = None) None
libp2p.request_response.codec module
- class libp2p.request_response.codec.BytesCodec(*args, **kwargs)
Bases:
RequestResponseCodec[bytes,bytes]Pass-through codec for raw bytes payloads.
- class libp2p.request_response.codec.JSONCodec(*args, **kwargs)
Bases:
RequestResponseCodec[Any,Any]Codec for JSON-serializable Python values.
libp2p.request_response.exceptions module
- exception libp2p.request_response.exceptions.MessageTooLargeError
Bases:
RequestResponseErrorRaised when a framed request or response exceeds configured limits.
- exception libp2p.request_response.exceptions.ProtocolNotSupportedError
Bases:
RequestResponseErrorRaised when the remote peer supports none of the requested protocols.
- exception libp2p.request_response.exceptions.RequestDecodeError
Bases:
RequestResponseErrorRaised when request deserialization fails on the server side.
- exception libp2p.request_response.exceptions.RequestEncodeError
Bases:
RequestResponseErrorRaised when request serialization fails.
- exception libp2p.request_response.exceptions.RequestResponseError
Bases:
BaseLibp2pErrorBase error for the request/response helper.
- exception libp2p.request_response.exceptions.RequestTimeoutError
Bases:
RequestResponseErrorRaised when a request/response exchange exceeds the configured timeout.
- exception libp2p.request_response.exceptions.RequestTransportError
Bases:
RequestResponseErrorRaised when transport- or stream-level failures interrupt a request.
- exception libp2p.request_response.exceptions.ResponseDecodeError
Bases:
RequestResponseErrorRaised when response deserialization fails on the client side.
- exception libp2p.request_response.exceptions.ResponseEncodeError
Bases:
RequestResponseErrorRaised when response serialization fails on the server side.
Module contents
- class libp2p.request_response.BytesCodec(*args, **kwargs)
Bases:
RequestResponseCodec[bytes,bytes]Pass-through codec for raw bytes payloads.
- class libp2p.request_response.JSONCodec(*args, **kwargs)
Bases:
RequestResponseCodec[Any,Any]Codec for JSON-serializable Python values.
- exception libp2p.request_response.MessageTooLargeError
Bases:
RequestResponseErrorRaised when a framed request or response exceeds configured limits.
- exception libp2p.request_response.ProtocolNotSupportedError
Bases:
RequestResponseErrorRaised when the remote peer supports none of the requested protocols.
- class libp2p.request_response.RequestContext(peer_id: 'ID', protocol_id: 'TProtocol')
Bases:
object- protocol_id: TProtocol
- exception libp2p.request_response.RequestDecodeError
Bases:
RequestResponseErrorRaised when request deserialization fails on the server side.
- exception libp2p.request_response.RequestEncodeError
Bases:
RequestResponseErrorRaised when request serialization fails.
- class libp2p.request_response.RequestResponse(host: IHost)
Bases:
objectSafe, one-shot request/response helper on top of libp2p streams.
- async send_request(peer_id: ID, protocol_ids: Sequence[TProtocol], request: ReqT, codec: RequestResponseCodec[ReqT, RespT], config: RequestResponseConfig | None = None) RespT
- set_handler(protocol_id: TProtocol, handler: Callable[[ReqT, RequestContext], Awaitable[RespT]], codec: RequestResponseCodec[ReqT, RespT], config: RequestResponseConfig | None = None) None
- class libp2p.request_response.RequestResponseConfig(timeout: 'float' = 10.0, max_request_size: 'int' = 1048576, max_response_size: 'int' = 10485760, max_concurrent_inbound: 'int' = 128)
Bases:
object
- exception libp2p.request_response.RequestResponseError
Bases:
BaseLibp2pErrorBase error for the request/response helper.
- exception libp2p.request_response.RequestTimeoutError
Bases:
RequestResponseErrorRaised when a request/response exchange exceeds the configured timeout.
- exception libp2p.request_response.RequestTransportError
Bases:
RequestResponseErrorRaised when transport- or stream-level failures interrupt a request.
- exception libp2p.request_response.ResponseDecodeError
Bases:
RequestResponseErrorRaised when response deserialization fails on the client side.
- exception libp2p.request_response.ResponseEncodeError
Bases:
RequestResponseErrorRaised when response serialization fails on the server side.