Client module
This module contains the factory method for creating Client classes, and the
method calling code for all types of methods.
For example, to create a client and call a method on it:
var proto_obj = grpc.load(proto_file_path);
var Client = proto_obj.package.subpackage.ServiceName;
var client = new Client(server_address, client_credentials);
var call = client.unaryMethod(arguments, callback);
- Source:
Classes
Members
(static) callError
See docs for client.callError
- Source:
(static) status
Map of status code names to status codes
- Source:
(inner) deprecated_request_wrap
Map with wrappers for each type of requester function to make it use the old
argument order with optional arguments after the callback.
- Source:
(inner) requester_makers
Map with short names for each of the requester maker functions. Used in
makeClientConstructor
- Source:
Methods
(static) getClientChannel(client) → {Channel}
Return the underlying channel object for the specified client
Parameters:
Name | Type | Description |
---|---|---|
client |
Client |
- Source:
Returns:
The channel
- Type
- Channel
(static) makeClientConstructor(methods, serviceName, class_options) → {function}
Creates a constructor for a client with the given methods. The methods object
maps method name to an object with the following keys:
path: The path on the server for accessing the method. For example, for
protocol buffers, we use "/service_name/method_name"
requestStream: bool indicating whether the client sends a stream
resonseStream: bool indicating whether the server sends a stream
requestSerialize: function to serialize request objects
responseDeserialize: function to deserialize response objects
Parameters:
Name | Type | Description |
---|---|---|
methods |
Object | An object mapping method names to method attributes |
serviceName |
string | The fully qualified name of the service |
class_options |
Object | An options object. Currently only uses the key deprecatedArgumentOrder, a boolean that Indicates that the old argument order should be used for methods, with optional arguments at the end instead of the callback at the end. Defaults to false. This option is only a temporary stopgap measure to smooth an API breakage. It is deprecated, and new code should not use it. |
- Source:
Returns:
New client constructor
- Type
- function
(static) makeProtobufClientConstructor(service, optionsopt) → {function}
Creates a constructor for clients for the given service
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
service |
ProtoBuf.Reflect.Service | The service to generate a client for | |
options |
Object |
<optional> |
Options to apply to the client |
- Source:
Returns:
New client constructor
- Type
- function
(static) waitForClientReady(client, deadline, callback)
Wait for the client to be ready. The callback will be called when the
client has successfully connected to the server, and it will be called
with an error if the attempt to connect to the server has unrecoverablly
failed or if the deadline expires. This function will make the channel
start connecting if it has not already done so.
Parameters:
Name | Type | Description |
---|---|---|
client |
Client | The client to wait on |
deadline |
Date | Number | When to stop waiting for a connection. Pass Infinity to wait forever. |
callback |
function | The callback to call when done attempting to connect. |
- Source:
(inner) _emitStatusIfDone()
If we have both processed all incoming messages and received the status from
the server, emit the status. Otherwise, do nothing.
- Source:
(inner) _readsDone(statusnon-null)
Called when all messages from the server have been processed. The status
parameter indicates that the call should end with that status. status
defaults to OK if not provided.
Parameters:
Name | Type | Description |
---|---|---|
status |
Object | The status that the call should end with |
- Source:
(inner) _receiveStatus()
Called to indicate that we have received a status from the server.
- Source:
(inner) cancel()
Cancel the ongoing call
- Source:
(inner) getCall(options)
Get a call object built with the provided options. Keys for options are
'deadline', which takes a date or number, and 'host', which takes a string
and overrides the hostname to connect to.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | Options map. |
- Source:
(inner) getPeer() → {string}
Get the endpoint this call/stream is connected to.
- Source:
Returns:
The URI of the endpoint
- Type
- string
(inner) makeBidiStreamRequestFunction(method, serialize, deserialize) → {function}
Get a function that can make bidirectional stream requests to the specified
method.
Parameters:
Name | Type | Description |
---|---|---|
method |
string | The name of the method to request |
serialize |
function | The serialization function for inputs |
deserialize |
function | The deserialization function for outputs |
- Source:
Returns:
makeBidiStreamRequest
- Type
- function
(inner) makeClientStreamRequestFunction(method, serialize, deserialize) → {function}
Get a function that can make client stream requests to the specified method.
Parameters:
Name | Type | Description |
---|---|---|
method |
string | The name of the method to request |
serialize |
function | The serialization function for inputs |
deserialize |
function | The deserialization function for outputs |
- Source:
Returns:
makeClientStreamRequest
- Type
- function
(inner) makeServerStreamRequestFunction(method, serialize, deserialize) → {function}
Get a function that can make server stream requests to the specified method.
Parameters:
Name | Type | Description |
---|---|---|
method |
string | The name of the method to request |
serialize |
function | The serialization function for inputs |
deserialize |
function | The deserialization function for outputs |
- Source:
Returns:
makeServerStreamRequest
- Type
- function
(inner) makeUnaryRequestFunction(method, serialize, deserialize) → {function}
Get a function that can make unary requests to the specified method.
Parameters:
Name | Type | Description |
---|---|---|
method |
string | The name of the method to request |
serialize |
function | The serialization function for inputs |
deserialize |
function | The deserialization function for outputs |
- Source:
Returns:
makeUnaryRequest
- Type
- function