Class: Client

grpc. Client


new Client(address, credentials, options)

A generic gRPC client. Primarily useful as a base class for generated clients

Parameters:
Name Type Description
address string

Server address to connect to

credentials grpc.credentials~ChannelCredentials

Credentials to use to connect to the server

options Object

Options to apply to channel creation

Methods


close()

Close this client.


getChannel()

Return the underlying channel object for the specified client

Returns:

The channel

Type
Channel

makeBidiStreamRequest(path, serialize, deserialize [, metadata] [, options])

Make a bidirectional stream request with this method on the given channel.

Parameters:
Name Type Argument Description
path string

The path of the method to request

serialize grpc~serialize

The serialization function for inputs

deserialize grpc~deserialize

The deserialization function for outputs

metadata grpc.Metadata <optional>

Array of metadata key/value pairs to add to the call

options grpc.Client~CallOptions <optional>

Options map

Returns:

An event emitter for stream related events

Type
grpc~ClientDuplexStream

makeClientStreamRequest(path, serialize, deserialize [, metadata] [, options], callback)

Make a client stream request to the given method, using the given serialize and deserialize functions, with the given argument.

Parameters:
Name Type Argument Description
path string

The path of the method to request

serialize grpc~serialize

The serialization function for inputs

deserialize grpc~deserialize

The deserialization function for outputs

metadata grpc.Metadata <optional>

Array of metadata key/value pairs to add to the call

options grpc.Client~CallOptions <optional>

Options map

callback grpc.Client~requestCallback

The callback for when the response is received

Returns:

An event emitter for stream related events

Type
grpc~ClientWritableStream

makeServerStreamRequest(path, serialize, deserialize, argument [, metadata] [, options])

Make a server stream request to the given method, with the given serialize and deserialize function, using the given argument

Parameters:
Name Type Argument Description
path string

The path of the method to request

serialize grpc~serialize

The serialization function for inputs

deserialize grpc~deserialize

The deserialization function for outputs

argument *

The argument to the call. Should be serializable with serialize

metadata grpc.Metadata <optional>

Array of metadata key/value pairs to add to the call

options grpc.Client~CallOptions <optional>

Options map

Returns:

An event emitter for stream related events

Type
grpc~ClientReadableStream

makeUnaryRequest(path, serialize, deserialize, argument [, metadata] [, options], callback)

Make a unary request to the given method, using the given serialize and deserialize functions, with the given argument.

Parameters:
Name Type Argument Description
path string

The path of the method to request

serialize grpc~serialize

The serialization function for inputs

deserialize grpc~deserialize

The deserialization function for outputs

argument *

The argument to the call. Should be serializable with serialize

metadata grpc.Metadata <optional>

Metadata to add to the call

options grpc.Client~CallOptions <optional>

Options map

callback grpc.Client~requestCallback

The callback for when the response is received

Returns:

An event emitter for stream related events

Type
grpc~ClientUnaryCall

waitForReady(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
deadline grpc~Deadline

When to stop waiting for a connection.

callback function

The callback to call when done attempting to connect.

Type Definitions


Call

Any client call type

Type:

CallOptions

Options that can be set on a call.

Type:
  • Object
Properties:
Name Type Description
deadline grpc~Deadline

The deadline for the entire call to complete.

host string

Server hostname to set on the call. Only meaningful if different from the server address used to construct the client.

parent grpc.Client~Call

Parent call. Used in servers when making a call as part of the process of handling a call. Used to propagate some information automatically, as specified by propagate_flags.

propagate_flags number

Indicates which properties of a parent call should propagate to this call. Bitwise combination of flags in grpc.propagate.

credentials grpc.credentials~CallCredentials

The credentials that should be used to make this particular call.


requestCallback(error, value)

Parameters:
Name Type Argument Description
error grpc~ServiceError <nullable>

The error, if the call failed

value *

The response value, if the call succeeded