@reptilestyle/grpc-js 1.9.14-compression.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +79 -0
- package/build/src/admin.d.ts +11 -0
- package/build/src/admin.js +30 -0
- package/build/src/admin.js.map +1 -0
- package/build/src/backoff-timeout.d.ts +90 -0
- package/build/src/backoff-timeout.js +174 -0
- package/build/src/backoff-timeout.js.map +1 -0
- package/build/src/call-credentials.d.ts +56 -0
- package/build/src/call-credentials.js +153 -0
- package/build/src/call-credentials.js.map +1 -0
- package/build/src/call-interface.d.ts +85 -0
- package/build/src/call-interface.js +84 -0
- package/build/src/call-interface.js.map +1 -0
- package/build/src/call-number.d.ts +1 -0
- package/build/src/call-number.js +24 -0
- package/build/src/call-number.js.map +1 -0
- package/build/src/call.d.ts +80 -0
- package/build/src/call.js +136 -0
- package/build/src/call.js.map +1 -0
- package/build/src/channel-credentials.d.ts +81 -0
- package/build/src/channel-credentials.js +177 -0
- package/build/src/channel-credentials.js.map +1 -0
- package/build/src/channel-options.d.ts +72 -0
- package/build/src/channel-options.js +69 -0
- package/build/src/channel-options.js.map +1 -0
- package/build/src/channel.d.ts +76 -0
- package/build/src/channel.js +68 -0
- package/build/src/channel.js.map +1 -0
- package/build/src/channelz.d.ts +108 -0
- package/build/src/channelz.js +637 -0
- package/build/src/channelz.js.map +1 -0
- package/build/src/client-interceptors.d.ts +120 -0
- package/build/src/client-interceptors.js +428 -0
- package/build/src/client-interceptors.js.map +1 -0
- package/build/src/client.d.ts +74 -0
- package/build/src/client.js +431 -0
- package/build/src/client.js.map +1 -0
- package/build/src/compression-algorithms.d.ts +5 -0
- package/build/src/compression-algorithms.js +26 -0
- package/build/src/compression-algorithms.js.map +1 -0
- package/build/src/compression-filter.d.ts +26 -0
- package/build/src/compression-filter.js +257 -0
- package/build/src/compression-filter.js.map +1 -0
- package/build/src/connectivity-state.d.ts +7 -0
- package/build/src/connectivity-state.js +28 -0
- package/build/src/connectivity-state.js.map +1 -0
- package/build/src/constants.d.ts +38 -0
- package/build/src/constants.js +64 -0
- package/build/src/constants.js.map +1 -0
- package/build/src/control-plane-status.d.ts +5 -0
- package/build/src/control-plane-status.js +42 -0
- package/build/src/control-plane-status.js.map +1 -0
- package/build/src/deadline.d.ts +14 -0
- package/build/src/deadline.js +97 -0
- package/build/src/deadline.js.map +1 -0
- package/build/src/duration.d.ts +7 -0
- package/build/src/duration.js +34 -0
- package/build/src/duration.js.map +1 -0
- package/build/src/error.d.ts +2 -0
- package/build/src/error.js +40 -0
- package/build/src/error.js.map +1 -0
- package/build/src/events.d.ts +9 -0
- package/build/src/events.js +19 -0
- package/build/src/events.js.map +1 -0
- package/build/src/experimental.d.ts +16 -0
- package/build/src/experimental.js +39 -0
- package/build/src/experimental.js.map +1 -0
- package/build/src/filter-stack.d.ts +21 -0
- package/build/src/filter-stack.js +82 -0
- package/build/src/filter-stack.js.map +1 -0
- package/build/src/filter.d.ts +25 -0
- package/build/src/filter.js +38 -0
- package/build/src/filter.js.map +1 -0
- package/build/src/generated/channelz.d.ts +72 -0
- package/build/src/generated/channelz.js +3 -0
- package/build/src/generated/channelz.js.map +1 -0
- package/build/src/generated/google/protobuf/Any.d.ts +9 -0
- package/build/src/generated/google/protobuf/Any.js +4 -0
- package/build/src/generated/google/protobuf/Any.js.map +1 -0
- package/build/src/generated/google/protobuf/BoolValue.d.ts +6 -0
- package/build/src/generated/google/protobuf/BoolValue.js +4 -0
- package/build/src/generated/google/protobuf/BoolValue.js.map +1 -0
- package/build/src/generated/google/protobuf/BytesValue.d.ts +6 -0
- package/build/src/generated/google/protobuf/BytesValue.js +4 -0
- package/build/src/generated/google/protobuf/BytesValue.js.map +1 -0
- package/build/src/generated/google/protobuf/DoubleValue.d.ts +6 -0
- package/build/src/generated/google/protobuf/DoubleValue.js +4 -0
- package/build/src/generated/google/protobuf/DoubleValue.js.map +1 -0
- package/build/src/generated/google/protobuf/Duration.d.ts +9 -0
- package/build/src/generated/google/protobuf/Duration.js +4 -0
- package/build/src/generated/google/protobuf/Duration.js.map +1 -0
- package/build/src/generated/google/protobuf/FloatValue.d.ts +6 -0
- package/build/src/generated/google/protobuf/FloatValue.js +4 -0
- package/build/src/generated/google/protobuf/FloatValue.js.map +1 -0
- package/build/src/generated/google/protobuf/Int32Value.d.ts +6 -0
- package/build/src/generated/google/protobuf/Int32Value.js +4 -0
- package/build/src/generated/google/protobuf/Int32Value.js.map +1 -0
- package/build/src/generated/google/protobuf/Int64Value.d.ts +7 -0
- package/build/src/generated/google/protobuf/Int64Value.js +4 -0
- package/build/src/generated/google/protobuf/Int64Value.js.map +1 -0
- package/build/src/generated/google/protobuf/StringValue.d.ts +6 -0
- package/build/src/generated/google/protobuf/StringValue.js +4 -0
- package/build/src/generated/google/protobuf/StringValue.js.map +1 -0
- package/build/src/generated/google/protobuf/Timestamp.d.ts +9 -0
- package/build/src/generated/google/protobuf/Timestamp.js +4 -0
- package/build/src/generated/google/protobuf/Timestamp.js.map +1 -0
- package/build/src/generated/google/protobuf/UInt32Value.d.ts +6 -0
- package/build/src/generated/google/protobuf/UInt32Value.js +4 -0
- package/build/src/generated/google/protobuf/UInt32Value.js.map +1 -0
- package/build/src/generated/google/protobuf/UInt64Value.d.ts +7 -0
- package/build/src/generated/google/protobuf/UInt64Value.js +4 -0
- package/build/src/generated/google/protobuf/UInt64Value.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/Address.d.ts +79 -0
- package/build/src/generated/grpc/channelz/v1/Address.js +4 -0
- package/build/src/generated/grpc/channelz/v1/Address.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/Channel.d.ts +64 -0
- package/build/src/generated/grpc/channelz/v1/Channel.js +4 -0
- package/build/src/generated/grpc/channelz/v1/Channel.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/ChannelConnectivityState.d.ts +24 -0
- package/build/src/generated/grpc/channelz/v1/ChannelConnectivityState.js +14 -0
- package/build/src/generated/grpc/channelz/v1/ChannelConnectivityState.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/ChannelData.d.ts +72 -0
- package/build/src/generated/grpc/channelz/v1/ChannelData.js +4 -0
- package/build/src/generated/grpc/channelz/v1/ChannelData.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/ChannelRef.d.ts +27 -0
- package/build/src/generated/grpc/channelz/v1/ChannelRef.js +4 -0
- package/build/src/generated/grpc/channelz/v1/ChannelRef.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/ChannelTrace.d.ts +41 -0
- package/build/src/generated/grpc/channelz/v1/ChannelTrace.js +4 -0
- package/build/src/generated/grpc/channelz/v1/ChannelTrace.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/ChannelTraceEvent.d.ts +74 -0
- package/build/src/generated/grpc/channelz/v1/ChannelTraceEvent.js +15 -0
- package/build/src/generated/grpc/channelz/v1/ChannelTraceEvent.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/Channelz.d.ts +159 -0
- package/build/src/generated/grpc/channelz/v1/Channelz.js +4 -0
- package/build/src/generated/grpc/channelz/v1/Channelz.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetChannelRequest.d.ts +13 -0
- package/build/src/generated/grpc/channelz/v1/GetChannelRequest.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetChannelRequest.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetChannelResponse.d.ts +15 -0
- package/build/src/generated/grpc/channelz/v1/GetChannelResponse.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetChannelResponse.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetServerRequest.d.ts +13 -0
- package/build/src/generated/grpc/channelz/v1/GetServerRequest.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetServerRequest.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetServerResponse.d.ts +15 -0
- package/build/src/generated/grpc/channelz/v1/GetServerResponse.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetServerResponse.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetServerSocketsRequest.d.ts +35 -0
- package/build/src/generated/grpc/channelz/v1/GetServerSocketsRequest.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetServerSocketsRequest.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetServerSocketsResponse.d.ts +29 -0
- package/build/src/generated/grpc/channelz/v1/GetServerSocketsResponse.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetServerSocketsResponse.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetServersRequest.d.ts +33 -0
- package/build/src/generated/grpc/channelz/v1/GetServersRequest.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetServersRequest.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetServersResponse.d.ts +29 -0
- package/build/src/generated/grpc/channelz/v1/GetServersResponse.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetServersResponse.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetSocketRequest.d.ts +25 -0
- package/build/src/generated/grpc/channelz/v1/GetSocketRequest.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetSocketRequest.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetSocketResponse.d.ts +15 -0
- package/build/src/generated/grpc/channelz/v1/GetSocketResponse.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetSocketResponse.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetSubchannelRequest.d.ts +13 -0
- package/build/src/generated/grpc/channelz/v1/GetSubchannelRequest.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetSubchannelRequest.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetSubchannelResponse.d.ts +15 -0
- package/build/src/generated/grpc/channelz/v1/GetSubchannelResponse.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetSubchannelResponse.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetTopChannelsRequest.d.ts +33 -0
- package/build/src/generated/grpc/channelz/v1/GetTopChannelsRequest.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetTopChannelsRequest.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/GetTopChannelsResponse.d.ts +29 -0
- package/build/src/generated/grpc/channelz/v1/GetTopChannelsResponse.js +4 -0
- package/build/src/generated/grpc/channelz/v1/GetTopChannelsResponse.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/Security.d.ts +79 -0
- package/build/src/generated/grpc/channelz/v1/Security.js +4 -0
- package/build/src/generated/grpc/channelz/v1/Security.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/Server.d.ts +41 -0
- package/build/src/generated/grpc/channelz/v1/Server.js +4 -0
- package/build/src/generated/grpc/channelz/v1/Server.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/ServerData.d.ts +53 -0
- package/build/src/generated/grpc/channelz/v1/ServerData.js +4 -0
- package/build/src/generated/grpc/channelz/v1/ServerData.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/ServerRef.d.ts +27 -0
- package/build/src/generated/grpc/channelz/v1/ServerRef.js +4 -0
- package/build/src/generated/grpc/channelz/v1/ServerRef.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/Socket.d.ts +66 -0
- package/build/src/generated/grpc/channelz/v1/Socket.js +4 -0
- package/build/src/generated/grpc/channelz/v1/Socket.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/SocketData.d.ts +146 -0
- package/build/src/generated/grpc/channelz/v1/SocketData.js +4 -0
- package/build/src/generated/grpc/channelz/v1/SocketData.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/SocketOption.d.ts +43 -0
- package/build/src/generated/grpc/channelz/v1/SocketOption.js +4 -0
- package/build/src/generated/grpc/channelz/v1/SocketOption.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionLinger.d.ts +29 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionLinger.js +4 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionLinger.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionTcpInfo.d.ts +70 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionTcpInfo.js +4 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionTcpInfo.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionTimeout.d.ts +15 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionTimeout.js +4 -0
- package/build/src/generated/grpc/channelz/v1/SocketOptionTimeout.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/SocketRef.d.ts +27 -0
- package/build/src/generated/grpc/channelz/v1/SocketRef.js +4 -0
- package/build/src/generated/grpc/channelz/v1/SocketRef.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/Subchannel.d.ts +66 -0
- package/build/src/generated/grpc/channelz/v1/Subchannel.js +4 -0
- package/build/src/generated/grpc/channelz/v1/Subchannel.js.map +1 -0
- package/build/src/generated/grpc/channelz/v1/SubchannelRef.d.ts +27 -0
- package/build/src/generated/grpc/channelz/v1/SubchannelRef.js +4 -0
- package/build/src/generated/grpc/channelz/v1/SubchannelRef.js.map +1 -0
- package/build/src/http_proxy.d.ts +15 -0
- package/build/src/http_proxy.js +259 -0
- package/build/src/http_proxy.js.map +1 -0
- package/build/src/index.d.ts +76 -0
- package/build/src/index.js +140 -0
- package/build/src/index.js.map +1 -0
- package/build/src/internal-channel.d.ts +118 -0
- package/build/src/internal-channel.js +535 -0
- package/build/src/internal-channel.js.map +1 -0
- package/build/src/load-balancer-child-handler.d.ts +24 -0
- package/build/src/load-balancer-child-handler.js +151 -0
- package/build/src/load-balancer-child-handler.js.map +1 -0
- package/build/src/load-balancer-outlier-detection.d.ts +61 -0
- package/build/src/load-balancer-outlier-detection.js +608 -0
- package/build/src/load-balancer-outlier-detection.js.map +1 -0
- package/build/src/load-balancer-pick-first.d.ts +97 -0
- package/build/src/load-balancer-pick-first.js +393 -0
- package/build/src/load-balancer-pick-first.js.map +1 -0
- package/build/src/load-balancer-round-robin.d.ts +21 -0
- package/build/src/load-balancer-round-robin.js +174 -0
- package/build/src/load-balancer-round-robin.js.map +1 -0
- package/build/src/load-balancer.d.ts +97 -0
- package/build/src/load-balancer.js +102 -0
- package/build/src/load-balancer.js.map +1 -0
- package/build/src/load-balancing-call.d.ts +44 -0
- package/build/src/load-balancing-call.js +269 -0
- package/build/src/load-balancing-call.js.map +1 -0
- package/build/src/logging.d.ts +7 -0
- package/build/src/logging.js +114 -0
- package/build/src/logging.js.map +1 -0
- package/build/src/make-client.d.ts +71 -0
- package/build/src/make-client.js +143 -0
- package/build/src/make-client.js.map +1 -0
- package/build/src/max-message-size-filter.d.ts +15 -0
- package/build/src/max-message-size-filter.js +86 -0
- package/build/src/max-message-size-filter.js.map +1 -0
- package/build/src/metadata.d.ts +84 -0
- package/build/src/metadata.js +249 -0
- package/build/src/metadata.js.map +1 -0
- package/build/src/object-stream.d.ts +27 -0
- package/build/src/object-stream.js +19 -0
- package/build/src/object-stream.js.map +1 -0
- package/build/src/picker.d.ts +91 -0
- package/build/src/picker.js +78 -0
- package/build/src/picker.js.map +1 -0
- package/build/src/resolver-dns.d.ts +13 -0
- package/build/src/resolver-dns.js +328 -0
- package/build/src/resolver-dns.js.map +1 -0
- package/build/src/resolver-ip.d.ts +1 -0
- package/build/src/resolver-ip.js +104 -0
- package/build/src/resolver-ip.js.map +1 -0
- package/build/src/resolver-uds.d.ts +1 -0
- package/build/src/resolver-uds.js +50 -0
- package/build/src/resolver-uds.js.map +1 -0
- package/build/src/resolver.d.ts +105 -0
- package/build/src/resolver.js +87 -0
- package/build/src/resolver.js.map +1 -0
- package/build/src/resolving-call.d.ts +44 -0
- package/build/src/resolving-call.js +273 -0
- package/build/src/resolving-call.js.map +1 -0
- package/build/src/resolving-load-balancer.d.ts +67 -0
- package/build/src/resolving-load-balancer.js +304 -0
- package/build/src/resolving-load-balancer.js.map +1 -0
- package/build/src/retrying-call.d.ts +94 -0
- package/build/src/retrying-call.js +639 -0
- package/build/src/retrying-call.js.map +1 -0
- package/build/src/server-call.d.ts +159 -0
- package/build/src/server-call.js +700 -0
- package/build/src/server-call.js.map +1 -0
- package/build/src/server-credentials.d.ts +11 -0
- package/build/src/server-credentials.js +81 -0
- package/build/src/server-credentials.js.map +1 -0
- package/build/src/server.d.ts +56 -0
- package/build/src/server.js +892 -0
- package/build/src/server.js.map +1 -0
- package/build/src/service-config.d.ts +56 -0
- package/build/src/service-config.js +416 -0
- package/build/src/service-config.js.map +1 -0
- package/build/src/status-builder.d.ts +28 -0
- package/build/src/status-builder.js +68 -0
- package/build/src/status-builder.js.map +1 -0
- package/build/src/stream-decoder.d.ts +10 -0
- package/build/src/stream-decoder.js +96 -0
- package/build/src/stream-decoder.js.map +1 -0
- package/build/src/subchannel-address.d.ts +18 -0
- package/build/src/subchannel-address.js +65 -0
- package/build/src/subchannel-address.js.map +1 -0
- package/build/src/subchannel-call.d.ts +61 -0
- package/build/src/subchannel-call.js +461 -0
- package/build/src/subchannel-call.js.map +1 -0
- package/build/src/subchannel-interface.d.ts +49 -0
- package/build/src/subchannel-interface.js +59 -0
- package/build/src/subchannel-interface.js.map +1 -0
- package/build/src/subchannel-pool.d.ts +40 -0
- package/build/src/subchannel-pool.js +137 -0
- package/build/src/subchannel-pool.js.map +1 -0
- package/build/src/subchannel.d.ts +119 -0
- package/build/src/subchannel.js +353 -0
- package/build/src/subchannel.js.map +1 -0
- package/build/src/tls-helpers.d.ts +2 -0
- package/build/src/tls-helpers.js +34 -0
- package/build/src/tls-helpers.js.map +1 -0
- package/build/src/transport.d.ts +130 -0
- package/build/src/transport.js +640 -0
- package/build/src/transport.js.map +1 -0
- package/build/src/uri-parser.d.ts +12 -0
- package/build/src/uri-parser.js +110 -0
- package/build/src/uri-parser.js.map +1 -0
- package/package.json +85 -0
- package/proto/channelz.proto +564 -0
- package/src/admin.ts +45 -0
- package/src/backoff-timeout.ts +196 -0
- package/src/call-credentials.ts +226 -0
- package/src/call-interface.ts +173 -0
- package/src/call-number.ts +22 -0
- package/src/call.ts +200 -0
- package/src/channel-credentials.ts +267 -0
- package/src/channel-options.ts +119 -0
- package/src/channel.ts +174 -0
- package/src/channelz.ts +886 -0
- package/src/client-interceptors.ts +577 -0
- package/src/client.ts +715 -0
- package/src/compression-algorithms.ts +22 -0
- package/src/compression-filter.ts +315 -0
- package/src/connectivity-state.ts +24 -0
- package/src/constants.ts +66 -0
- package/src/control-plane-status.ts +43 -0
- package/src/deadline.ts +95 -0
- package/src/duration.ts +36 -0
- package/src/error.ts +37 -0
- package/src/events.ts +26 -0
- package/src/experimental.ts +48 -0
- package/src/filter-stack.ts +100 -0
- package/src/filter.ts +63 -0
- package/src/generated/channelz.ts +73 -0
- package/src/generated/google/protobuf/Any.ts +13 -0
- package/src/generated/google/protobuf/BoolValue.ts +10 -0
- package/src/generated/google/protobuf/BytesValue.ts +10 -0
- package/src/generated/google/protobuf/DoubleValue.ts +10 -0
- package/src/generated/google/protobuf/Duration.ts +13 -0
- package/src/generated/google/protobuf/FloatValue.ts +10 -0
- package/src/generated/google/protobuf/Int32Value.ts +10 -0
- package/src/generated/google/protobuf/Int64Value.ts +11 -0
- package/src/generated/google/protobuf/StringValue.ts +10 -0
- package/src/generated/google/protobuf/Timestamp.ts +13 -0
- package/src/generated/google/protobuf/UInt32Value.ts +10 -0
- package/src/generated/google/protobuf/UInt64Value.ts +11 -0
- package/src/generated/grpc/channelz/v1/Address.ts +89 -0
- package/src/generated/grpc/channelz/v1/Channel.ts +68 -0
- package/src/generated/grpc/channelz/v1/ChannelConnectivityState.ts +45 -0
- package/src/generated/grpc/channelz/v1/ChannelData.ts +76 -0
- package/src/generated/grpc/channelz/v1/ChannelRef.ts +31 -0
- package/src/generated/grpc/channelz/v1/ChannelTrace.ts +45 -0
- package/src/generated/grpc/channelz/v1/ChannelTraceEvent.ts +91 -0
- package/src/generated/grpc/channelz/v1/Channelz.ts +178 -0
- package/src/generated/grpc/channelz/v1/GetChannelRequest.ts +17 -0
- package/src/generated/grpc/channelz/v1/GetChannelResponse.ts +19 -0
- package/src/generated/grpc/channelz/v1/GetServerRequest.ts +17 -0
- package/src/generated/grpc/channelz/v1/GetServerResponse.ts +19 -0
- package/src/generated/grpc/channelz/v1/GetServerSocketsRequest.ts +39 -0
- package/src/generated/grpc/channelz/v1/GetServerSocketsResponse.ts +33 -0
- package/src/generated/grpc/channelz/v1/GetServersRequest.ts +37 -0
- package/src/generated/grpc/channelz/v1/GetServersResponse.ts +33 -0
- package/src/generated/grpc/channelz/v1/GetSocketRequest.ts +29 -0
- package/src/generated/grpc/channelz/v1/GetSocketResponse.ts +19 -0
- package/src/generated/grpc/channelz/v1/GetSubchannelRequest.ts +17 -0
- package/src/generated/grpc/channelz/v1/GetSubchannelResponse.ts +19 -0
- package/src/generated/grpc/channelz/v1/GetTopChannelsRequest.ts +37 -0
- package/src/generated/grpc/channelz/v1/GetTopChannelsResponse.ts +33 -0
- package/src/generated/grpc/channelz/v1/Security.ts +87 -0
- package/src/generated/grpc/channelz/v1/Server.ts +45 -0
- package/src/generated/grpc/channelz/v1/ServerData.ts +57 -0
- package/src/generated/grpc/channelz/v1/ServerRef.ts +31 -0
- package/src/generated/grpc/channelz/v1/Socket.ts +70 -0
- package/src/generated/grpc/channelz/v1/SocketData.ts +150 -0
- package/src/generated/grpc/channelz/v1/SocketOption.ts +47 -0
- package/src/generated/grpc/channelz/v1/SocketOptionLinger.ts +33 -0
- package/src/generated/grpc/channelz/v1/SocketOptionTcpInfo.ts +74 -0
- package/src/generated/grpc/channelz/v1/SocketOptionTimeout.ts +19 -0
- package/src/generated/grpc/channelz/v1/SocketRef.ts +31 -0
- package/src/generated/grpc/channelz/v1/Subchannel.ts +70 -0
- package/src/generated/grpc/channelz/v1/SubchannelRef.ts +31 -0
- package/src/http_proxy.ts +311 -0
- package/src/index.ts +284 -0
- package/src/internal-channel.ts +832 -0
- package/src/load-balancer-child-handler.ts +169 -0
- package/src/load-balancer-outlier-detection.ts +882 -0
- package/src/load-balancer-pick-first.ts +487 -0
- package/src/load-balancer-round-robin.ts +249 -0
- package/src/load-balancer.ts +230 -0
- package/src/load-balancing-call.ts +351 -0
- package/src/logging.ts +123 -0
- package/src/make-client.ts +238 -0
- package/src/max-message-size-filter.ts +88 -0
- package/src/metadata.ts +298 -0
- package/src/object-stream.ts +66 -0
- package/src/picker.ts +146 -0
- package/src/resolver-dns.ts +412 -0
- package/src/resolver-ip.ts +120 -0
- package/src/resolver-uds.ts +63 -0
- package/src/resolver.ts +180 -0
- package/src/resolving-call.ts +331 -0
- package/src/resolving-load-balancer.ts +403 -0
- package/src/retrying-call.ts +821 -0
- package/src/server-call.ts +1033 -0
- package/src/server-credentials.ts +108 -0
- package/src/server.ts +1300 -0
- package/src/service-config.ts +542 -0
- package/src/status-builder.ts +80 -0
- package/src/stream-decoder.ts +105 -0
- package/src/subchannel-address.ts +88 -0
- package/src/subchannel-call.ts +539 -0
- package/src/subchannel-interface.ts +97 -0
- package/src/subchannel-pool.ts +176 -0
- package/src/subchannel.ts +482 -0
- package/src/tls-helpers.ts +35 -0
- package/src/transport.ts +824 -0
- package/src/uri-parser.ts +114 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2019 gRPC authors.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { ChannelOptions, channelOptionsEqual } from './channel-options';
|
|
19
|
+
import { Subchannel } from './subchannel';
|
|
20
|
+
import {
|
|
21
|
+
SubchannelAddress,
|
|
22
|
+
subchannelAddressEqual,
|
|
23
|
+
} from './subchannel-address';
|
|
24
|
+
import { ChannelCredentials } from './channel-credentials';
|
|
25
|
+
import { GrpcUri, uriToString } from './uri-parser';
|
|
26
|
+
import { Http2SubchannelConnector } from './transport';
|
|
27
|
+
|
|
28
|
+
// 10 seconds in milliseconds. This value is arbitrary.
|
|
29
|
+
/**
|
|
30
|
+
* The amount of time in between checks for dropping subchannels that have no
|
|
31
|
+
* other references
|
|
32
|
+
*/
|
|
33
|
+
const REF_CHECK_INTERVAL = 10_000;
|
|
34
|
+
|
|
35
|
+
export class SubchannelPool {
|
|
36
|
+
private pool: {
|
|
37
|
+
[channelTarget: string]: Array<{
|
|
38
|
+
subchannelAddress: SubchannelAddress;
|
|
39
|
+
channelArguments: ChannelOptions;
|
|
40
|
+
channelCredentials: ChannelCredentials;
|
|
41
|
+
subchannel: Subchannel;
|
|
42
|
+
}>;
|
|
43
|
+
} = Object.create(null);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A timer of a task performing a periodic subchannel cleanup.
|
|
47
|
+
*/
|
|
48
|
+
private cleanupTimer: NodeJS.Timeout | null = null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A pool of subchannels use for making connections. Subchannels with the
|
|
52
|
+
* exact same parameters will be reused.
|
|
53
|
+
*/
|
|
54
|
+
constructor() {}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Unrefs all unused subchannels and cancels the cleanup task if all
|
|
58
|
+
* subchannels have been unrefed.
|
|
59
|
+
*/
|
|
60
|
+
unrefUnusedSubchannels(): void {
|
|
61
|
+
let allSubchannelsUnrefed = true;
|
|
62
|
+
|
|
63
|
+
/* These objects are created with Object.create(null), so they do not
|
|
64
|
+
* have a prototype, which means that for (... in ...) loops over them
|
|
65
|
+
* do not need to be filtered */
|
|
66
|
+
// eslint-disable-disable-next-line:forin
|
|
67
|
+
for (const channelTarget in this.pool) {
|
|
68
|
+
const subchannelObjArray = this.pool[channelTarget];
|
|
69
|
+
|
|
70
|
+
const refedSubchannels = subchannelObjArray.filter(
|
|
71
|
+
value => !value.subchannel.unrefIfOneRef()
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (refedSubchannels.length > 0) {
|
|
75
|
+
allSubchannelsUnrefed = false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* For each subchannel in the pool, try to unref it if it has
|
|
79
|
+
* exactly one ref (which is the ref from the pool itself). If that
|
|
80
|
+
* does happen, remove the subchannel from the pool */
|
|
81
|
+
this.pool[channelTarget] = refedSubchannels;
|
|
82
|
+
}
|
|
83
|
+
/* Currently we do not delete keys with empty values. If that results
|
|
84
|
+
* in significant memory usage we should change it. */
|
|
85
|
+
|
|
86
|
+
// Cancel the cleanup task if all subchannels have been unrefed.
|
|
87
|
+
if (allSubchannelsUnrefed && this.cleanupTimer !== null) {
|
|
88
|
+
clearInterval(this.cleanupTimer);
|
|
89
|
+
this.cleanupTimer = null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Ensures that the cleanup task is spawned.
|
|
95
|
+
*/
|
|
96
|
+
ensureCleanupTask(): void {
|
|
97
|
+
if (this.cleanupTimer === null) {
|
|
98
|
+
this.cleanupTimer = setInterval(() => {
|
|
99
|
+
this.unrefUnusedSubchannels();
|
|
100
|
+
}, REF_CHECK_INTERVAL);
|
|
101
|
+
|
|
102
|
+
// Unref because this timer should not keep the event loop running.
|
|
103
|
+
// Call unref only if it exists to address electron/electron#21162
|
|
104
|
+
this.cleanupTimer.unref?.();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Get a subchannel if one already exists with exactly matching parameters.
|
|
110
|
+
* Otherwise, create and save a subchannel with those parameters.
|
|
111
|
+
* @param channelTarget
|
|
112
|
+
* @param subchannelTarget
|
|
113
|
+
* @param channelArguments
|
|
114
|
+
* @param channelCredentials
|
|
115
|
+
*/
|
|
116
|
+
getOrCreateSubchannel(
|
|
117
|
+
channelTargetUri: GrpcUri,
|
|
118
|
+
subchannelTarget: SubchannelAddress,
|
|
119
|
+
channelArguments: ChannelOptions,
|
|
120
|
+
channelCredentials: ChannelCredentials
|
|
121
|
+
): Subchannel {
|
|
122
|
+
this.ensureCleanupTask();
|
|
123
|
+
const channelTarget = uriToString(channelTargetUri);
|
|
124
|
+
if (channelTarget in this.pool) {
|
|
125
|
+
const subchannelObjArray = this.pool[channelTarget];
|
|
126
|
+
for (const subchannelObj of subchannelObjArray) {
|
|
127
|
+
if (
|
|
128
|
+
subchannelAddressEqual(
|
|
129
|
+
subchannelTarget,
|
|
130
|
+
subchannelObj.subchannelAddress
|
|
131
|
+
) &&
|
|
132
|
+
channelOptionsEqual(
|
|
133
|
+
channelArguments,
|
|
134
|
+
subchannelObj.channelArguments
|
|
135
|
+
) &&
|
|
136
|
+
channelCredentials._equals(subchannelObj.channelCredentials)
|
|
137
|
+
) {
|
|
138
|
+
return subchannelObj.subchannel;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// If we get here, no matching subchannel was found
|
|
143
|
+
const subchannel = new Subchannel(
|
|
144
|
+
channelTargetUri,
|
|
145
|
+
subchannelTarget,
|
|
146
|
+
channelArguments,
|
|
147
|
+
channelCredentials,
|
|
148
|
+
new Http2SubchannelConnector(channelTargetUri)
|
|
149
|
+
);
|
|
150
|
+
if (!(channelTarget in this.pool)) {
|
|
151
|
+
this.pool[channelTarget] = [];
|
|
152
|
+
}
|
|
153
|
+
this.pool[channelTarget].push({
|
|
154
|
+
subchannelAddress: subchannelTarget,
|
|
155
|
+
channelArguments,
|
|
156
|
+
channelCredentials,
|
|
157
|
+
subchannel,
|
|
158
|
+
});
|
|
159
|
+
subchannel.ref();
|
|
160
|
+
return subchannel;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const globalSubchannelPool = new SubchannelPool();
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get either the global subchannel pool, or a new subchannel pool.
|
|
168
|
+
* @param global
|
|
169
|
+
*/
|
|
170
|
+
export function getSubchannelPool(global: boolean): SubchannelPool {
|
|
171
|
+
if (global) {
|
|
172
|
+
return globalSubchannelPool;
|
|
173
|
+
} else {
|
|
174
|
+
return new SubchannelPool();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2019 gRPC authors.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { ChannelCredentials } from './channel-credentials';
|
|
19
|
+
import { Metadata } from './metadata';
|
|
20
|
+
import { ChannelOptions } from './channel-options';
|
|
21
|
+
import { ConnectivityState } from './connectivity-state';
|
|
22
|
+
import { BackoffTimeout, BackoffOptions } from './backoff-timeout';
|
|
23
|
+
import * as logging from './logging';
|
|
24
|
+
import { LogVerbosity, Status } from './constants';
|
|
25
|
+
import { GrpcUri, uriToString } from './uri-parser';
|
|
26
|
+
import {
|
|
27
|
+
SubchannelAddress,
|
|
28
|
+
subchannelAddressToString,
|
|
29
|
+
} from './subchannel-address';
|
|
30
|
+
import {
|
|
31
|
+
SubchannelRef,
|
|
32
|
+
ChannelzTrace,
|
|
33
|
+
ChannelzChildrenTracker,
|
|
34
|
+
SubchannelInfo,
|
|
35
|
+
registerChannelzSubchannel,
|
|
36
|
+
ChannelzCallTracker,
|
|
37
|
+
unregisterChannelzRef,
|
|
38
|
+
} from './channelz';
|
|
39
|
+
import {
|
|
40
|
+
ConnectivityStateListener,
|
|
41
|
+
SubchannelInterface,
|
|
42
|
+
} from './subchannel-interface';
|
|
43
|
+
import { SubchannelCallInterceptingListener } from './subchannel-call';
|
|
44
|
+
import { SubchannelCall } from './subchannel-call';
|
|
45
|
+
import { CallEventTracker, SubchannelConnector, Transport } from './transport';
|
|
46
|
+
|
|
47
|
+
const TRACER_NAME = 'subchannel';
|
|
48
|
+
|
|
49
|
+
/* setInterval and setTimeout only accept signed 32 bit integers. JS doesn't
|
|
50
|
+
* have a constant for the max signed 32 bit integer, so this is a simple way
|
|
51
|
+
* to calculate it */
|
|
52
|
+
const KEEPALIVE_MAX_TIME_MS = ~(1 << 31);
|
|
53
|
+
|
|
54
|
+
export class Subchannel {
|
|
55
|
+
/**
|
|
56
|
+
* The subchannel's current connectivity state. Invariant: `session` === `null`
|
|
57
|
+
* if and only if `connectivityState` is IDLE or TRANSIENT_FAILURE.
|
|
58
|
+
*/
|
|
59
|
+
private connectivityState: ConnectivityState = ConnectivityState.IDLE;
|
|
60
|
+
/**
|
|
61
|
+
* The underlying http2 session used to make requests.
|
|
62
|
+
*/
|
|
63
|
+
private transport: Transport | null = null;
|
|
64
|
+
/**
|
|
65
|
+
* Indicates that the subchannel should transition from TRANSIENT_FAILURE to
|
|
66
|
+
* CONNECTING instead of IDLE when the backoff timeout ends.
|
|
67
|
+
*/
|
|
68
|
+
private continueConnecting = false;
|
|
69
|
+
/**
|
|
70
|
+
* A list of listener functions that will be called whenever the connectivity
|
|
71
|
+
* state changes. Will be modified by `addConnectivityStateListener` and
|
|
72
|
+
* `removeConnectivityStateListener`
|
|
73
|
+
*/
|
|
74
|
+
private stateListeners: Set<ConnectivityStateListener> = new Set();
|
|
75
|
+
|
|
76
|
+
private backoffTimeout: BackoffTimeout;
|
|
77
|
+
|
|
78
|
+
private keepaliveTime: number;
|
|
79
|
+
/**
|
|
80
|
+
* Tracks channels and subchannel pools with references to this subchannel
|
|
81
|
+
*/
|
|
82
|
+
private refcount = 0;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A string representation of the subchannel address, for logging/tracing
|
|
86
|
+
*/
|
|
87
|
+
private subchannelAddressString: string;
|
|
88
|
+
|
|
89
|
+
// Channelz info
|
|
90
|
+
private readonly channelzEnabled: boolean = true;
|
|
91
|
+
private channelzRef: SubchannelRef;
|
|
92
|
+
private channelzTrace: ChannelzTrace;
|
|
93
|
+
private callTracker = new ChannelzCallTracker();
|
|
94
|
+
private childrenTracker = new ChannelzChildrenTracker();
|
|
95
|
+
|
|
96
|
+
// Channelz socket info
|
|
97
|
+
private streamTracker = new ChannelzCallTracker();
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A class representing a connection to a single backend.
|
|
101
|
+
* @param channelTarget The target string for the channel as a whole
|
|
102
|
+
* @param subchannelAddress The address for the backend that this subchannel
|
|
103
|
+
* will connect to
|
|
104
|
+
* @param options The channel options, plus any specific subchannel options
|
|
105
|
+
* for this subchannel
|
|
106
|
+
* @param credentials The channel credentials used to establish this
|
|
107
|
+
* connection
|
|
108
|
+
*/
|
|
109
|
+
constructor(
|
|
110
|
+
private channelTarget: GrpcUri,
|
|
111
|
+
private subchannelAddress: SubchannelAddress,
|
|
112
|
+
private options: ChannelOptions,
|
|
113
|
+
private credentials: ChannelCredentials,
|
|
114
|
+
private connector: SubchannelConnector
|
|
115
|
+
) {
|
|
116
|
+
const backoffOptions: BackoffOptions = {
|
|
117
|
+
initialDelay: options['grpc.initial_reconnect_backoff_ms'],
|
|
118
|
+
maxDelay: options['grpc.max_reconnect_backoff_ms'],
|
|
119
|
+
};
|
|
120
|
+
this.backoffTimeout = new BackoffTimeout(() => {
|
|
121
|
+
this.handleBackoffTimer();
|
|
122
|
+
}, backoffOptions);
|
|
123
|
+
this.backoffTimeout.unref();
|
|
124
|
+
this.subchannelAddressString = subchannelAddressToString(subchannelAddress);
|
|
125
|
+
|
|
126
|
+
this.keepaliveTime = options['grpc.keepalive_time_ms'] ?? -1;
|
|
127
|
+
|
|
128
|
+
if (options['grpc.enable_channelz'] === 0) {
|
|
129
|
+
this.channelzEnabled = false;
|
|
130
|
+
}
|
|
131
|
+
this.channelzTrace = new ChannelzTrace();
|
|
132
|
+
this.channelzRef = registerChannelzSubchannel(
|
|
133
|
+
this.subchannelAddressString,
|
|
134
|
+
() => this.getChannelzInfo(),
|
|
135
|
+
this.channelzEnabled
|
|
136
|
+
);
|
|
137
|
+
if (this.channelzEnabled) {
|
|
138
|
+
this.channelzTrace.addTrace('CT_INFO', 'Subchannel created');
|
|
139
|
+
}
|
|
140
|
+
this.trace(
|
|
141
|
+
'Subchannel constructed with options ' +
|
|
142
|
+
JSON.stringify(options, undefined, 2)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private getChannelzInfo(): SubchannelInfo {
|
|
147
|
+
return {
|
|
148
|
+
state: this.connectivityState,
|
|
149
|
+
trace: this.channelzTrace,
|
|
150
|
+
callTracker: this.callTracker,
|
|
151
|
+
children: this.childrenTracker.getChildLists(),
|
|
152
|
+
target: this.subchannelAddressString,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private trace(text: string): void {
|
|
157
|
+
logging.trace(
|
|
158
|
+
LogVerbosity.DEBUG,
|
|
159
|
+
TRACER_NAME,
|
|
160
|
+
'(' +
|
|
161
|
+
this.channelzRef.id +
|
|
162
|
+
') ' +
|
|
163
|
+
this.subchannelAddressString +
|
|
164
|
+
' ' +
|
|
165
|
+
text
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private refTrace(text: string): void {
|
|
170
|
+
logging.trace(
|
|
171
|
+
LogVerbosity.DEBUG,
|
|
172
|
+
'subchannel_refcount',
|
|
173
|
+
'(' +
|
|
174
|
+
this.channelzRef.id +
|
|
175
|
+
') ' +
|
|
176
|
+
this.subchannelAddressString +
|
|
177
|
+
' ' +
|
|
178
|
+
text
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private handleBackoffTimer() {
|
|
183
|
+
if (this.continueConnecting) {
|
|
184
|
+
this.transitionToState(
|
|
185
|
+
[ConnectivityState.TRANSIENT_FAILURE],
|
|
186
|
+
ConnectivityState.CONNECTING
|
|
187
|
+
);
|
|
188
|
+
} else {
|
|
189
|
+
this.transitionToState(
|
|
190
|
+
[ConnectivityState.TRANSIENT_FAILURE],
|
|
191
|
+
ConnectivityState.IDLE
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Start a backoff timer with the current nextBackoff timeout
|
|
198
|
+
*/
|
|
199
|
+
private startBackoff() {
|
|
200
|
+
this.backoffTimeout.runOnce();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private stopBackoff() {
|
|
204
|
+
this.backoffTimeout.stop();
|
|
205
|
+
this.backoffTimeout.reset();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private startConnectingInternal() {
|
|
209
|
+
let options = this.options;
|
|
210
|
+
if (options['grpc.keepalive_time_ms']) {
|
|
211
|
+
const adjustedKeepaliveTime = Math.min(
|
|
212
|
+
this.keepaliveTime,
|
|
213
|
+
KEEPALIVE_MAX_TIME_MS
|
|
214
|
+
);
|
|
215
|
+
options = { ...options, 'grpc.keepalive_time_ms': adjustedKeepaliveTime };
|
|
216
|
+
}
|
|
217
|
+
this.connector
|
|
218
|
+
.connect(this.subchannelAddress, this.credentials, options)
|
|
219
|
+
.then(
|
|
220
|
+
transport => {
|
|
221
|
+
if (
|
|
222
|
+
this.transitionToState(
|
|
223
|
+
[ConnectivityState.CONNECTING],
|
|
224
|
+
ConnectivityState.READY
|
|
225
|
+
)
|
|
226
|
+
) {
|
|
227
|
+
this.transport = transport;
|
|
228
|
+
if (this.channelzEnabled) {
|
|
229
|
+
this.childrenTracker.refChild(transport.getChannelzRef());
|
|
230
|
+
}
|
|
231
|
+
transport.addDisconnectListener(tooManyPings => {
|
|
232
|
+
this.transitionToState(
|
|
233
|
+
[ConnectivityState.READY],
|
|
234
|
+
ConnectivityState.IDLE
|
|
235
|
+
);
|
|
236
|
+
if (tooManyPings && this.keepaliveTime > 0) {
|
|
237
|
+
this.keepaliveTime *= 2;
|
|
238
|
+
logging.log(
|
|
239
|
+
LogVerbosity.ERROR,
|
|
240
|
+
`Connection to ${uriToString(this.channelTarget)} at ${
|
|
241
|
+
this.subchannelAddressString
|
|
242
|
+
} rejected by server because of excess pings. Increasing ping interval to ${
|
|
243
|
+
this.keepaliveTime
|
|
244
|
+
} ms`
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
} else {
|
|
249
|
+
/* If we can't transition from CONNECTING to READY here, we will
|
|
250
|
+
* not be using this transport, so release its resources. */
|
|
251
|
+
transport.shutdown();
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
error => {
|
|
255
|
+
this.transitionToState(
|
|
256
|
+
[ConnectivityState.CONNECTING],
|
|
257
|
+
ConnectivityState.TRANSIENT_FAILURE,
|
|
258
|
+
`${error}`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Initiate a state transition from any element of oldStates to the new
|
|
266
|
+
* state. If the current connectivityState is not in oldStates, do nothing.
|
|
267
|
+
* @param oldStates The set of states to transition from
|
|
268
|
+
* @param newState The state to transition to
|
|
269
|
+
* @returns True if the state changed, false otherwise
|
|
270
|
+
*/
|
|
271
|
+
private transitionToState(
|
|
272
|
+
oldStates: ConnectivityState[],
|
|
273
|
+
newState: ConnectivityState,
|
|
274
|
+
errorMessage?: string
|
|
275
|
+
): boolean {
|
|
276
|
+
if (oldStates.indexOf(this.connectivityState) === -1) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
this.trace(
|
|
280
|
+
ConnectivityState[this.connectivityState] +
|
|
281
|
+
' -> ' +
|
|
282
|
+
ConnectivityState[newState]
|
|
283
|
+
);
|
|
284
|
+
if (this.channelzEnabled) {
|
|
285
|
+
this.channelzTrace.addTrace(
|
|
286
|
+
'CT_INFO',
|
|
287
|
+
'Connectivity state change to ' + ConnectivityState[newState]
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
const previousState = this.connectivityState;
|
|
291
|
+
this.connectivityState = newState;
|
|
292
|
+
switch (newState) {
|
|
293
|
+
case ConnectivityState.READY:
|
|
294
|
+
this.stopBackoff();
|
|
295
|
+
break;
|
|
296
|
+
case ConnectivityState.CONNECTING:
|
|
297
|
+
this.startBackoff();
|
|
298
|
+
this.startConnectingInternal();
|
|
299
|
+
this.continueConnecting = false;
|
|
300
|
+
break;
|
|
301
|
+
case ConnectivityState.TRANSIENT_FAILURE:
|
|
302
|
+
if (this.channelzEnabled && this.transport) {
|
|
303
|
+
this.childrenTracker.unrefChild(this.transport.getChannelzRef());
|
|
304
|
+
}
|
|
305
|
+
this.transport?.shutdown();
|
|
306
|
+
this.transport = null;
|
|
307
|
+
/* If the backoff timer has already ended by the time we get to the
|
|
308
|
+
* TRANSIENT_FAILURE state, we want to immediately transition out of
|
|
309
|
+
* TRANSIENT_FAILURE as though the backoff timer is ending right now */
|
|
310
|
+
if (!this.backoffTimeout.isRunning()) {
|
|
311
|
+
process.nextTick(() => {
|
|
312
|
+
this.handleBackoffTimer();
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
break;
|
|
316
|
+
case ConnectivityState.IDLE:
|
|
317
|
+
if (this.channelzEnabled && this.transport) {
|
|
318
|
+
this.childrenTracker.unrefChild(this.transport.getChannelzRef());
|
|
319
|
+
}
|
|
320
|
+
this.transport?.shutdown();
|
|
321
|
+
this.transport = null;
|
|
322
|
+
break;
|
|
323
|
+
default:
|
|
324
|
+
throw new Error(`Invalid state: unknown ConnectivityState ${newState}`);
|
|
325
|
+
}
|
|
326
|
+
for (const listener of this.stateListeners) {
|
|
327
|
+
listener(this, previousState, newState, this.keepaliveTime, errorMessage);
|
|
328
|
+
}
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
ref() {
|
|
333
|
+
this.refTrace('refcount ' + this.refcount + ' -> ' + (this.refcount + 1));
|
|
334
|
+
this.refcount += 1;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
unref() {
|
|
338
|
+
this.refTrace('refcount ' + this.refcount + ' -> ' + (this.refcount - 1));
|
|
339
|
+
this.refcount -= 1;
|
|
340
|
+
if (this.refcount === 0) {
|
|
341
|
+
if (this.channelzEnabled) {
|
|
342
|
+
this.channelzTrace.addTrace('CT_INFO', 'Shutting down');
|
|
343
|
+
}
|
|
344
|
+
if (this.channelzEnabled) {
|
|
345
|
+
unregisterChannelzRef(this.channelzRef);
|
|
346
|
+
}
|
|
347
|
+
process.nextTick(() => {
|
|
348
|
+
this.transitionToState(
|
|
349
|
+
[ConnectivityState.CONNECTING, ConnectivityState.READY],
|
|
350
|
+
ConnectivityState.IDLE
|
|
351
|
+
);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
unrefIfOneRef(): boolean {
|
|
357
|
+
if (this.refcount === 1) {
|
|
358
|
+
this.unref();
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
createCall(
|
|
365
|
+
metadata: Metadata,
|
|
366
|
+
host: string,
|
|
367
|
+
method: string,
|
|
368
|
+
listener: SubchannelCallInterceptingListener
|
|
369
|
+
): SubchannelCall {
|
|
370
|
+
if (!this.transport) {
|
|
371
|
+
throw new Error('Cannot create call, subchannel not READY');
|
|
372
|
+
}
|
|
373
|
+
let statsTracker: Partial<CallEventTracker>;
|
|
374
|
+
if (this.channelzEnabled) {
|
|
375
|
+
this.callTracker.addCallStarted();
|
|
376
|
+
this.streamTracker.addCallStarted();
|
|
377
|
+
statsTracker = {
|
|
378
|
+
onCallEnd: status => {
|
|
379
|
+
if (status.code === Status.OK) {
|
|
380
|
+
this.callTracker.addCallSucceeded();
|
|
381
|
+
} else {
|
|
382
|
+
this.callTracker.addCallFailed();
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
} else {
|
|
387
|
+
statsTracker = {};
|
|
388
|
+
}
|
|
389
|
+
return this.transport.createCall(
|
|
390
|
+
metadata,
|
|
391
|
+
host,
|
|
392
|
+
method,
|
|
393
|
+
listener,
|
|
394
|
+
statsTracker
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* If the subchannel is currently IDLE, start connecting and switch to the
|
|
400
|
+
* CONNECTING state. If the subchannel is current in TRANSIENT_FAILURE,
|
|
401
|
+
* the next time it would transition to IDLE, start connecting again instead.
|
|
402
|
+
* Otherwise, do nothing.
|
|
403
|
+
*/
|
|
404
|
+
startConnecting() {
|
|
405
|
+
process.nextTick(() => {
|
|
406
|
+
/* First, try to transition from IDLE to connecting. If that doesn't happen
|
|
407
|
+
* because the state is not currently IDLE, check if it is
|
|
408
|
+
* TRANSIENT_FAILURE, and if so indicate that it should go back to
|
|
409
|
+
* connecting after the backoff timer ends. Otherwise do nothing */
|
|
410
|
+
if (
|
|
411
|
+
!this.transitionToState(
|
|
412
|
+
[ConnectivityState.IDLE],
|
|
413
|
+
ConnectivityState.CONNECTING
|
|
414
|
+
)
|
|
415
|
+
) {
|
|
416
|
+
if (this.connectivityState === ConnectivityState.TRANSIENT_FAILURE) {
|
|
417
|
+
this.continueConnecting = true;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Get the subchannel's current connectivity state.
|
|
425
|
+
*/
|
|
426
|
+
getConnectivityState() {
|
|
427
|
+
return this.connectivityState;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Add a listener function to be called whenever the subchannel's
|
|
432
|
+
* connectivity state changes.
|
|
433
|
+
* @param listener
|
|
434
|
+
*/
|
|
435
|
+
addConnectivityStateListener(listener: ConnectivityStateListener) {
|
|
436
|
+
this.stateListeners.add(listener);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Remove a listener previously added with `addConnectivityStateListener`
|
|
441
|
+
* @param listener A reference to a function previously passed to
|
|
442
|
+
* `addConnectivityStateListener`
|
|
443
|
+
*/
|
|
444
|
+
removeConnectivityStateListener(listener: ConnectivityStateListener) {
|
|
445
|
+
this.stateListeners.delete(listener);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Reset the backoff timeout, and immediately start connecting if in backoff.
|
|
450
|
+
*/
|
|
451
|
+
resetBackoff() {
|
|
452
|
+
process.nextTick(() => {
|
|
453
|
+
this.backoffTimeout.reset();
|
|
454
|
+
this.transitionToState(
|
|
455
|
+
[ConnectivityState.TRANSIENT_FAILURE],
|
|
456
|
+
ConnectivityState.CONNECTING
|
|
457
|
+
);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
getAddress(): string {
|
|
462
|
+
return this.subchannelAddressString;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
getChannelzRef(): SubchannelRef {
|
|
466
|
+
return this.channelzRef;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
getRealSubchannel(): this {
|
|
470
|
+
return this;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
realSubchannelEquals(other: SubchannelInterface): boolean {
|
|
474
|
+
return other.getRealSubchannel() === this;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
throttleKeepalive(newKeepaliveTime: number) {
|
|
478
|
+
if (newKeepaliveTime > this.keepaliveTime) {
|
|
479
|
+
this.keepaliveTime = newKeepaliveTime;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2019 gRPC authors.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as fs from 'fs';
|
|
19
|
+
|
|
20
|
+
export const CIPHER_SUITES: string | undefined =
|
|
21
|
+
process.env.GRPC_SSL_CIPHER_SUITES;
|
|
22
|
+
|
|
23
|
+
const DEFAULT_ROOTS_FILE_PATH = process.env.GRPC_DEFAULT_SSL_ROOTS_FILE_PATH;
|
|
24
|
+
|
|
25
|
+
let defaultRootsData: Buffer | null = null;
|
|
26
|
+
|
|
27
|
+
export function getDefaultRootsData(): Buffer | null {
|
|
28
|
+
if (DEFAULT_ROOTS_FILE_PATH) {
|
|
29
|
+
if (defaultRootsData === null) {
|
|
30
|
+
defaultRootsData = fs.readFileSync(DEFAULT_ROOTS_FILE_PATH);
|
|
31
|
+
}
|
|
32
|
+
return defaultRootsData;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|