Class OperatorServiceStubsOptions.Builder
- java.lang.Object
-
- io.temporal.serviceclient.OperatorServiceStubsOptions.Builder
-
- Enclosing class:
- OperatorServiceStubsOptions
public static class OperatorServiceStubsOptions.Builder extends java.lang.Object
Builder is the builder for ClientOptions.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description T
addGrpcClientInterceptor(io.grpc.ClientInterceptor grpcClientInterceptor)
T
addGrpcMetadataProvider(GrpcMetadataProvider grpcMetadataProvider)
OperatorServiceStubsOptions
build()
Builds and returns a ClientOptions object.T
setChannel(io.grpc.ManagedChannel channel)
Sets fully custom user-configured gRPC channel to use.T
setChannelInitializer(java.util.function.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.T
setConnectionBackoffResetFrequency(java.time.Duration connectionBackoffResetFrequency)
Sets frequency at which gRPC connection backoff should be reset practically defining an upper limit for the maximum backoff duration.T
setEnableHttps(boolean enableHttps)
Sets option to enable SSL/TLS/HTTPS for gRPC.T
setEnableKeepAlive(boolean enableKeepAlive)
Enables keep alive ping from client to the server, which can help drop abruptly closed connections faster.T
setGrpcClientInterceptors(java.util.Collection<io.grpc.ClientInterceptor> grpcClientInterceptors)
T
setGrpcMetadataProviders(java.util.Collection<GrpcMetadataProvider> grpcMetadataProviders)
T
setGrpcReconnectFrequency(java.time.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.T
setHeaders(io.grpc.Metadata headers)
T
setHealthCheckAttemptTimeout(java.time.Duration healthCheckAttemptTimeout)
Deprecated.rpcTimeout
is now used as an attempt timeout.T
setHealthCheckTimeout(java.time.Duration healthCheckTimeout)
Deprecated.Use more explicitWorkflowServiceStubs.newConnectedServiceStubs(WorkflowServiceStubsOptions, Duration)
with a timeout parameter insteadT
setKeepAlivePermitWithoutStream(boolean keepAlivePermitWithoutStream)
If true, client sends keepalive pings even with no active RPCs.T
setKeepAliveTime(java.time.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.T
setKeepAliveTimeout(java.time.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.T
setMetricsScope(com.uber.m3.tally.Scope metricsScope)
Sets the scope to be used for metrics reporting.T
setRpcTimeout(java.time.Duration timeout)
Sets the rpc timeout value.T
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.T
setTarget(java.lang.String target)
Sets a target string, which can be either a validNameResolver
-compliant URI, or an authority string.OperatorServiceStubsOptions
validateAndBuildWithDefaults()
-
-
-
Method Detail
-
build
public OperatorServiceStubsOptions build()
Builds and returns a ClientOptions object.- Returns:
- ClientOptions object with the specified params.
-
validateAndBuildWithDefaults
public OperatorServiceStubsOptions validateAndBuildWithDefaults()
-
setTarget
public T setTarget(java.lang.String target)
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 isDEFAULT_LOCAL_DOCKER_TARGET
Mutually exclusive with
setChannel(ManagedChannel)
.- Returns:
this
-
setChannelInitializer
public T setChannelInitializer(java.util.function.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. Currently, Temporal Stubs useNettyChannelBuilder
to 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 withServiceStubsOptions.Builder.setTarget(String)
. The listener is called with an instance ofNettyChannelBuilder
that will be used by Temporal Stubs to create aManagedChannel
. The builder type may change in the future.- Returns:
this
-
setChannel
public T setChannel(io.grpc.ManagedChannel channel)
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
public T 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. Supersedes enableHttps; Exclusive with channel. Consider usingSimpleSslContextBuilder
which greatly simplifies creation of the TLS enabled SslContext with client and server key validation.- Returns:
this
-
setEnableHttps
public T setEnableHttps(boolean enableHttps)
Sets option to enable SSL/TLS/HTTPS for gRPC.Mutually exclusive with channel; Ignored and assumed
true
ifsetSslContext(SslContext)
is specified.- Returns:
this
-
setConnectionBackoffResetFrequency
public T setConnectionBackoffResetFrequency(java.time.Duration connectionBackoffResetFrequency)
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:
ManagedChannel.resetConnectBackoff()
-
setGrpcReconnectFrequency
public T setGrpcReconnectFrequency(java.time.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. 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:
ManagedChannel.enterIdle()
-
setHeaders
public T setHeaders(io.grpc.Metadata headers)
- Parameters:
headers
- gRPC headers to be added to every call- Returns:
this
-
addGrpcMetadataProvider
public T addGrpcMetadataProvider(GrpcMetadataProvider grpcMetadataProvider)
- Parameters:
grpcMetadataProvider
- gRPC metadata/headers provider to be called on each gRPC request to supply additional headers- Returns:
this
-
setGrpcMetadataProviders
public T setGrpcMetadataProviders(java.util.Collection<GrpcMetadataProvider> grpcMetadataProviders)
- Parameters:
grpcMetadataProviders
- gRPC metadata/headers providers to be called on each gRPC request to supply additional headers- Returns:
this
-
addGrpcClientInterceptor
public T addGrpcClientInterceptor(io.grpc.ClientInterceptor grpcClientInterceptor)
- Parameters:
grpcClientInterceptor
- gRPC client interceptor to be added to gRPC channel- Returns:
this
-
setGrpcClientInterceptors
public T setGrpcClientInterceptors(java.util.Collection<io.grpc.ClientInterceptor> grpcClientInterceptors)
- Parameters:
grpcClientInterceptors
- gRPC client interceptors to be added to gRPC channel- Returns:
this
-
setMetricsScope
public T setMetricsScope(com.uber.m3.tally.Scope metricsScope)
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
Scope
in 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
-
setHealthCheckAttemptTimeout
@Deprecated public T setHealthCheckAttemptTimeout(java.time.Duration healthCheckAttemptTimeout)
Deprecated.rpcTimeout
is now used as an attempt timeout.Set the time to wait between service responses on each health check.- Returns:
this
-
setHealthCheckTimeout
@Deprecated public T setHealthCheckTimeout(java.time.Duration healthCheckTimeout)
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
-
setEnableKeepAlive
public T setEnableKeepAlive(boolean enableKeepAlive)
Enables keep alive ping from client to the server, which can help drop abruptly closed connections faster.- Returns:
this
-
setKeepAliveTime
public T setKeepAliveTime(java.time.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. If set below 10s, a minimum value of 10s will be used instead.- Returns:
this
-
setKeepAliveTimeout
public T setKeepAliveTimeout(java.time.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.- Returns:
this
-
setKeepAlivePermitWithoutStream
public T setKeepAlivePermitWithoutStream(boolean keepAlivePermitWithoutStream)
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. * @return- Returns:
this
-
setRpcTimeout
public T setRpcTimeout(java.time.Duration timeout)
Sets the rpc timeout value. Default is 10 seconds.- Returns:
this
-
-