Skip to content

Commit

Permalink
docs: update docs for new platform interfaces (#808)
Browse files Browse the repository at this point in the history
Updating docs to reflect changes from #802.

Signed-off-by: Michael Rebello <me@michaelrebello.com>
  • Loading branch information
rebello95 authored Apr 22, 2020
1 parent 93f7123 commit 21195fb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/root/api/grpc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ stream.

val request = GRPCRequestBuilder(...).build()
val responseHandler = GRPCResponseHandler(...)
val grpcEmitter = grpcClient.send(request, responseHandler)
val grpcEmitter = grpcClient.start(request, responseHandler)
.sendMessage(...)
.sendMessage(...)

Expand All @@ -139,7 +139,7 @@ stream.

let request = GRPCRequestBuilder(...).build()
let responseHandler = GRPCResponseHandler(...)
let grpcEmitter = grpcClient.send(request, handler: responseHandler)
let grpcEmitter = grpcClient.start(request, handler: responseHandler)
.sendMessage(...)
.sendMessage(...)

Expand Down
47 changes: 40 additions & 7 deletions docs/root/api/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Doing so returns a ``StreamEmitter`` which allows the sender to interact with th

val request = RequestBuilder(...).build()
val responseHandler = ResponseHandler(...)
val emitter = envoy.send(request, responseHandler)
val emitter = envoy.start(request, responseHandler)
.sendData(...)
.sendData(...)

Expand All @@ -120,7 +120,7 @@ Doing so returns a ``StreamEmitter`` which allows the sender to interact with th

let request = RequestBuilder(...).build()
let responseHandler = ResponseHandler(...)
let emitter = envoy.send(request, handler: responseHandler)
let emitter = envoy.start(request, handler: responseHandler)
.sendData(...)
.sendData(...)

Expand All @@ -137,23 +137,56 @@ Sending a unary request may be done by either closing the ``StreamEmitter`` afte
set of headers/data has been written, or by using the helper function that returns a
``CancelableStream`` type instead of a ``StreamEmitter``.

The unary helper function takes optional body data, then closes the stream.
The ``CancelableStream`` it returns does not expose options for sending additional data.
The unary helper function allows for easily performing the following request types:

- **Headers-only:** Send request headers then close the stream.

- Done by passing ``nil`` body and ``nil`` trailers.

- **Close with data:** Send request headers and data, then close.

- Done by passing ``nil`` trailers.

- **Close with trailers:** Send request headers and data, then close with trailers.

- Done by passing a body and trailers.

The ``CancelableStream`` returned by the unary function does not expose options for sending additional data.

**Kotlin**::

val envoy = AndroidEnvoyClientBuilder(...).build()

val request = RequestBuilder(...).build()
val responseHandler = ResponseHandler(...)

// Headers-only
val cancelable = envoy.send(request, null, null, responseHandler)

// Close using data
val cancelable = envoy.send(request, body, null, responseHandler)

// Close using trailers
val cancelable = envoy.send(request, body, trailers, responseHandler)
// cancelable.cancel()

// To cancel the request:
cancelable.cancel()

**Swift**::

let envoy = try EnvoyClientBuilder(...).build()

let request = RequestBuilder(...).build()
let responseHandler = ResponseHandler(...)
let cancelable = envoy.send(request, body, trailers: [:], handler: responseHandler)
// cancelable.cancel()

// Headers-only
let cancelable = envoy.send(request, nil, trailers: nil, handler: responseHandler)

// Close using data
let cancelable = envoy.send(request, body, trailers: nil, handler: responseHandler)

// Close using trailers
let cancelable = envoy.send(request, body, trailers: trailers, handler: responseHandler)

// To cancel the request:
cancelable.cancel()

0 comments on commit 21195fb

Please sign in to comment.