Module: src/client

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

ClientDuplexStream
ClientReadableStream
ClientWritableStream

Members

(static) callError

See docs for client.callError
Source:

(static) status

Map of status code names to status codes
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) → {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
Source:
Returns:
New client constructor
Type
function

(static) makeProtobufClientConstructor(service) → {function}

Creates a constructor for clients for the given service
Parameters:
Name Type Description
service ProtoBuf.Reflect.Service The service to generate a client for
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) 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