Package com.ocient.transport
Interface SimplexTransport<TREQUEST,TRESPONSE>
- All Superinterfaces:
com.ibm.asyncutil.util.AsyncCloseable
- All Known Implementing Classes:
JavaNetOcientWireV1Transport,MockOcientCluster.Transport,NettyOcientWireV1Transport
public interface SimplexTransport<TREQUEST,TRESPONSE>
extends com.ibm.asyncutil.util.AsyncCloseable
Represents a simplex, uni-directional transport mechanism.
An invariant: requests are ONLY sent from the client. Unsolicited requests from the server are not permitted.
+--------+ +--------+ | | Request 1 | | | Client |------------------------>| Server | | |invalid input: '<'------------------------| | +--------+ +----+---+
+--------+ +--------+ | | Request 2 | | | Client |------------------------>| Server | | |invalid input: '<'------------------------| | +--------+ +----+---+ ...
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceOpaque, consumer-defined context of a stream request.static classContextual wrapper for items passed along the stream. -
Method Summary
Modifier and TypeMethodDescriptionio.netty.buffer.ByteBufallocate(int capacity) Allocates an I/O capableByteBufwith the specified capacity.close()booleanisValid()sendAndReceive(TREQUEST request, SimplexTransport.Ctx ctx) Sends aSimplexTransportto the server and returns aCompletionStagethat completes with theSimplexTransportfrom the server.sendNoReceive(TREQUEST request, SimplexTransport.Ctx ctx) SendsSimplexTransportto the server.default com.ibm.asyncutil.iteration.AsyncIterator<SimplexTransport.StreamCtx<TransportResult<TRESPONSE>>> stream(com.ibm.asyncutil.iteration.AsyncIterator<SimplexTransport.StreamCtx<TransportResult<TREQUEST>>> requests, int maxQueueDepth) Accepts a stream of requests and returns the result response stream.
-
Method Details
-
allocate
io.netty.buffer.ByteBuf allocate(int capacity) Allocates an I/O capableByteBufwith the specified capacity.- Parameters:
capacity- the desired capacity of the new buffer.- Returns:
- a new I/O capable
ByteBufwith the specified capacity.
-
sendAndReceive
CompletionStage<TransportResult<TRESPONSE>> sendAndReceive(TREQUEST request, SimplexTransport.Ctx ctx) Sends aSimplexTransportto the server and returns aCompletionStagethat completes with theSimplexTransportfrom the server.- Parameters:
request- theSimplexTransport- Returns:
- a
CompletionStagethat completes with aSimplexTransportfrom the server.
-
stream
default com.ibm.asyncutil.iteration.AsyncIterator<SimplexTransport.StreamCtx<TransportResult<TRESPONSE>>> stream(com.ibm.asyncutil.iteration.AsyncIterator<SimplexTransport.StreamCtx<TransportResult<TREQUEST>>> requests, int maxQueueDepth) Accepts a stream of requests and returns the result response stream. Backpressure may be applied by the request producer via theinterface.invalid reference
AsynciteratorImplementations may enqueue up to
maxQueueDepthrequests in the recepient's recv queue at any given time.Implementations must ensure that requests are sent in the sequence they are generated.
- Parameters:
requests- the stream ofSimplexTransports. Callers may apply backpressure by throttling the stream of requests.maxQueueDepth- the maximum queue depth of the recipient's recv queue.- Returns:
- the stream of responses; one per request.
-
sendNoReceive
SendsSimplexTransportto the server. notably, a response is NOT expected from the server.- Parameters:
request- theSimplexTransport
-
close
CompletionStage<Void> close()- Specified by:
closein interfacecom.ibm.asyncutil.util.AsyncCloseable
-
isValid
boolean isValid() -
getLocalAddress
Optional<SocketAddress> getLocalAddress() -
getRemoteAddress
Optional<SocketAddress> getRemoteAddress()
-