@grpc/grpc-js
- Version 1.12.2
- Published
- 1.94 MB
- 2 dependencies
- Apache-2.0 license
Install
npm i @grpc/grpc-js
yarn add @grpc/grpc-js
pnpm add @grpc/grpc-js
Overview
gRPC Library for Node - pure JS implementation
Index
Variables
Functions
Classes
Interfaces
ChannelOptions
- 'grpc-node.max_session_memory'
- 'grpc-node.retry_max_attempts_limit'
- 'grpc-node.tls_enable_trace'
- 'grpc.client_idle_timeout_ms'
- 'grpc.default_authority'
- 'grpc.default_compression_algorithm'
- 'grpc.dns_min_time_between_resolutions_ms'
- 'grpc.enable_channelz'
- 'grpc.enable_http_proxy'
- 'grpc.enable_retries'
- 'grpc.http_connect_creds'
- 'grpc.http_connect_target'
- 'grpc.initial_reconnect_backoff_ms'
- 'grpc.keepalive_permit_without_calls'
- 'grpc.keepalive_time_ms'
- 'grpc.keepalive_timeout_ms'
- 'grpc.lb.ring_hash.ring_size_cap'
- 'grpc.max_concurrent_streams'
- 'grpc.max_connection_age_grace_ms'
- 'grpc.max_connection_age_ms'
- 'grpc.max_connection_idle_ms'
- 'grpc.max_receive_message_length'
- 'grpc.max_reconnect_backoff_ms'
- 'grpc.max_send_message_length'
- 'grpc.per_rpc_retry_buffer_size'
- 'grpc.primary_user_agent'
- 'grpc.retry_buffer_size'
- 'grpc.secondary_user_agent'
- 'grpc.service_config_disable_resolution'
- 'grpc.service_config'
- 'grpc.ssl_target_name_override'
- 'grpc.use_local_subchannel_pool'
Enums
Type Aliases
- Call
- ClientDuplexStream
- ClientOptions
- ClientReadableStream
- ClientUnaryCall
- ClientWritableStream
- Deadline
- handleBidiStreamingCall
- handleClientStreamingCall
- handleServerStreamingCall
- handleUnaryCall
- Listener
- MetadataValue
- OAuth2Client
- Requester
- Responder
- sendUnaryData
- ServerDuplexStream
- ServerErrorResponse
- ServerListener
- ServerReadableStream
- ServerUnaryCall
- ServerWritableStream
- ServiceDefinition
- ServiceError
- UntypedHandleCall
Namespaces
experimental
- BackoffTimeout
- BaseFilter
- BaseSubchannelWrapper
- CaCertificateUpdate
- CaCertificateUpdateListener
- CallStream
- CertificateProvider
- ChannelControlHelper
- ChildLoadBalancerHandler
- ConfigSelector
- ConnectivityStateListener
- createCertificateProviderChannelCredentials()
- createCertificateProviderServerCredentials()
- createChildChannelControlHelper()
- createResolver()
- createServerCredentialsWithInterceptors()
- Duration
- durationToMs()
- Endpoint
- endpointHasAddress()
- EndpointMap
- endpointToString()
- FailurePercentageEjectionConfig
- FileWatcherCertificateProvider
- FileWatcherCertificateProviderConfig
- Filter
- FilterFactory
- FilterStackFactory
- GrpcUri
- HealthListener
- HostPort
- IdentityCertificateUpdate
- IdentityCertificateUpdateListener
- isLoadBalancerNameRegistered()
- LeafLoadBalancer
- LoadBalancer
- log()
- OutlierDetectionRawConfig
- parseDuration()
- parseLoadBalancingConfig()
- PickArgs
- Picker
- PickResult
- PickResultType
- QueuePicker
- registerAdminService()
- registerLoadBalancerType()
- registerResolver()
- Resolver
- ResolverListener
- selectLbConfigFromList()
- splitHostPort()
- SubchannelAddress
- subchannelAddressToString()
- SubchannelInterface
- SuccessRateEjectionConfig
- trace()
- TypedLoadBalancingConfig
- UnavailablePicker
- uriToString()
Variables
variable credentials
const credentials: { combineChannelCredentials: ( channelCredentials: ChannelCredentials, ...callCredentials: CallCredentials[] ) => ChannelCredentials; combineCallCredentials: ( first: CallCredentials, ...additional: CallCredentials[] ) => CallCredentials; createInsecure: typeof ChannelCredentials.createInsecure; createSsl: typeof ChannelCredentials.createSsl; createFromSecureContext: typeof ChannelCredentials.createFromSecureContext; createFromMetadataGenerator: typeof CallCredentials.createFromMetadataGenerator; createFromGoogleCredential: typeof CallCredentials.createFromGoogleCredential; createEmpty: typeof CallCredentials.createEmpty;};
** Client Credentials ***
Functions
function addAdminServicesToServer
addAdminServicesToServer: (server: Server) => void;
function closeClient
closeClient: (client: Client) => void;
Close a Client object.
Parameter client
The client to close.
function getChannelzHandlers
getChannelzHandlers: () => ChannelzHandlers;
function getChannelzServiceDefinition
getChannelzServiceDefinition: () => ChannelzDefinition;
function getClientChannel
getClientChannel: (client: Client) => Channel;
function load
load: (filename: any, format: any, options: any) => never;
function loadObject
loadObject: (value: any, options: any) => never;
** Unimplemented function stubs ***
function loadPackageDefinition
loadPackageDefinition: (packageDef: PackageDefinition) => GrpcObject;
Load a gRPC package definition as a gRPC object hierarchy.
Parameter packageDef
The package definition object. The resulting gRPC object.
function makeClientConstructor
makeClientConstructor: ( methods: ServiceDefinition, serviceName: string, classOptions?: {}) => ServiceClientConstructor;
Creates a constructor for a client with the given methods, as specified in the methods argument. The resulting class will have an instance method for each method in the service, which is a partial application of one of the [Client]grpc.Client request methods, depending on
requestSerialize
andresponseSerialize
, with themethod
,serialize
, anddeserialize
arguments predefined.Parameter methods
An object mapping method names to method attributes
Parameter serviceName
The fully qualified name of the service
Parameter classOptions
An options object. New client constructor, which is a subclass of grpc.Client, and has the same arguments as that constructor.
function makeGenericClientConstructor
makeGenericClientConstructor: ( methods: ServiceDefinition, serviceName: string, classOptions?: {}) => ServiceClientConstructor;
Creates a constructor for a client with the given methods, as specified in the methods argument. The resulting class will have an instance method for each method in the service, which is a partial application of one of the [Client]grpc.Client request methods, depending on
requestSerialize
andresponseSerialize
, with themethod
,serialize
, anddeserialize
arguments predefined.Parameter methods
An object mapping method names to method attributes
Parameter serviceName
The fully qualified name of the service
Parameter classOptions
An options object. New client constructor, which is a subclass of grpc.Client, and has the same arguments as that constructor.
function setLogger
setLogger: (logger: Partial<Console>) => void;
function setLogVerbosity
setLogVerbosity: (verbosity: LogVerbosity) => void;
function waitForClientReady
waitForClientReady: ( client: Client, deadline: Date | number, callback: (error?: Error) => void) => void;
Classes
class CallCredentials
abstract class CallCredentials {}
A class that represents a generic method of adding authentication-related metadata on a per-request basis.
method compose
abstract compose: (callCredentials: CallCredentials) => CallCredentials;
Creates a new CallCredentials object from properties of both this and another CallCredentials object. This object's metadata generator will be called first.
Parameter callCredentials
The other CallCredentials object.
method createEmpty
static createEmpty: () => CallCredentials;
method createFromGoogleCredential
static createFromGoogleCredential: ( googleCredentials: OAuth2Client) => CallCredentials;
Create a gRPC credential from a Google credential object.
Parameter googleCredentials
The authentication client to use. The resulting CallCredentials object.
method createFromMetadataGenerator
static createFromMetadataGenerator: ( metadataGenerator: CallMetadataGenerator) => CallCredentials;
Creates a new CallCredentials object from a given function that generates Metadata objects.
Parameter metadataGenerator
A function that accepts a set of options, and generates a Metadata object based on these options, which is passed back to the caller via a supplied (err, metadata) callback.
method generateMetadata
abstract generateMetadata: (options: CallMetadataOptions) => Promise<Metadata>;
Asynchronously generates a new Metadata object.
Parameter options
Options used in generating the Metadata object.
class Channel
class ChannelImplementation implements Channel {}
constructor
constructor( target: string, credentials: ChannelCredentials, options: ChannelOptions);
method close
close: () => void;
method createCall
createCall: ( method: string, deadline: Deadline, host: string | null | undefined, parentCall: ServerSurfaceCall | null, propagateFlags: number | null | undefined) => Call;
method getChannelzRef
getChannelzRef: () => ChannelRef;
Get the channelz reference object for this channel. The returned value is garbage if channelz is disabled for this channel.
Returns
method getConnectivityState
getConnectivityState: (tryToConnect: boolean) => ConnectivityState;
method getTarget
getTarget: () => string;
method watchConnectivityState
watchConnectivityState: ( currentState: ConnectivityState, deadline: Date | number, callback: (error?: Error) => void) => void;
class ChannelCredentials
abstract class ChannelCredentials {}
A class that contains credentials for communicating over a channel, as well as a set of per-call credentials, which are applied to every method call made over a channel initialized with an instance of this class.
constructor
protected constructor(callCredentials?: CallCredentials);
property callCredentials
protected callCredentials: CallCredentials;
method compose
abstract compose: (callCredentials: CallCredentials) => ChannelCredentials;
Returns a copy of this object with the included set of per-call credentials expanded to include callCredentials.
Parameter callCredentials
A CallCredentials object to associate with this instance.
method createFromSecureContext
static createFromSecureContext: ( secureContext: SecureContext, verifyOptions?: VerifyOptions) => ChannelCredentials;
Return a new ChannelCredentials instance with credentials created using the provided secureContext. The resulting instances can be used to construct a Channel that communicates over TLS. gRPC will not override anything in the provided secureContext, so the environment variables GRPC_SSL_CIPHER_SUITES and GRPC_DEFAULT_SSL_ROOTS_FILE_PATH will not be applied.
Parameter secureContext
The return value of tls.createSecureContext()
Parameter verifyOptions
Additional options to modify certificate verification
method createInsecure
static createInsecure: () => ChannelCredentials;
Return a new ChannelCredentials instance with no credentials.
method createSsl
static createSsl: ( rootCerts?: Buffer | null, privateKey?: Buffer | null, certChain?: Buffer | null, verifyOptions?: VerifyOptions) => ChannelCredentials;
Return a new ChannelCredentials instance with a given set of credentials. The resulting instance can be used to construct a Channel that communicates over TLS.
Parameter rootCerts
The root certificate data.
Parameter privateKey
The client certificate private key, if available.
Parameter certChain
The client certificate key chain, if available.
Parameter verifyOptions
Additional options to modify certificate verification
class Client
class Client {}
A generic gRPC client. Primarily useful as a base class for all generated clients.
constructor
constructor( address: string, credentials: ChannelCredentials, options?: ClientOptions);
method close
close: () => void;
method getChannel
getChannel: () => Channel;
method makeBidiStreamRequest
makeBidiStreamRequest: { <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, options?: CallOptions ): ClientDuplexStream<RequestType, ResponseType>; <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, options?: CallOptions ): any;};
method makeClientStreamRequest
makeClientStreamRequest: { <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, options: CallOptions, callback: UnaryCallback<ResponseType> ): ClientWritableStream<RequestType>; <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, callback: UnaryCallback<ResponseType> ): any; <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, options: CallOptions, callback: UnaryCallback<ResponseType> ): any; <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, callback: UnaryCallback<ResponseType> ): any;};
method makeServerStreamRequest
makeServerStreamRequest: { <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, options?: CallOptions ): ClientReadableStream<ResponseType>; <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, options?: CallOptions ): any;};
method makeUnaryRequest
makeUnaryRequest: { <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, options: CallOptions, callback: UnaryCallback<ResponseType> ): ClientUnaryCall; <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, callback: UnaryCallback<ResponseType> ): any; <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, options: CallOptions, callback: UnaryCallback<ResponseType> ): any; <RequestType, ResponseType>( method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, callback: UnaryCallback<ResponseType> ): any;};
method waitForReady
waitForReady: (deadline: Deadline, callback: (error?: Error) => void) => void;
class InterceptingCall
class InterceptingCall implements InterceptingCallInterface {}
constructor
constructor( nextCall: InterceptingCallInterface, requester?: Partial<FullRequester>);
method cancelWithStatus
cancelWithStatus: (status: Status, details: string) => void;
method getPeer
getPeer: () => string;
method halfClose
halfClose: () => void;
method sendMessage
sendMessage: (message: any) => void;
method sendMessageWithContext
sendMessageWithContext: (context: MessageContext, message: any) => void;
method start
start: ( metadata: Metadata, interceptingListener?: Partial<InterceptingListener>) => void;
method startRead
startRead: () => void;
class InterceptorConfigurationError
class InterceptorConfigurationError extends Error {}
Error class associated with passing both interceptors and interceptor providers to a client constructor or as call options.
constructor
constructor(message: string);
class ListenerBuilder
class ListenerBuilder {}
method build
build: () => Listener;
method withOnReceiveMessage
withOnReceiveMessage: (onReceiveMessage: MessageListener) => this;
method withOnReceiveMetadata
withOnReceiveMetadata: (onReceiveMetadata: MetadataListener) => this;
method withOnReceiveStatus
withOnReceiveStatus: (onReceiveStatus: StatusListener) => this;
class Metadata
class Metadata {}
A class for storing metadata. Keys are normalized to lowercase ASCII.
constructor
constructor(options?: MetadataOptions);
property internalRepr
protected internalRepr: MetadataObject;
method add
add: (key: string, value: MetadataValue) => void;
Adds the given value for the given key by appending to a list of previous values associated with that key. Normalizes the key.
Parameter key
The key for which a new value should be appended.
Parameter value
The value to add. Must be a buffer if and only if the normalized key ends with '-bin'.
method clone
clone: () => Metadata;
Clones the metadata object. The newly cloned object.
method fromHttp2Headers
static fromHttp2Headers: (headers: http2.IncomingHttpHeaders) => Metadata;
Returns a new Metadata object based fields in a given IncomingHttpHeaders object.
Parameter headers
An IncomingHttpHeaders object.
method get
get: (key: string) => MetadataValue[];
Gets a list of all values associated with the key. Normalizes the key.
Parameter key
The key whose value should be retrieved. A list of values associated with the given key.
method getMap
getMap: () => { [key: string]: any };
Gets a plain object mapping each key to the first value associated with it. This reflects the most common way that people will want to see metadata. A key/value mapping of the metadata.
method getOptions
getOptions: () => MetadataOptions;
method merge
merge: (other: Metadata) => void;
Merges all key-value pairs from a given Metadata object into this one. If both this object and the given object have values in the same key, values from the other Metadata object will be appended to this object's values.
Parameter other
A Metadata object.
method remove
remove: (key: string) => void;
Removes the given key and any associated values. Normalizes the key.
Parameter key
The key whose values should be removed.
method set
set: (key: string, value: MetadataValue) => void;
Sets the given value for the given key by replacing any other values associated with that key. Normalizes the key.
Parameter key
The key to whose value should be set.
Parameter value
The value to set. Must be a buffer if and only if the normalized key ends with '-bin'.
method setOptions
setOptions: (options: MetadataOptions) => void;
method toHttp2Headers
toHttp2Headers: () => http2.OutgoingHttpHeaders;
Creates an OutgoingHttpHeaders object that can be used with the http2 API.
method toJSON
toJSON: () => { [key: string]: any[] };
This modifies the behavior of JSON.stringify to show an object representation of the metadata map.
class RequesterBuilder
class RequesterBuilder {}
method build
build: () => Requester;
method withCancel
withCancel: (cancel: CancelRequester) => this;
method withHalfClose
withHalfClose: (halfClose: CloseRequester) => this;
method withSendMessage
withSendMessage: (sendMessage: MessageRequester) => this;
method withStart
withStart: (start: MetadataRequester) => this;
class ResponderBuilder
class ResponderBuilder {}
method build
build: () => Responder;
method withSendMessage
withSendMessage: (sendMessage: MessageResponder) => this;
method withSendMetadata
withSendMetadata: (sendMetadata: MetadataResponder) => this;
method withSendStatus
withSendStatus: (sendStatus: StatusResponder) => this;
method withStart
withStart: (start: StartResponder) => this;
class Server
class Server {}
constructor
constructor(options?: ServerOptions);
method addHttp2Port
addHttp2Port: () => never;
method addProtoService
addProtoService: () => never;
method addService
addService: ( service: ServiceDefinition, implementation: UntypedServiceImplementation) => void;
method bind
bind: (port: string, creds: ServerCredentials) => never;
method bindAsync
bindAsync: ( port: string, creds: ServerCredentials, callback: (error: Error | null, port: number) => void) => void;
method createConnectionInjector
createConnectionInjector: (credentials: ServerCredentials) => ConnectionInjector;
method drain
drain: (port: string, graceTimeMs: number) => void;
Gracefully close all connections associated with a previously bound port. After the grace time, forcefully close all remaining open connections.
If port 0 was bound, only the actual bound port can be drained. For example, if bindAsync was called with "localhost:0" and the bound port result was 54321, it can be drained as "localhost:54321".
Parameter port
Parameter graceTimeMs
Returns
method forceShutdown
forceShutdown: () => void;
method getChannelzRef
getChannelzRef: () => ServerRef;
Get the channelz reference object for this server. The returned value is garbage if channelz is disabled for this server.
Returns
method register
register: <RequestType, ResponseType>( name: string, handler: HandleCall<RequestType, ResponseType>, serialize: Serialize<ResponseType>, deserialize: Deserialize<RequestType>, type: string) => boolean;
method removeService
removeService: (service: ServiceDefinition) => void;
method start
start: () => void;
Deprecated
No longer needed as of version 1.10.x
method tryShutdown
tryShutdown: (callback: (error?: Error) => void) => void;
method unbind
unbind: (port: string) => void;
Unbind a previously bound port, or cancel an in-progress bindAsync operation. If port 0 was bound, only the actual bound port can be unbound. For example, if bindAsync was called with "localhost:0" and the bound port result was 54321, it can be unbound as "localhost:54321".
Parameter port
method unregister
unregister: (name: string) => boolean;
class ServerCredentials
abstract class ServerCredentials {}
method createInsecure
static createInsecure: () => ServerCredentials;
method createSsl
static createSsl: ( rootCerts: Buffer | null, keyCertPairs: KeyCertPair[], checkClientCertificate?: boolean) => ServerCredentials;
method getWatcherCount
protected getWatcherCount: () => number;
method updateSecureContextOptions
protected updateSecureContextOptions: ( options: SecureServerOptions | null) => void;
class ServerInterceptingCall
class ServerInterceptingCall implements ServerInterceptingCallInterface {}
constructor
constructor( nextCall: ServerInterceptingCallInterface, responder?: Partial<FullResponder>);
method getDeadline
getDeadline: () => Deadline;
method getHost
getHost: () => string;
method getPeer
getPeer: () => string;
method sendMessage
sendMessage: (message: any, callback: () => void) => void;
method sendMetadata
sendMetadata: (metadata: Metadata) => void;
method sendStatus
sendStatus: (status: PartialStatusObject) => void;
method start
start: (listener: InterceptingServerListener) => void;
method startRead
startRead: () => void;
class ServerListenerBuilder
class ServerListenerBuilder {}
method build
build: () => ServerListener;
method withOnCancel
withOnCancel: (onCancel: ServerCancelListener) => this;
method withOnReceiveHalfClose
withOnReceiveHalfClose: (onReceiveHalfClose: ServerHalfCloseListener) => this;
method withOnReceiveMessage
withOnReceiveMessage: (onReceiveMessage: ServerMessageListener) => this;
method withOnReceiveMetadata
withOnReceiveMetadata: (onReceiveMetadata: ServerMetadataListener) => this;
class StatusBuilder
class StatusBuilder {}
A builder for gRPC status objects.
constructor
constructor();
method build
build: () => Partial<StatusObject>;
Builds the status object.
method withCode
withCode: (code: Status) => this;
Adds a status code to the builder.
method withDetails
withDetails: (details: string) => this;
Adds details to the builder.
method withMetadata
withMetadata: (metadata: Metadata) => this;
Adds metadata to the builder.
Interfaces
interface CallInvocationTransformer
interface CallInvocationTransformer {}
call signature
(callProperties: CallProperties<any, any>): CallProperties<any, any>;
interface CallOptions
interface CallOptions {}
property credentials
credentials?: CallCredentials;
property deadline
deadline?: Deadline;
property host
host?: string;
property interceptor_providers
interceptor_providers?: InterceptorProvider[];
property interceptors
interceptors?: Interceptor[];
property parent
parent?: | ServerUnaryCall<any, any> | ServerReadableStream<any, any> | ServerWritableStream<any, any> | ServerDuplexStream<any, any>;
property propagate_flags
propagate_flags?: number;
interface CallProperties
interface CallProperties<RequestType, ResponseType> {}
property argument
argument?: RequestType;
property call
call: SurfaceCall;
property callback
callback?: UnaryCallback<ResponseType>;
property callOptions
callOptions: CallOptions;
property channel
channel: Channel;
property metadata
metadata: Metadata;
property methodDefinition
methodDefinition: ClientMethodDefinition<RequestType, ResponseType>;
interface ChannelInterface
interface Channel {}
An interface that represents a communication channel to a server specified by a given address.
method close
close: () => void;
Close the channel. This has the same functionality as the existing grpc.Client.prototype.close
method createCall
createCall: ( method: string, deadline: Deadline, host: string | null | undefined, parentCall: ServerSurfaceCall | null, propagateFlags: number | null | undefined) => Call;
Create a call object. Call is an opaque type that is used by the Client class. This function is called by the gRPC library when starting a request. Implementers should return an instance of Call that is returned from calling createCall on an instance of the provided Channel class.
Parameter method
The full method string to request.
Parameter deadline
The call deadline
Parameter host
A host string override for making the request
Parameter parentCall
A server call to propagate some information from
Parameter propagateFlags
A bitwise combination of elements of grpc.propagate that indicates what information to propagate from parentCall.
method getChannelzRef
getChannelzRef: () => ChannelRef;
Get the channelz reference object for this channel. A request to the channelz service for the id in this object will provide information about this channel.
method getConnectivityState
getConnectivityState: (tryToConnect: boolean) => ConnectivityState;
Get the channel's current connectivity state. This method is here mainly because it is in the existing internal Channel class, and there isn't another good place to put it.
Parameter tryToConnect
If true, the channel will start connecting if it is idle. Otherwise, idle channels will only start connecting when a call starts.
method getTarget
getTarget: () => string;
Return the target that this channel connects to
method watchConnectivityState
watchConnectivityState: ( currentState: ConnectivityState, deadline: Date | number, callback: (error?: Error) => void) => void;
Watch for connectivity state changes. This is also here mainly because it is in the existing external Channel class.
Parameter currentState
The state to watch for transitions from. This should always be populated by calling getConnectivityState immediately before.
Parameter deadline
A deadline for waiting for a state change
Parameter callback
Called with no error when a state change, or with an error if the deadline passes without a state change.
interface ChannelOptions
interface ChannelOptions {}
An interface that contains options used when initializing a Channel instance.
property 'grpc-node.max_session_memory'
'grpc-node.max_session_memory'?: number;
property 'grpc-node.retry_max_attempts_limit'
'grpc-node.retry_max_attempts_limit'?: number;
property 'grpc-node.tls_enable_trace'
'grpc-node.tls_enable_trace'?: number;
Set the enableTrace option in TLS clients and servers
property 'grpc.client_idle_timeout_ms'
'grpc.client_idle_timeout_ms'?: number;
property 'grpc.default_authority'
'grpc.default_authority'?: string;
property 'grpc.default_compression_algorithm'
'grpc.default_compression_algorithm'?: CompressionAlgorithms;
property 'grpc.dns_min_time_between_resolutions_ms'
'grpc.dns_min_time_between_resolutions_ms'?: number;
property 'grpc.enable_channelz'
'grpc.enable_channelz'?: number;
property 'grpc.enable_http_proxy'
'grpc.enable_http_proxy'?: number;
property 'grpc.enable_retries'
'grpc.enable_retries'?: number;
property 'grpc.http_connect_creds'
'grpc.http_connect_creds'?: string;
property 'grpc.http_connect_target'
'grpc.http_connect_target'?: string;
property 'grpc.initial_reconnect_backoff_ms'
'grpc.initial_reconnect_backoff_ms'?: number;
property 'grpc.keepalive_permit_without_calls'
'grpc.keepalive_permit_without_calls'?: number;
property 'grpc.keepalive_time_ms'
'grpc.keepalive_time_ms'?: number;
property 'grpc.keepalive_timeout_ms'
'grpc.keepalive_timeout_ms'?: number;
property 'grpc.lb.ring_hash.ring_size_cap'
'grpc.lb.ring_hash.ring_size_cap'?: number;
property 'grpc.max_concurrent_streams'
'grpc.max_concurrent_streams'?: number;
property 'grpc.max_connection_age_grace_ms'
'grpc.max_connection_age_grace_ms'?: number;
property 'grpc.max_connection_age_ms'
'grpc.max_connection_age_ms'?: number;
property 'grpc.max_connection_idle_ms'
'grpc.max_connection_idle_ms'?: number;
property 'grpc.max_receive_message_length'
'grpc.max_receive_message_length'?: number;
property 'grpc.max_reconnect_backoff_ms'
'grpc.max_reconnect_backoff_ms'?: number;
property 'grpc.max_send_message_length'
'grpc.max_send_message_length'?: number;
property 'grpc.per_rpc_retry_buffer_size'
'grpc.per_rpc_retry_buffer_size'?: number;
property 'grpc.primary_user_agent'
'grpc.primary_user_agent'?: string;
property 'grpc.retry_buffer_size'
'grpc.retry_buffer_size'?: number;
property 'grpc.secondary_user_agent'
'grpc.secondary_user_agent'?: string;
property 'grpc.service_config_disable_resolution'
'grpc.service_config_disable_resolution'?: number;
property 'grpc.service_config'
'grpc.service_config'?: string;
property 'grpc.ssl_target_name_override'
'grpc.ssl_target_name_override'?: string;
property 'grpc.use_local_subchannel_pool'
'grpc.use_local_subchannel_pool'?: number;
index signature
[key: string]: any;
interface ConnectionInjector
interface ConnectionInjector {}
method destroy
destroy: () => void;
method drain
drain: (graceTimeMs: number) => void;
method injectConnection
injectConnection: (connection: Duplex) => void;
interface deserialize
interface Deserialize<T> {}
call signature
(bytes: Buffer): T;
interface FullResponder
interface FullResponder {}
property sendMessage
sendMessage: MessageResponder;
property sendMetadata
sendMetadata: MetadataResponder;
property sendStatus
sendStatus: StatusResponder;
property start
start: StartResponder;
interface FullServerListener
interface FullServerListener {}
property onCancel
onCancel: ServerCancelListener;
property onReceiveHalfClose
onReceiveHalfClose: ServerHalfCloseListener;
property onReceiveMessage
onReceiveMessage: ServerMessageListener;
property onReceiveMetadata
onReceiveMetadata: ServerMetadataListener;
interface GrpcObject
interface GrpcObject {}
index signature
[index: string]: GrpcObject | ServiceClientConstructor | ProtobufTypeDefinition;
interface InterceptingListener
interface InterceptingListener {}
An object with methods for handling the responses to a call.
method onReceiveMessage
onReceiveMessage: (message: any) => void;
method onReceiveMetadata
onReceiveMetadata: (metadata: Metadata) => void;
method onReceiveStatus
onReceiveStatus: (status: StatusObject) => void;
interface Interceptor
interface Interceptor {}
call signature
(options: InterceptorOptions, nextCall: NextCall): InterceptingCall;
interface InterceptorOptions
interface InterceptorOptions extends CallOptions {}
property method_definition
method_definition: ClientMethodDefinition<any, any>;
interface InterceptorProvider
interface InterceptorProvider {}
call signature
(methodDefinition: ClientMethodDefinition<any, any>): Interceptor;
interface KeyCertPair
interface KeyCertPair {}
property cert_chain
cert_chain: Buffer;
property private_key
private_key: Buffer;
interface LoadBalancingConfig
interface LoadBalancingConfig {}
index signature
[key: string]: object;
interface MetadataOptions
interface MetadataOptions {}
property cacheableRequest
cacheableRequest?: boolean;
property corked
corked?: boolean;
property idempotentRequest
idempotentRequest?: boolean;
property waitForReady
waitForReady?: boolean;
interface MethodConfig
interface MethodConfig {}
property hedgingPolicy
hedgingPolicy?: HedgingPolicy;
property maxRequestBytes
maxRequestBytes?: number;
property maxResponseBytes
maxResponseBytes?: number;
property name
name: MethodConfigName[];
property retryPolicy
retryPolicy?: RetryPolicy;
property timeout
timeout?: Duration;
property waitForReady
waitForReady?: boolean;
interface MethodDefinition
interface MethodDefinition<RequestType, ResponseType> extends ClientMethodDefinition<RequestType, ResponseType>, ServerMethodDefinition<RequestType, ResponseType> {}
interface NextCall
interface NextCall {}
call signature
(options: InterceptorOptions): InterceptingCallInterface;
interface ProtobufTypeDefinition
interface ProtobufTypeDefinition {}
property fileDescriptorProtos
fileDescriptorProtos: Buffer[];
property format
format: string;
property type
type: object;
interface requestCallback
interface UnaryCallback<ResponseType> {}
call signature
(err: ServiceError | null, value?: ResponseType): void;
interface RetryPolicy
interface RetryPolicy {}
property backoffMultiplier
backoffMultiplier: number;
property initialBackoff
initialBackoff: string;
property maxAttempts
maxAttempts: number;
property maxBackoff
maxBackoff: string;
property retryableStatusCodes
retryableStatusCodes: (Status | string)[];
interface serialize
interface Serialize<T> {}
call signature
(value: T): Buffer;
interface ServerInterceptingCallInterface
interface ServerInterceptingCallInterface {}
method getDeadline
getDeadline: () => Deadline;
Return the call deadline set by the client. The value is Infinity if there is no deadline.
method getHost
getHost: () => string;
Return the host requested by the client in the ":authority" header.
method getPeer
getPeer: () => string;
Return the peer address of the client making the request, if known, or "unknown" otherwise
method sendMessage
sendMessage: (message: any, callback: () => void) => void;
Send a response message.
method sendMetadata
sendMetadata: (metadata: Metadata) => void;
Send response metadata.
method sendStatus
sendStatus: (status: PartialStatusObject) => void;
End the call by sending this status.
method start
start: (listener: InterceptingServerListener) => void;
Register the listener to handle inbound events.
method startRead
startRead: () => void;
Start a single read, eventually triggering either listener.onReceiveMessage or listener.onReceiveHalfClose.
interface ServerInterceptor
interface ServerInterceptor {}
call signature
( methodDescriptor: ServerMethodDefinition<any, any>, call: ServerInterceptingCallInterface): ServerInterceptingCall;
interface ServerOptions
interface ServerOptions extends ChannelOptions {}
property interceptors
interceptors?: ServerInterceptor[];
interface ServiceClientConstructor
interface ServiceClientConstructor {}
property service
service: ServiceDefinition;
property serviceName
serviceName: string;
construct signature
new ( address: string, credentials: ChannelCredentials, options?: Partial<ChannelOptions>): ServiceClient;
interface ServiceConfig
interface ServiceConfig {}
property loadBalancingConfig
loadBalancingConfig: LoadBalancingConfig[];
property loadBalancingPolicy
loadBalancingPolicy?: string;
property methodConfig
methodConfig: MethodConfig[];
property retryThrottling
retryThrottling?: RetryThrottling;
interface StatusObject
interface StatusObject {}
interface UntypedServiceImplementation
interface UntypedServiceImplementation {}
index signature
[name: string]: UntypedHandleCall;
interface VerifyOptions
interface VerifyOptions {}
Additional peer verification options that can be set when creating SSL credentials.
property checkServerIdentity
checkServerIdentity?: CheckServerIdentityCallback;
If set, this callback will be invoked after the usual hostname verification has been performed on the peer certificate.
property rejectUnauthorized
rejectUnauthorized?: boolean;
Enums
enum compressionAlgorithms
enum compressionAlgorithms { identity = 0, deflate = 1, gzip = 2,}
enum connectivityState
enum connectivityState { IDLE = 0, CONNECTING = 1, READY = 2, TRANSIENT_FAILURE = 3, SHUTDOWN = 4,}
member CONNECTING
CONNECTING = 1
member IDLE
IDLE = 0
member READY
READY = 2
member SHUTDOWN
SHUTDOWN = 4
member TRANSIENT_FAILURE
TRANSIENT_FAILURE = 3
enum logVerbosity
enum logVerbosity { DEBUG = 0, INFO = 1, ERROR = 2, NONE = 3,}
enum propagate
enum propagate { DEADLINE = 1, CENSUS_STATS_CONTEXT = 2, CENSUS_TRACING_CONTEXT = 4, CANCELLATION = 8, DEFAULTS = 65535,}
NOTE: This enum is not currently used in any implemented API in this library. It is included only for type parity with the other implementation.
member CANCELLATION
CANCELLATION = 8
member CENSUS_STATS_CONTEXT
CENSUS_STATS_CONTEXT = 2
member CENSUS_TRACING_CONTEXT
CENSUS_TRACING_CONTEXT = 4
member DEADLINE
DEADLINE = 1
member DEFAULTS
DEFAULTS = 65535
enum status
enum status { OK = 0, CANCELLED = 1, UNKNOWN = 2, INVALID_ARGUMENT = 3, DEADLINE_EXCEEDED = 4, NOT_FOUND = 5, ALREADY_EXISTS = 6, PERMISSION_DENIED = 7, RESOURCE_EXHAUSTED = 8, FAILED_PRECONDITION = 9, ABORTED = 10, OUT_OF_RANGE = 11, UNIMPLEMENTED = 12, INTERNAL = 13, UNAVAILABLE = 14, DATA_LOSS = 15, UNAUTHENTICATED = 16,}
member ABORTED
ABORTED = 10
member ALREADY_EXISTS
ALREADY_EXISTS = 6
member CANCELLED
CANCELLED = 1
member DATA_LOSS
DATA_LOSS = 15
member DEADLINE_EXCEEDED
DEADLINE_EXCEEDED = 4
member FAILED_PRECONDITION
FAILED_PRECONDITION = 9
member INTERNAL
INTERNAL = 13
member INVALID_ARGUMENT
INVALID_ARGUMENT = 3
member NOT_FOUND
NOT_FOUND = 5
member OK
OK = 0
member OUT_OF_RANGE
OUT_OF_RANGE = 11
member PERMISSION_DENIED
PERMISSION_DENIED = 7
member RESOURCE_EXHAUSTED
RESOURCE_EXHAUSTED = 8
member UNAUTHENTICATED
UNAUTHENTICATED = 16
member UNAVAILABLE
UNAVAILABLE = 14
member UNIMPLEMENTED
UNIMPLEMENTED = 12
member UNKNOWN
UNKNOWN = 2
Type Aliases
type Call
type Call = | ClientUnaryCall | ClientReadableStream<any> | ClientWritableStream<any> | ClientDuplexStream<any, any>;
type ClientDuplexStream
type ClientDuplexStream<RequestType, ResponseType> = ClientWritableStream<RequestType> & ClientReadableStream<ResponseType>;
A type representing the return value of a bidirectional stream method call.
type ClientOptions
type ClientOptions = Partial<ChannelOptions> & { channelOverride?: Channel; channelFactoryOverride?: ( address: string, credentials: ChannelCredentials, options: ClientOptions ) => Channel; interceptors?: Interceptor[]; interceptor_providers?: InterceptorProvider[]; callInvocationTransformer?: CallInvocationTransformer;};
type ClientReadableStream
type ClientReadableStream<ResponseType> = { deserialize: (chunk: Buffer) => ResponseType;} & SurfaceCall & ObjectReadable<ResponseType>;
A type representing the return value of a server stream method call.
type ClientUnaryCall
type ClientUnaryCall = SurfaceCall;
A type representing the return value of a unary method call.
type ClientWritableStream
type ClientWritableStream<RequestType> = { serialize: (value: RequestType) => Buffer;} & SurfaceCall & ObjectWritable<RequestType>;
A type representing the return value of a client stream method call.
type Deadline
type Deadline = Date | number;
type handleBidiStreamingCall
type handleBidiStreamingCall<RequestType, ResponseType> = ( call: ServerDuplexStream<RequestType, ResponseType>) => void;
type handleClientStreamingCall
type handleClientStreamingCall<RequestType, ResponseType> = ( call: ServerReadableStream<RequestType, ResponseType>, callback: sendUnaryData<ResponseType>) => void;
type handleServerStreamingCall
type handleServerStreamingCall<RequestType, ResponseType> = ( call: ServerWritableStream<RequestType, ResponseType>) => void;
type handleUnaryCall
type handleUnaryCall<RequestType, ResponseType> = ( call: ServerUnaryCall<RequestType, ResponseType>, callback: sendUnaryData<ResponseType>) => void;
type Listener
type Listener = Partial<FullListener>;
type MetadataValue
type MetadataValue = string | Buffer;
type OAuth2Client
type OAuth2Client = OldOAuth2Client | CurrentOAuth2Client;
type Requester
type Requester = Partial<FullRequester>;
type Responder
type Responder = Partial<FullResponder>;
type sendUnaryData
type sendUnaryData<ResponseType> = ( error: ServerErrorResponse | ServerStatusResponse | null, value?: ResponseType | null, trailer?: Metadata, flags?: number) => void;
type ServerDuplexStream
type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall & ObjectReadable<RequestType> & ObjectWritable<ResponseType> & { end: (metadata?: Metadata) => void; };
type ServerErrorResponse
type ServerErrorResponse = ServerStatusResponse & Error;
type ServerListener
type ServerListener = Partial<FullServerListener>;
type ServerReadableStream
type ServerReadableStream<RequestType, ResponseType> = ServerSurfaceCall & ObjectReadable<RequestType>;
type ServerUnaryCall
type ServerUnaryCall<RequestType, ResponseType> = ServerSurfaceCall & { request: RequestType;};
type ServerWritableStream
type ServerWritableStream<RequestType, ResponseType> = ServerSurfaceCall & ObjectWritable<ResponseType> & { request: RequestType; end: (metadata?: Metadata) => void; };
type ServiceDefinition
type ServiceDefinition<ImplementationType = UntypedServiceImplementation> = { readonly [index in keyof ImplementationType]: MethodDefinition<any, any>;};
type ServiceError
type ServiceError = StatusObject & Error;
A type extending the built-in Error object with additional fields.
type UntypedHandleCall
type UntypedHandleCall = HandleCall<any, any>;
Namespaces
namespace experimental
module 'build/src/experimental.d.ts' {}
function createCertificateProviderChannelCredentials
createCertificateProviderChannelCredentials: ( caCertificateProvider: CertificateProvider, identityCertificateProvider: CertificateProvider | null, verifyOptions?: VerifyOptions) => CertificateProviderChannelCredentialsImpl;
function createCertificateProviderServerCredentials
createCertificateProviderServerCredentials: ( caCertificateProvider: CertificateProvider, identityCertificateProvider: CertificateProvider | null, requireClientCertificate: boolean) => CertificateProviderServerCredentials;
function createChildChannelControlHelper
createChildChannelControlHelper: ( parent: ChannelControlHelper, overrides: Partial<ChannelControlHelper>) => ChannelControlHelper;
Create a child ChannelControlHelper that overrides some methods of the parent while letting others pass through to the parent unmodified. This allows other code to create these children without needing to know about all of the methods to be passed through.
Parameter parent
Parameter overrides
function createResolver
createResolver: ( target: GrpcUri, listener: ResolverListener, options: ChannelOptions) => Resolver;
Create a name resolver for the specified target, if possible. Throws an error if no such name resolver can be created.
Parameter target
Parameter listener
function createServerCredentialsWithInterceptors
createServerCredentialsWithInterceptors: ( credentials: ServerCredentials, interceptors: ServerInterceptor[]) => ServerCredentials;
function durationToMs
durationToMs: (duration: Duration) => number;
function endpointHasAddress
endpointHasAddress: ( endpoint: Endpoint, expectedAddress: SubchannelAddress) => boolean;
function endpointToString
endpointToString: (endpoint: Endpoint) => string;
function isLoadBalancerNameRegistered
isLoadBalancerNameRegistered: (typeName: string) => boolean;
function log
log: (severity: LogVerbosity, ...args: any[]) => void;
function parseDuration
parseDuration: (value: string) => Duration | null;
function parseLoadBalancingConfig
parseLoadBalancingConfig: ( rawConfig: LoadBalancingConfig) => TypedLoadBalancingConfig;
function registerAdminService
registerAdminService: ( getServiceDefinition: GetServiceDefinition, getHandlers: GetHandlers) => void;
function registerLoadBalancerType
registerLoadBalancerType: ( typeName: string, loadBalancerType: LoadBalancerConstructor, loadBalancingConfigType: TypedLoadBalancingConfigConstructor) => void;
function registerResolver
registerResolver: (scheme: string, resolverClass: ResolverConstructor) => void;
Register a resolver class to handle target names prefixed with the
prefix
string. This prefix should correspond to a URI scheme name listed in the [gRPC Name Resolution document](https://github.com/grpc/grpc/blob/master/doc/naming.md)Parameter prefix
Parameter resolverClass
function selectLbConfigFromList
selectLbConfigFromList: ( configs: LoadBalancingConfig[], fallbackTodefault?: boolean) => TypedLoadBalancingConfig | null;
function splitHostPort
splitHostPort: (path: string) => HostPort | null;
function subchannelAddressToString
subchannelAddressToString: (address: SubchannelAddress) => string;
function trace
trace: (severity: LogVerbosity, tracer: string, text: string) => void;
function uriToString
uriToString: (uri: GrpcUri) => string;
class BackoffTimeout
class BackoffTimeout {}
constructor
constructor(callback: () => void, options?: BackoffOptions);
method getEndTime
getEndTime: () => Date;
Get the approximate timestamp of when the timer will fire. Only valid if this.isRunning() is true.
method isRunning
isRunning: () => boolean;
Check whether the timer is currently running.
method ref
ref: () => void;
Set that while the timer is running, it should keep the Node process running.
method reset
reset: () => void;
Reset the delay time to its initial value. If the timer is still running, retroactively apply that reset to the current timer.
method runOnce
runOnce: () => void;
Call the callback after the current amount of delay time
method stop
stop: () => void;
Stop the timer. The callback will not be called until
runOnce
is called again.
method unref
unref: () => void;
Set that while the timer is running, it should not keep the Node process running.
class BaseFilter
abstract class BaseFilter implements Filter {}
method receiveMessage
receiveMessage: (message: Promise<Buffer>) => Promise<Buffer>;
method receiveMetadata
receiveMetadata: (metadata: Metadata) => Metadata;
method receiveTrailers
receiveTrailers: (status: StatusObject) => StatusObject;
method sendMessage
sendMessage: (message: Promise<WriteObject>) => Promise<WriteObject>;
method sendMetadata
sendMetadata: (metadata: Promise<Metadata>) => Promise<Metadata>;
class BaseSubchannelWrapper
abstract class BaseSubchannelWrapper implements SubchannelInterface {}
constructor
constructor(child: SubchannelInterface);
property child
protected child: SubchannelInterface;
method addConnectivityStateListener
addConnectivityStateListener: (listener: ConnectivityStateListener) => void;
method addHealthStateWatcher
addHealthStateWatcher: (listener: HealthListener) => void;
method getAddress
getAddress: () => string;
method getChannelzRef
getChannelzRef: () => SubchannelRef;
method getConnectivityState
getConnectivityState: () => ConnectivityState;
method getRealSubchannel
getRealSubchannel: () => Subchannel;
method isHealthy
isHealthy: () => boolean;
method realSubchannelEquals
realSubchannelEquals: (other: SubchannelInterface) => boolean;
method ref
ref: () => void;
method removeConnectivityStateListener
removeConnectivityStateListener: (listener: ConnectivityStateListener) => void;
method removeHealthStateWatcher
removeHealthStateWatcher: (listener: HealthListener) => void;
method setHealthy
protected setHealthy: (healthy: boolean) => void;
method startConnecting
startConnecting: () => void;
method throttleKeepalive
throttleKeepalive: (newKeepaliveTime: number) => void;
method unref
unref: () => void;
class ChildLoadBalancerHandler
class ChildLoadBalancerHandler implements LoadBalancer {}
constructor
constructor( channelControlHelper: ChannelControlHelper, credentials: ChannelCredentials, options: ChannelOptions);
method configUpdateRequiresNewPolicyInstance
protected configUpdateRequiresNewPolicyInstance: ( oldConfig: TypedLoadBalancingConfig, newConfig: TypedLoadBalancingConfig) => boolean;
method destroy
destroy: () => void;
method exitIdle
exitIdle: () => void;
method getTypeName
getTypeName: () => string;
method resetBackoff
resetBackoff: () => void;
method updateAddressList
updateAddressList: ( endpointList: Endpoint[], lbConfig: TypedLoadBalancingConfig, attributes: { [key: string]: unknown }) => void;
Prerequisites: lbConfig !== null and lbConfig.name is registered
Parameter endpointList
Parameter lbConfig
Parameter attributes
class EndpointMap
class EndpointMap<ValueType> {}
property size
readonly size: number;
method clear
clear: () => void;
method delete
delete: (endpoint: Endpoint) => void;
method deleteMissing
deleteMissing: (endpoints: Endpoint[]) => ValueType[];
Delete any entries in this map with keys that are not in endpoints
Parameter endpoints
method entries
entries: () => IterableIterator<[Endpoint, ValueType]>;
method get
get: (endpoint: Endpoint) => ValueType | undefined;
method getForSubchannelAddress
getForSubchannelAddress: (address: SubchannelAddress) => ValueType | undefined;
method has
has: (endpoint: Endpoint) => boolean;
method keys
keys: () => IterableIterator<Endpoint>;
method set
set: (endpoint: Endpoint, mapEntry: ValueType) => void;
method values
values: () => IterableIterator<ValueType>;
class FileWatcherCertificateProvider
class FileWatcherCertificateProvider implements CertificateProvider {}
constructor
constructor(config: FileWatcherCertificateProviderConfig);
method addCaCertificateListener
addCaCertificateListener: (listener: CaCertificateUpdateListener) => void;
method addIdentityCertificateListener
addIdentityCertificateListener: ( listener: IdentityCertificateUpdateListener) => void;
method removeCaCertificateListener
removeCaCertificateListener: (listener: CaCertificateUpdateListener) => void;
method removeIdentityCertificateListener
removeIdentityCertificateListener: ( listener: IdentityCertificateUpdateListener) => void;
class FilterStackFactory
class FilterStackFactory implements FilterFactory<FilterStack> {}
constructor
constructor(factories: FilterFactory<Filter>[]);
method clone
clone: () => FilterStackFactory;
method createFilter
createFilter: () => FilterStack;
method push
push: (filterFactories: FilterFactory<Filter>[]) => void;
class LeafLoadBalancer
class LeafLoadBalancer {}
This class handles the leaf load balancing operations for a single endpoint. It is a thin wrapper around a PickFirstLoadBalancer with a different API that more closely reflects how it will be used as a leaf balancer.
constructor
constructor( endpoint: Endpoint, channelControlHelper: ChannelControlHelper, credentials: ChannelCredentials, options: ChannelOptions);
method destroy
destroy: () => void;
method exitIdle
exitIdle: () => void;
method getConnectivityState
getConnectivityState: () => ConnectivityState;
method getEndpoint
getEndpoint: () => Endpoint;
method getPicker
getPicker: () => Picker;
method startConnecting
startConnecting: () => void;
method updateEndpoint
updateEndpoint: (newEndpoint: Endpoint) => void;
Update the endpoint associated with this LeafLoadBalancer to a new endpoint. Does not trigger connection establishment if a connection attempt is not already in progress.
Parameter newEndpoint
class QueuePicker
class QueuePicker {}
A standard picker representing a load balancer in the IDLE or CONNECTING state. Always responds to every pick request with a QUEUE pick result indicating that the pick should be tried again with the next
Picker
. Also reports back to the load balancer that a connection should be established once any pick is attempted. If the childPicker is provided, delegate to it instead of returning the hardcoded QUEUE pick result, but still calls exitIdle.
constructor
constructor(loadBalancer: LoadBalancer, childPicker?: Picker);
method pick
pick: (pickArgs: PickArgs) => PickResult;
class UnavailablePicker
class UnavailablePicker implements Picker {}
A standard picker representing a load balancer in the TRANSIENT_FAILURE state. Always responds to every pick request with an UNAVAILABLE status.
constructor
constructor(status?: Partial<StatusObject>);
method pick
pick: (pickArgs: PickArgs) => TransientFailurePickResult;
interface CaCertificateUpdate
interface CaCertificateUpdate {}
property caCertificate
caCertificate: Buffer;
interface CaCertificateUpdateListener
interface CaCertificateUpdateListener {}
call signature
(update: CaCertificateUpdate | null): void;
interface CallStream
interface Call {}
method cancelWithStatus
cancelWithStatus: (status: Status, details: string) => void;
method getCallNumber
getCallNumber: () => number;
method getPeer
getPeer: () => string;
method halfClose
halfClose: () => void;
method sendMessageWithContext
sendMessageWithContext: (context: MessageContext, message: Buffer) => void;
method setCredentials
setCredentials: (credentials: CallCredentials) => void;
method start
start: (metadata: Metadata, listener: InterceptingListener) => void;
method startRead
startRead: () => void;
interface CertificateProvider
interface CertificateProvider {}
method addCaCertificateListener
addCaCertificateListener: (listener: CaCertificateUpdateListener) => void;
method addIdentityCertificateListener
addIdentityCertificateListener: ( listener: IdentityCertificateUpdateListener) => void;
method removeCaCertificateListener
removeCaCertificateListener: (listener: CaCertificateUpdateListener) => void;
method removeIdentityCertificateListener
removeIdentityCertificateListener: ( listener: IdentityCertificateUpdateListener) => void;
interface ChannelControlHelper
interface ChannelControlHelper {}
A collection of functions associated with a channel that a load balancer can call as necessary.
method addChannelzChild
addChannelzChild: (child: ChannelRef | SubchannelRef) => void;
method createSubchannel
createSubchannel: ( subchannelAddress: SubchannelAddress, subchannelArgs: ChannelOptions, credentialsOverride: ChannelCredentials | null) => SubchannelInterface;
Returns a subchannel connected to the specified address.
Parameter subchannelAddress
The address to connect to
Parameter subchannelArgs
Extra channel arguments specified by the load balancer
method removeChannelzChild
removeChannelzChild: (child: ChannelRef | SubchannelRef) => void;
method requestReresolution
requestReresolution: () => void;
Request new data from the resolver.
method updateState
updateState: (connectivityState: ConnectivityState, picker: Picker) => void;
Passes a new subchannel picker up to the channel. This is called if either the connectivity state changes or if a different picker is needed for any other reason.
Parameter connectivityState
New connectivity state
Parameter picker
New picker
interface ConfigSelector
interface ConfigSelector {}
Selects a configuration for a method given the name and metadata. Defined in https://github.com/grpc/proposal/blob/master/A31-xds-timeout-support-and-config-selector.md#new-functionality-in-grpc
call signature
(methodName: string, metadata: Metadata, channelId: number): CallConfig;
interface FailurePercentageEjectionConfig
interface FailurePercentageEjectionConfig {}
property enforcement_percentage
readonly enforcement_percentage: number;
property minimum_hosts
readonly minimum_hosts: number;
property request_volume
readonly request_volume: number;
property threshold
readonly threshold: number;
interface FileWatcherCertificateProviderConfig
interface FileWatcherCertificateProviderConfig {}
property caCertificateFile
caCertificateFile?: string | undefined;
property certificateFile
certificateFile?: string | undefined;
property privateKeyFile
privateKeyFile?: string | undefined;
property refreshIntervalMs
refreshIntervalMs: number;
interface Filter
interface Filter {}
Filter classes represent related per-call logic and state that is primarily used to modify incoming and outgoing data. All async filters can be rejected. The rejection error must be a StatusObject, and a rejection will cause the call to end with that status.
method receiveMessage
receiveMessage: (message: Promise<Buffer>) => Promise<Buffer>;
method receiveMetadata
receiveMetadata: (metadata: Metadata) => Metadata;
method receiveTrailers
receiveTrailers: (status: StatusObject) => StatusObject;
method sendMessage
sendMessage: (message: Promise<WriteObject>) => Promise<WriteObject>;
method sendMetadata
sendMetadata: (metadata: Promise<Metadata>) => Promise<Metadata>;
interface FilterFactory
interface FilterFactory<T extends Filter> {}
method createFilter
createFilter: () => T;
interface GrpcUri
interface GrpcUri {}
interface IdentityCertificateUpdate
interface IdentityCertificateUpdate {}
property certificate
certificate: Buffer;
property privateKey
privateKey: Buffer;
interface IdentityCertificateUpdateListener
interface IdentityCertificateUpdateListener {}
call signature
(update: IdentityCertificateUpdate | null): void;
interface LoadBalancer
interface LoadBalancer {}
Tracks one or more connected subchannels and determines which subchannel each request should use.
method destroy
destroy: () => void;
The load balancer unrefs all of its subchannels and stops calling methods of its channel control helper.
method exitIdle
exitIdle: () => void;
If the load balancer is currently in the IDLE state, start connecting.
method getTypeName
getTypeName: () => string;
Get the type name for this load balancer type. Must be constant across an entire load balancer implementation class and must match the name that the balancer implementation class was registered with.
method resetBackoff
resetBackoff: () => void;
If the load balancer is currently in the CONNECTING or TRANSIENT_FAILURE state, reset the current connection backoff timeout to its base value and transition to CONNECTING if in TRANSIENT_FAILURE.
method updateAddressList
updateAddressList: ( endpointList: Endpoint[], lbConfig: TypedLoadBalancingConfig, attributes: { [key: string]: unknown }) => void;
Gives the load balancer a new list of addresses to start connecting to. The load balancer will start establishing connections with the new list, but will continue using any existing connections until the new connections are established
Parameter endpointList
The new list of addresses to connect to
Parameter lbConfig
The load balancing config object from the service config, if one was provided
interface OutlierDetectionRawConfig
interface OutlierDetectionRawConfig {}
property base_ejection_time
base_ejection_time?: Duration;
property child_policy
child_policy: LoadBalancingConfig[];
property failure_percentage_ejection
failure_percentage_ejection?: Partial<FailurePercentageEjectionConfig>;
property interval
interval?: Duration;
property max_ejection_percent
max_ejection_percent?: number;
property max_ejection_time
max_ejection_time?: Duration;
property success_rate_ejection
success_rate_ejection?: Partial<SuccessRateEjectionConfig>;
interface PickArgs
interface PickArgs {}
property extraPickInfo
extraPickInfo: { [key: string]: string;};
property metadata
metadata: Metadata;
interface Picker
interface Picker {}
A proxy object representing the momentary state of a load balancer. Picks subchannels or returns other information based on that state. Should be replaced every time the load balancer changes state.
method pick
pick: (pickArgs: PickArgs) => PickResult;
interface PickResult
interface PickResult {}
property onCallEnded
onCallEnded: ((statusCode: Status) => void) | null;
property onCallStarted
onCallStarted: (() => void) | null;
property pickResultType
pickResultType: PickResultType;
property status
status: StatusObject | null;
The status object to end the call with. Populated if and only if
pickResultType
is TRANSIENT_FAILURE.
property subchannel
subchannel: SubchannelInterface | null;
The subchannel to use as the transport for the call. Only meaningful if
pickResultType
is COMPLETE. If null, indicates that the call should be dropped.
interface Resolver
interface Resolver {}
A resolver class that handles one or more of the name syntax schemes defined in the [gRPC Name Resolution document](https://github.com/grpc/grpc/blob/master/doc/naming.md)
method destroy
destroy: () => void;
Discard all resources owned by the resolver. A later call to
updateResolution
should reinitialize those resources. NoResolverListener
callbacks should be called afterdestroy
is called untilupdateResolution
is called again.
method updateResolution
updateResolution: () => void;
Indicates that the caller wants new name resolution data. Calling this function may eventually result in calling one of the
ResolverListener
functions, but that is not guaranteed. Those functions will never be called synchronously with the constructor or updateResolution.
interface ResolverListener
interface ResolverListener {}
A listener object passed to the resolver's constructor that provides name resolution updates back to the resolver's owner.
method onError
onError: (error: StatusObject) => void;
Called whenever a name resolution attempt fails.
Parameter error
Describes how resolution failed
method onSuccessfulResolution
onSuccessfulResolution: ( addressList: Endpoint[], serviceConfig: ServiceConfig | null, serviceConfigError: StatusObject | null, configSelector: ConfigSelector | null, attributes: { [key: string]: unknown }) => void;
Called whenever the resolver has new name resolution results to report
Parameter addressList
The new list of backend addresses
Parameter serviceConfig
The new service configuration corresponding to the
addressList
. Will benull
if no service configuration was retrieved or if the service configuration was invalidParameter serviceConfigError
If non-
null
, indicates that the retrieved service configuration was invalid
interface SubchannelInterface
interface SubchannelInterface {}
This is an interface for load balancing policies to use to interact with subchannels. This allows load balancing policies to wrap and unwrap subchannels.
Any load balancing policy that wraps subchannels must unwrap the subchannel in the picker, so that other load balancing policies consistently have access to their own wrapper objects.
method addConnectivityStateListener
addConnectivityStateListener: (listener: ConnectivityStateListener) => void;
method addHealthStateWatcher
addHealthStateWatcher: (listener: HealthListener) => void;
method getAddress
getAddress: () => string;
method getChannelzRef
getChannelzRef: () => SubchannelRef;
method getConnectivityState
getConnectivityState: () => ConnectivityState;
method getRealSubchannel
getRealSubchannel: () => Subchannel;
If this is a wrapper, return the wrapped subchannel, otherwise return this
method isHealthy
isHealthy: () => boolean;
method realSubchannelEquals
realSubchannelEquals: (other: SubchannelInterface) => boolean;
Returns true if this and other both proxy the same underlying subchannel. Can be used instead of directly accessing getRealSubchannel to allow mocks to avoid implementing getRealSubchannel
method ref
ref: () => void;
method removeConnectivityStateListener
removeConnectivityStateListener: (listener: ConnectivityStateListener) => void;
method removeHealthStateWatcher
removeHealthStateWatcher: (listener: HealthListener) => void;
method startConnecting
startConnecting: () => void;
method throttleKeepalive
throttleKeepalive: (newKeepaliveTime: number) => void;
method unref
unref: () => void;
interface SuccessRateEjectionConfig
interface SuccessRateEjectionConfig {}
property enforcement_percentage
readonly enforcement_percentage: number;
property minimum_hosts
readonly minimum_hosts: number;
property request_volume
readonly request_volume: number;
property stdev_factor
readonly stdev_factor: number;
interface TypedLoadBalancingConfig
interface TypedLoadBalancingConfig {}
method getLoadBalancerName
getLoadBalancerName: () => string;
method toJsonObject
toJsonObject: () => object;
enum PickResultType
enum PickResultType { COMPLETE = 0, QUEUE = 1, TRANSIENT_FAILURE = 2, DROP = 3,}
member COMPLETE
COMPLETE = 0
member DROP
DROP = 3
member QUEUE
QUEUE = 1
member TRANSIENT_FAILURE
TRANSIENT_FAILURE = 2
type ConnectivityStateListener
type ConnectivityStateListener = ( subchannel: SubchannelInterface, previousState: ConnectivityState, newState: ConnectivityState, keepaliveTime: number, errorMessage?: string) => void;
type HealthListener
type HealthListener = (healthy: boolean) => void;
type SubchannelAddress
type SubchannelAddress = TcpSubchannelAddress | IpcSubchannelAddress;
This represents a single backend address to connect to. This interface is a subset of net.SocketConnectOpts, i.e. the options described at https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener. Those are in turn a subset of the options that can be passed to http2.connect.
Package Files (39)
- build/src/admin.d.ts
- build/src/backoff-timeout.d.ts
- build/src/call-credentials.d.ts
- build/src/call-interface.d.ts
- build/src/call.d.ts
- build/src/certificate-provider.d.ts
- build/src/channel-credentials.d.ts
- build/src/channel-options.d.ts
- build/src/channel.d.ts
- build/src/channelz.d.ts
- build/src/client-interceptors.d.ts
- build/src/client.d.ts
- build/src/compression-algorithms.d.ts
- build/src/connectivity-state.d.ts
- build/src/constants.d.ts
- build/src/deadline.d.ts
- build/src/duration.d.ts
- build/src/experimental.d.ts
- build/src/filter-stack.d.ts
- build/src/filter.d.ts
- build/src/index.d.ts
- build/src/load-balancer-child-handler.d.ts
- build/src/load-balancer-outlier-detection.d.ts
- build/src/load-balancer-pick-first.d.ts
- build/src/load-balancer.d.ts
- build/src/logging.d.ts
- build/src/make-client.d.ts
- build/src/metadata.d.ts
- build/src/picker.d.ts
- build/src/resolver.d.ts
- build/src/server-call.d.ts
- build/src/server-credentials.d.ts
- build/src/server-interceptors.d.ts
- build/src/server.d.ts
- build/src/service-config.d.ts
- build/src/status-builder.d.ts
- build/src/subchannel-address.d.ts
- build/src/subchannel-interface.d.ts
- build/src/uri-parser.d.ts
Dependencies (2)
Dev Dependencies (30)
- @grpc/proto-loader
- @types/gulp
- @types/gulp-mocha
- @types/lodash
- @types/mocha
- @types/ncp
- @types/node
- @types/pify
- @types/semver
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- @typescript-eslint/typescript-estree
- clang-format
- eslint
- eslint-config-prettier
- eslint-plugin-node
- eslint-plugin-prettier
- execa
- gulp
- gulp-mocha
- lodash
- madge
- mocha-jenkins-reporter
- ncp
- pify
- prettier
- rimraf
- semver
- ts-node
- typescript
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@grpc/grpc-js
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@grpc/grpc-js)
- HTML<a href="https://www.jsdocs.io/package/@grpc/grpc-js"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 12561 ms. - Missing or incorrect documentation? Open an issue for this package.