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(method, serialize, deserialize [, metadata] [, options])
-
Make a bidirectional stream request with this method on the given channel.
Parameters:
Name Type Argument Description methodstring The name of the method to request
serializegrpc~serialize The serialization function for inputs
deserializegrpc~deserialize The deserialization function for outputs
metadatagrpc.Metadata <optional>
Array of metadata key/value pairs to add to the call
optionsgrpc.Client~CallOptions <optional>
Options map
Returns:
An event emitter for stream related events
-
makeClientStreamRequest(method, 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 methodstring The name of the method to request
serializegrpc~serialize The serialization function for inputs
deserializegrpc~deserialize The deserialization function for outputs
metadatagrpc.Metadata <optional>
Array of metadata key/value pairs to add to the call
optionsgrpc.Client~CallOptions <optional>
Options map
callbackgrpc.Client~requestCallback The callback to for when the response is received
Returns:
An event emitter for stream related events
-
makeServerStreamRequest(method, 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 methodstring The name of the method to request
serializegrpc~serialize The serialization function for inputs
deserializegrpc~deserialize The deserialization function for outputs
argument* The argument to the call. Should be serializable with serialize
metadatagrpc.Metadata <optional>
Array of metadata key/value pairs to add to the call
optionsgrpc.Client~CallOptions <optional>
Options map
Returns:
An event emitter for stream related events
-
makeUnaryRequest(method, 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 methodstring The name of the method to request
serializegrpc~serialize The serialization function for inputs
deserializegrpc~deserialize The deserialization function for outputs
argument* The argument to the call. Should be serializable with serialize
metadatagrpc.Metadata <optional>
Metadata to add to the call
optionsgrpc.Client~CallOptions <optional>
Options map
callbackgrpc.Client~requestCallback The callback to 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 deadlinegrpc~Deadline When to stop waiting for a connection.
callbackfunction The callback to call when done attempting to connect.
Type Definitions
-
Call
-
Any client call type
Type:
- grpc~ClientUnaryCall | grpc~ClientReadableStream | grpc~ClientWritableStream | grpc~ClientDuplexStream
-
CallOptions
-
Options that can be set on a call.
Type:
- Object
Properties:
Name Type Description deadlinegrpc~Deadline The deadline for the entire call to complete.
hoststring Server hostname to set on the call. Only meaningful if different from the server address used to construct the client.
parentgrpc.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_flagsnumber Indicates which properties of a parent call should propagate to this call. Bitwise combination of flags in grpc.propagate.
credentialsgrpc.credentials~CallCredentials The credentials that should be used to make this particular call.
-
requestCallback(error, value)
-
Parameters:
Name Type Argument Description errorgrpc~ServiceError <nullable>
The error, if the call failed
value* The response value, if the call succeeded