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~ChannelCredentials | Credentials to use to connect to the server |
options |
Object | Options to apply to channel creation |
- Source:
Methods
close()
Close this client.
- Source:
getChannel() → {Channel}
Return the underlying channel object for the specified client
- Source:
Returns:
The channel
- Type
- Channel
makeBidiStreamRequest(method, serialize, deserialize, metadataopt, optionsopt) → {grpc~ClientDuplexStream}
Make a bidirectional stream request with this method on the given channel.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
method |
string | The name 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 |
- Source:
Returns:
An event emitter for stream related events
makeClientStreamRequest(method, serialize, deserialize, metadataopt, optionsopt, callback) → {grpc~ClientWritableStream}
Make a client stream request to the given method, using the given serialize and deserialize functions, with the given argument.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
method |
string | The name 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 to for when the response is received |
- Source:
Returns:
An event emitter for stream related events
makeServerStreamRequest(method, serialize, deserialize, argument, metadataopt, optionsopt) → {grpc~ClientReadableStream}
Make a server stream request to the given method, with the given serialize and deserialize function, using the given argument
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
method |
string | The name 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 |
- Source:
Returns:
An event emitter for stream related events
makeUnaryRequest(method, serialize, deserialize, argument, metadataopt, optionsopt, callback) → {grpc~ClientUnaryCall}
Make a unary request to the given method, using the given serialize and deserialize functions, with the given argument.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
method |
string | The name 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 to for when the response is received |
- Source:
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. |
- Source:
Type Definitions
Call
Any client call type
Type:
- ClientUnaryCall | ClientReadableStream | ClientWritableStream | ClientDuplexStream
- Source:
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. |
- Source:
requestCallback(errornullable, value)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
error |
grpc~ServiceError |
<nullable> |
The error, if the call failed |
value |
* | The response value, if the call succeeded |
- Source: