Class ServiceStubsOptions.Builder<T extends ServiceStubsOptions.Builder<T>>
- Direct Known Subclasses:
CloudServiceStubsOptions.Builder,OperatorServiceStubsOptions.Builder,WorkflowServiceStubsOptions.Builder
- Enclosing class:
ServiceStubsOptions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddApiKey(AuthorizationTokenSupplier apiKey) Add aAuthorizationGrpcMetadataProviderto the gRPC metadata providers that supplies an authentication token on each gRPC request.addGrpcClientInterceptor(io.grpc.ClientInterceptor grpcClientInterceptor) addGrpcMetadataProvider(GrpcMetadataProvider grpcMetadataProvider) build()setChannel(io.grpc.ManagedChannel channel) Sets fully custom user-configured gRPC channel to use.setChannelInitializer(Consumer<io.grpc.ManagedChannelBuilder<?>> channelInitializer) Gives an opportunity to provide some additional configuration to the channel builder or override configurations done by the Temporal Stubs.setConnectionBackoffResetFrequency(Duration connectionBackoffResetFrequency) Sets frequency at which gRPC connection backoff should be reset practically defining an upper limit for the maximum backoff duration.setEnableHttps(boolean enableHttps) Sets option to enable SSL/TLS/HTTPS for gRPC.setEnableKeepAlive(boolean enableKeepAlive) Enables keep alive ping from client to the server, which can help drop abruptly closed connections faster.setGrpcClientInterceptors(Collection<io.grpc.ClientInterceptor> grpcClientInterceptors) setGrpcCompression(GrpcCompression grpcCompression) Sets outbound transport-level gRPC compression.setGrpcMetadataProviders(Collection<GrpcMetadataProvider> grpcMetadataProviders) setGrpcReconnectFrequency(Duration grpcReconnectFrequency) Sets frequency at which gRPC channel will be moved into an idle state and triggers tear-down of the channel's name resolver and load balancer, while still allowing on-going RPCs on the channel to continue.setHeaders(io.grpc.Metadata headers) setHealthCheckAttemptTimeout(Duration healthCheckAttemptTimeout) Deprecated.setHealthCheckTimeout(Duration healthCheckTimeout) Deprecated.Use more explicitWorkflowServiceStubs.newConnectedServiceStubs(WorkflowServiceStubsOptions, Duration)with a timeout parameter insteadsetKeepAlivePermitWithoutStream(boolean keepAlivePermitWithoutStream) If true, client sends keepalive pings even with no active RPCs.setKeepAliveTime(Duration keepAliveTime) After a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.setKeepAliveTimeout(Duration keepAliveTimeout) After having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.setMetricsScope(com.uber.m3.tally.Scope metricsScope) Sets the scope to be used for metrics reporting.setRpcTimeout(Duration timeout) Sets the rpc timeout value.setSslContext(io.grpc.netty.shaded.io.netty.handler.ssl.SslContext sslContext) Sets gRPC SSL Context to use, used for more advanced scenarios such as mTLS.setSystemInfoTimeout(Duration systemInfoTimeout) Set a SystemInfoTimeout that specifies how long the client tries to fetch server capabilities.Sets a target string, which can be either a validNameResolver-compliant URI, or an authority string.
-
Constructor Details
-
Builder
protected Builder() -
Builder
-
-
Method Details
-
setTarget
Sets a target string, which can be either a validNameResolver-compliant URI, or an authority string. SeeManagedChannelBuilder.forTarget(String)for more information about parameter format. Default isServiceStubsOptions.DEFAULT_LOCAL_DOCKER_TARGETMutually exclusive with
setChannel(ManagedChannel).- Returns:
this
-
setChannelInitializer
Gives an opportunity to provide some additional configuration to the channel builder or override configurations done by the Temporal Stubs. Currently, Temporal Stubs useNettyChannelBuilderto create aManagedChannel.Advanced API
Mutually exclusive with
setChannel(ManagedChannel).- Parameters:
channelInitializer- listener that will be called as a last step of channel creation if Stubs are configured withsetTarget(String). The listener is called with an instance ofNettyChannelBuilderthat will be used by Temporal Stubs to create aManagedChannel. The builder type may change in the future.- Returns:
this
-
setChannel
Sets fully custom user-configured gRPC channel to use.Before supplying a fully custom channel using this method, it's recommended to first consider using
setTarget(String)+ other options ofWorkflowServiceStubsOptions.Builder+setChannelInitializer(Consumer)for some rarely used configuration.
This option is not intended for the majority of users as it disables some Temporal connection management features and can lead to outages if the channel is configured or managed improperly.Mutually exclusive with
setTarget(String),setChannelInitializer(Consumer),setSslContext(SslContext),setGrpcReconnectFrequency(Duration)andsetConnectionBackoffResetFrequency(Duration). These options are ignored if the custom channel is supplied.- Returns:
this
-
setSslContext
Sets gRPC SSL Context to use, used for more advanced scenarios such as mTLS. Supersedes enableHttps; Exclusive with channel. Consider usingSimpleSslContextBuilderwhich greatly simplifies creation of the TLS enabled SslContext with client and server key validation.- Returns:
this
-
setEnableHttps
Sets option to enable SSL/TLS/HTTPS for gRPC.Mutually exclusive with channel; Ignored and assumed
trueifsetSslContext(SslContext)is specified.- Returns:
this
-
setConnectionBackoffResetFrequency
Sets frequency at which gRPC connection backoff should be reset practically defining an upper limit for the maximum backoff duration. If set to null then no backoff reset will be performed and we'll rely on default gRPC backoff behavior defined in ExponentialBackoffPolicy.Mutually exclusive with
setChannel(ManagedChannel).- Parameters:
connectionBackoffResetFrequency- frequency, defaults to once every 10 seconds. Set to null in order to disable this feature- Returns:
this- See Also:
-
setGrpcReconnectFrequency
Sets frequency at which gRPC channel will be moved into an idle state and triggers tear-down of the channel's name resolver and load balancer, while still allowing on-going RPCs on the channel to continue. New RPCs on the channel will trigger creation of a new connection. This allows worker to connect to a new temporal backend host periodically avoiding hot spots and resulting in a more even connection distribution.Mutually exclusive with
setChannel(ManagedChannel).- Parameters:
grpcReconnectFrequency- frequency, defaults to once every 1 minute. Set to null in order to disable this feature- Returns:
this- See Also:
-
setHeaders
- Parameters:
headers- gRPC headers to be added to every call- Returns:
this
-
addGrpcMetadataProvider
- Parameters:
grpcMetadataProvider- gRPC metadata/headers provider to be called on each gRPC request to supply additional headers- Returns:
this
-
addApiKey
Add aAuthorizationGrpcMetadataProviderto the gRPC metadata providers that supplies an authentication token on each gRPC request.- Parameters:
apiKey- authentication token supplier to be called on each gRPC request. SDK will automatically add the "Bearer " prefix.- Returns:
this
-
setGrpcMetadataProviders
- Parameters:
grpcMetadataProviders- gRPC metadata/headers providers to be called on each gRPC request to supply additional headers- Returns:
this
-
addGrpcClientInterceptor
- Parameters:
grpcClientInterceptor- gRPC client interceptor to be added to gRPC channel- Returns:
this
-
setGrpcClientInterceptors
- Parameters:
grpcClientInterceptors- gRPC client interceptors to be added to gRPC channel- Returns:
this
-
setMetricsScope
Sets the scope to be used for metrics reporting. Optional. Default is to not report metrics.This method should be used to integrate client and workers with external metrics and monitoring systems.
Example:
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); StatsReporter reporter = new MicrometerClientStatsReporter(registry); Scope scope = new RootScopeBuilder().reporter(reporter).reportEvery(Duration.ofSeconds(10)); WorkflowServiceStubsOptions options = WorkflowServiceStubsOptions.newBuilder() .setMetricsScope(scope) .build();Note: Don't mock
Scopein tests! If you need to verify the metrics behavior, create a real Scope and mock, stub or spy a reporter instance:
StatsReporter reporter = mock(StatsReporter.class); Scope metricsScope = new RootScopeBuilder() .reporter(reporter) .reportEvery(com.uber.m3.util.Duration.ofMillis(10));- Parameters:
metricsScope- the scope to be used for metrics reporting.- Returns:
this
-
setGrpcCompression
Sets outbound transport-level gRPC compression. Defaults toGrpcCompression.GZIP. If a specific server RPC does not support gzip, the SDK may retry that RPC without compression and continue using gzip for other RPCs. Set toGrpcCompression.NONEto opt out of compressing requests.The SDK uses the default gRPC response decompression registry for all compression options, so disabling request compression does not disable accepting compressed responses.
- Returns:
this
-
setHealthCheckAttemptTimeout
Deprecated.rpcTimeoutis now used as an attempt timeout.Set the time to wait between service responses on each health check.- Returns:
this
-
setHealthCheckTimeout
Deprecated.Use more explicitWorkflowServiceStubs.newConnectedServiceStubs(WorkflowServiceStubsOptions, Duration)with a timeout parameter insteadSet a HealthCheckTimeout after which to stop waiting while checking server connection when creating new client.- Returns:
this
-
setSystemInfoTimeout
-
setEnableKeepAlive
Enables keep alive ping from client to the server, which can help drop abruptly closed connections faster.Default is true
- Returns:
this
-
setKeepAliveTime
-
setKeepAliveTimeout
-
setKeepAlivePermitWithoutStream
If true, client sends keepalive pings even with no active RPCs. If false, when there are no active RPCs, Time and Timeout will be ignored and no keepalive pings will be sent. * @returnDefault is true
- Returns:
this
-
setRpcTimeout
-
build
- Returns:
- Built ServiceStubOptions object with the specified params
-
validateAndBuildWithDefaults
-
rpcTimeoutis now used as an attempt timeout.