Package com.ocient.transport

# Interface SimplexTransport<TREQUEST,TRESPONSE>

All Superinterfaces:
  `com.ibm.asyncutil.util.AsyncCloseable`

All Known Implementing Classes:
  `JavaNetOcientWireV1Transport`, `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 | | |<------------------------| | +--------+ +----+---+

+--------+ +--------+ | | Request 2 | | | Client |------------------------>| Server | | |<------------------------| | +--------+ +----+---+ ...

## Nested Class Summary

Nested Classes
Modifier and Type
Interface
Description
`static interface`
`SimplexTransport.Ctx`
Opaque, consumer-defined context of a stream request.
`static class`
`SimplexTransport.StreamCtx<T>`
Contextual wrapper for items passed along the stream.

## Method Summary

Modifier and Type
Method
Description
`io.netty.buffer.ByteBuf`
`allocate(int capacity)`
Allocates an I/O capable `ByteBuf` with the specified capacity.
`CompletionStage<Void>`
`close()`
`Optional<SocketAddress>`
`getLocalAddress()`
`Optional<SocketAddress>`
`getRemoteAddress()`
`boolean`
`isValid()`
`CompletionStage<TransportResult<TRESPONSE>>`
`sendAndReceive(TREQUEST request, SimplexTransport.Ctx ctx)`
Sends a `SimplexTransport` to the server and returns a `CompletionStage` that completes with the `SimplexTransport` from the server.
`CompletionStage<TransportResult<Void>>`
`sendNoReceive(TREQUEST request, SimplexTransport.Ctx ctx)`
Sends `SimplexTransport` to 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 capable `ByteBuf` with the specified capacity.

Parameters:
  `capacity` - the desired capacity of the new buffer.
Returns:
  a new I/O capable `ByteBuf` with the specified capacity.

### sendAndReceive

CompletionStage<TransportResult<TRESPONSE>> sendAndReceive(TREQUEST request, SimplexTransport.Ctx ctx)
Sends a `SimplexTransport` to the server and returns a `CompletionStage` that completes with the `SimplexTransport` from the server.

Parameters:
  `request` - the `SimplexTransport`
Returns:
  a `CompletionStage` that completes with a `SimplexTransport` from 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 the `Asynciterator` interface.

Implementations may enqueue up to `maxQueueDepth` requests 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 of `SimplexTransport`s. 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

CompletionStage<TransportResult<Void>> sendNoReceive(TREQUEST request, SimplexTransport.Ctx ctx)
Sends `SimplexTransport` to the server. notably, a response is NOT expected from the server.

Parameters:
  `request` - the `SimplexTransport`

### close

CompletionStage<Void> close()

Specified by:
  `close` in interface `com.ibm.asyncutil.util.AsyncCloseable`

### isValid

boolean isValid()

### getLocalAddress

Optional<SocketAddress> getLocalAddress()

### getRemoteAddress

Optional<SocketAddress> getRemoteAddress()