Provider independent client API for invoking GRPC requests
Provider independent client API for invoking GRPC requests
(disconnect this)
Disconnects from the GRPC endpoint and releases all resources held by the underlying provider
Disconnects from the GRPC endpoint and releases all resources held by the underlying provider
(invoke this params)
Invokes a GRPC-based remote-procedure against the provider
A map with the following entries:
Value | Type | Description |
---|---|---|
service | String | The GRPC service-name of the endpoint |
method | String | The GRPC method-name of the endpoint |
metadata | map | Optional [string string] tuples that will be submitted as attributes to the request, such as via HTTP headers for GRPC-HTTP2 |
input | map | See Input section below |
output | map | See Output section below |
Any GRPC Service endpoint can define methods that take either unary or streaming inputs or outputs. This API assumes core.async channels in either case as a 'streaming first' design. For unary input, simply produce one message before closing the stream. Closing the stream indicates that the input is complete.
The input parameter is a map with the following fields:
Value | Type | Description |
---|---|---|
f | (fn [map]) | A protobuf new-XX function, such as produced by the protoc-gen-clojure compiler, to be applied to any outbound request messages |
ch | core.async/chan | A core.async channel used to send input parameters. Close to complete. |
The output parameter is a map with the following fields:
Value | Type | Description |
---|---|---|
f | (fn [is]) | A protobuf pb->msg function, such as produced by the protoc-gen-clojure compiler, to be applied to any incoming response messages |
ch | core.async/chan | A core.async channel that will be populated with any GRPC return messages. Unary responses arrive as a single message on the channel. Will close when the response is complete. |
A promise that, on success, evaluates to a map with the following entries:
Value | Type | Description |
---|---|---|
status | Int | The GRPC status code returned from the remote procedure |
message | String | The GRPC message (if any) returned from the remote procedure |
(let [{:keys [status message]} @(invoke client {:service "my.service"
:method "MyMethod"
:input {:f myservice/new-MyRequest :ch input}
:output {:f myservice/pb->MyResponse :ch output}})]
(println "status:" status))
Invokes a GRPC-based remote-procedure against the provider #### Parameters A map with the following entries: | Value | Type | Description | |-----------------|-------------------|---------------------------------------------------------------------------| | **service** | _String_ | The GRPC service-name of the endpoint | | **method** | _String_ | The GRPC method-name of the endpoint | | **metadata** | _map_ | Optional [string string] tuples that will be submitted as attributes to the request, such as via HTTP headers for GRPC-HTTP2 | | **input** | _map_ | See _Input_ section below | | **output** | _map_ | See _Output_ section below | ##### Unary vs Streaming Input Any [GRPC Service endpoint](https://grpc.io/docs/guides/concepts.html#service-definition) can define methods that take either unary or streaming inputs or outputs. This API assumes core.async channels in either case as a 'streaming first' design. For unary input, simply produce one message before closing the stream. Closing the stream indicates that the input is complete. ##### Input The _input_ parameter is a map with the following fields: | Value | Type | Description | |-----------------|-------------------|---------------------------------------------------------------------------| | **f** | _(fn [map])_ | A protobuf new-XX function, such as produced by the protoc-gen-clojure compiler, to be applied to any outbound request messages | | **ch** | _core.async/chan_ | A core.async channel used to send input parameters. Close to complete. | ##### Output The _output_ parameter is a map with the following fields: | Value | Type | Description | |-----------------|-------------------|---------------------------------------------------------------------------| | **f** | _(fn [is])_ | A protobuf pb->msg function, such as produced by the protoc-gen-clojure compiler, to be applied to any incoming response messages | | **ch** | _core.async/chan_ | A core.async channel that will be populated with any GRPC return messages. Unary responses arrive as a single message on the channel. Will close when the response is complete. | #### Return value A promise that, on success, evaluates to a map with the following entries: | Value | Type | Description | |-----------------|----------|---------------------------------------------------------------------------| | **status** | _Int_ | The [GRPC status code](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md) returned from the remote procedure | | **message** | _String_ | The GRPC message (if any) returned from the remote procedure | #### Example ``` (let [{:keys [status message]} @(invoke client {:service "my.service" :method "MyMethod" :input {:f myservice/new-MyRequest :ch input} :output {:f myservice/pb->MyResponse :ch output}})] (println "status:" status)) ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close