Class CoreEnvironment.Builder<SELF extends CoreEnvironment.Builder<SELF>>
- Enclosing class:
CoreEnvironment
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddRequestCallback
(RequestCallback requestCallback) Allows to configure callbacks across the lifetime of a request.applyProfile
(String profileName) Applies custom properties based on a profile name.build()
Turns this builder into a realCoreEnvironment
.Returns the currently stored config builder.compressionConfig
(CompressionConfig.Builder compressionConfig) Deprecated.This method clobbers any previously configured values.compressionConfig
(Consumer<CompressionConfig.Builder> builderConsumer) Passes theCompressionConfig.Builder
to the provided consumer.Customizes the event bus for the SDK.ioConfig()
Returns the currently stored config builder.ioConfig
(IoConfig.Builder ioConfig) Deprecated.This method clobbers any previously configured values.ioConfig
(Consumer<IoConfig.Builder> builderConsumer) Passes theIoConfig.Builder
to the provided consumer.Deprecated.Please useioEnvironmentConfig()
instead.ioEnvironment
(IoEnvironment.Builder ioEnvironment) Deprecated.This method clobbers any previously configured values.ioEnvironment
(Consumer<IoEnvironment.Builder> builderConsumer) Passes theIoEnvironment.Builder
to the provided consumer.Returns the currently stored IoEnvironment builder.load
(PropertyLoader<CoreEnvironment.Builder> loader) Immediately loads the properties from the given loader into the environment.You might wonder why callers can't useload(PropertyLoader)
to load system properties.Returns the currently stored config builder.loggerConfig
(LoggerConfig.Builder loggerConfig) Deprecated.This method clobbers any previously configured values.loggerConfig
(Consumer<LoggerConfig.Builder> builderConsumer) Passes theLoggerConfig.Builder
to the provided consumer.loggingMeterConfig
(LoggingMeterConfig.Builder loggingMeterConfig) Deprecated.This method clobbers any previously configured values.loggingMeterConfig
(Consumer<LoggingMeterConfig.Builder> builderConsumer) Passes theLoggingMeterConfig.Builder
to the provided consumer.maxNumRequestsInRetry
(long maxNumRequestsInRetry) Allows to customize the maximum number of requests allowed in the retry timer.Allows to configure a custom metrics implementation.Returns the currently stored config builder.orphanReporterConfig
(OrphanReporterConfig.Builder orphanReporterConfig) Deprecated.This method clobbers any previously configured values.orphanReporterConfig
(Consumer<OrphanReporterConfig.Builder> builderConsumer) Passes theOrphanReporterConfig.Builder
to the provided consumer.preferredServerGroup
(String preferredServerGroup) Sets a preferred server group, that will be used for operations that support this feature.publishOnScheduler
(Supplier<Scheduler> publishOnScheduler) Specifies the supplier the SDK uses to get the Scheduler for publishing Reactive API results.requestTracer
(RequestTracer requestTracer) Allows to configure a custom tracer implementation.retryStrategy
(RetryStrategy retryStrategy) Allows to customize the default retry strategy.Customizes the default Reactor scheduler used for parallel operations.schedulerThreadCount
(int schedulerThreadCount) Customizes the thread count for theCoreEnvironment.scheduler()
if not customized byscheduler(Scheduler)
.Returns the currently stored config builder.securityConfig
(SecurityConfig.Builder securityConfig) Deprecated.This method clobbers any previously configured values.securityConfig
(Consumer<SecurityConfig.Builder> builderConsumer) Passes theSecurityConfig.Builder
to the provided consumer.protected SELF
self()
thresholdLoggingTracerConfig
(ThresholdLoggingTracerConfig.Builder thresholdLoggingTracerConfig) Deprecated.This method clobbers any previously configured values.thresholdLoggingTracerConfig
(Consumer<ThresholdLoggingTracerConfig.Builder> builderConsumer) Passes theThresholdLoggingTracerConfig.Builder
to the provided consumer.Deprecated.thresholdRequestTracerConfig
(ThresholdRequestTracerConfig.Builder thresholdRequestTracerConfig) Deprecated.This method clobbers any previously configured values.Returns the currently stored config builder.timeoutConfig
(TimeoutConfig.Builder timeoutConfig) Deprecated.This method clobbers any previously configured values.timeoutConfig
(Consumer<TimeoutConfig.Builder> builderConsumer) Passes theTimeoutConfig.Builder
to the provided consumer.transactionsConfig
(CoreTransactionsConfig transactionsConfig) Allows configuring the transactions config.
-
Field Details
-
transactionsConfig
-
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
ioEnvironment
Passes theIoEnvironment.Builder
to the provided consumer.Allows customizing I/O thread pools and other resources. For more I/O settings, see:
ioConfig(Consumer)
- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
ioConfig
Passes theIoConfig.Builder
to the provided consumer.This is the main way to control how the SDK behaves at the lower levels. It allows customizing settings such as tcp keepalive, number of connections, circuit breakers, etc.
- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
compressionConfig
Passes theCompressionConfig.Builder
to the provided consumer.Allows customizing document value compression settings.
Usually this does not need to be tuned, but thresholds can be modified or compression can be disabled completely if needed.
- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
securityConfig
Passes theSecurityConfig.Builder
to the provided consumer.Allows configuring everything related to TLS/encrypted connections.
Note that if you are looking to use client certificate authentication, please refer to the
CertificateAuthenticator
instead.- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
timeoutConfig
Passes theTimeoutConfig.Builder
to the provided consumer.Allows customizing the default timeouts for all operations.
The default timeout can be overridden on a per-request basis using the "timeout" property of the request's option block.
- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
loggerConfig
Passes theLoggerConfig.Builder
to the provided consumer.- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
orphanReporterConfig
Passes theOrphanReporterConfig.Builder
to the provided consumer.Allows customizing the behavior of the orphan response reporter.
The orphan reporter logs all responses that arrived when the requesting side is not listening anymore (usually because of a timeout). The config can be modified to tune certain properties like the sample size or the emit interval.
- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
thresholdLoggingTracerConfig
public SELF thresholdLoggingTracerConfig(Consumer<ThresholdLoggingTracerConfig.Builder> builderConsumer) Passes theThresholdLoggingTracerConfig.Builder
to the provided consumer.- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
loggingMeterConfig
Passes theLoggingMeterConfig.Builder
to the provided consumer.- Parameters:
builderConsumer
- configures the builder.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
self
-
maxNumRequestsInRetry
Allows to customize the maximum number of requests allowed in the retry timer.If the
CoreEnvironment.DEFAULT_MAX_NUM_REQUESTS_IN_RETRY
is reached, each request that would be queued for retry is instead cancelled with aCancellationReason.TOO_MANY_REQUESTS_IN_RETRY
. This acts as a form of safety net and backpressure.- Parameters:
maxNumRequestsInRetry
- the maximum number of requests outstanding for retry.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
load
Immediately loads the properties from the given loader into the environment.- Parameters:
loader
- the loader to load the properties from.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
ioEnvironment
Deprecated.This method clobbers any previously configured values. Please useioEnvironment(Consumer)
instead.Allows to customize I/O thread pools.Note that the
IoEnvironment
holds thread pools and other resources. If you do not want to customize thread pool sizes, you likely want to look at theIoConfig
instead.- Parameters:
ioEnvironment
- the IO environment to customize.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
ioEnvironment
Deprecated.Please useioEnvironmentConfig()
instead.Returns the currently stored IoEnvironment builder.- Returns:
- the current builder.
-
ioEnvironmentConfig
Returns the currently stored IoEnvironment builder.- Returns:
- the current builder.
-
ioConfig
Deprecated.This method clobbers any previously configured values. Please useioConfig(Consumer)
instead.Allows to customize various I/O-related configuration properties.The I/O config is the main way to control how the SDK behaves at the lower levels. It allows to customize properties such as tcp keepalive, number of connections, circuit breakers, etc.
- Parameters:
ioConfig
- the custom I/O config to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
ioConfig
Returns the currently stored config builder.- Returns:
- the current builder.
-
orphanReporterConfig
Deprecated.This method clobbers any previously configured values. Please useorphanReporterConfig(Consumer)
instead.Allows to customize the behavior of the orphan response reporter.The orphan reporter logs all responses that arrived when the requesting side is not listening anymore (usually because of a timeout). The config can be modified to tune certain properties like the sample size or the emit interval.
- Parameters:
orphanReporterConfig
- the custom orphan reporter config.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
orphanReporterConfig
Returns the currently stored config builder.- Returns:
- the current builder.
-
loggingMeterConfig
Deprecated.This method clobbers any previously configured values. Please useloggingMeterConfig(Consumer)
instead. -
loggingMeterConfig
-
thresholdRequestTracerConfig
@Deprecated public SELF thresholdRequestTracerConfig(ThresholdRequestTracerConfig.Builder thresholdRequestTracerConfig) Deprecated.This method clobbers any previously configured values. Please usethresholdLoggingTracerConfig(Consumer)
instead.Allows to customize the threshold request tracer configuration.- Parameters:
thresholdRequestTracerConfig
- the configuration which should be used.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
thresholdRequestTracerConfig
Deprecated. -
thresholdLoggingTracerConfig
@Deprecated public SELF thresholdLoggingTracerConfig(ThresholdLoggingTracerConfig.Builder thresholdLoggingTracerConfig) Deprecated.This method clobbers any previously configured values. Please usethresholdLoggingTracerConfig(Consumer)
instead.Allows to customize the threshold request tracer configuration.- Parameters:
thresholdLoggingTracerConfig
- the configuration which should be used.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
publishOnScheduler
Specifies the supplier the SDK uses to get the Scheduler for publishing Reactive API results.Defaults to null, which means reactive results are published immediately in a thread owned by the SDK -- typically the SDK's Netty event loop.
The supplier is invoked once for every subscription, by the same thread that subscribes to the Mono/Flux.
- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
thresholdLoggingTracerConfig
-
compressionConfig
Deprecated.This method clobbers any previously configured values. Please usecompressionConfig(Consumer)
instead.Allows to customize document value compression settings.Usually this does not need to be tuned, but thresholds can be modified or compression can be disabled completely if needed.
- Parameters:
compressionConfig
- the custom compression config.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
compressionConfig
Returns the currently stored config builder.- Returns:
- the current builder.
-
securityConfig
Deprecated.This method clobbers any previously configured values. Please usesecurityConfig(Consumer)
instead.Allows to configure everything related to TLS/encrypted connections.Note that if you are looking to use client certificate authentication, please refer to the
CertificateAuthenticator
instead.- Parameters:
securityConfig
- the custom security config to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
securityConfig
Returns the currently stored config builder.- Returns:
- the current builder.
-
timeoutConfig
Deprecated.This method clobbers any previously configured values. Please usetimeoutConfig(Consumer)
instead.Allows to customize the default timeouts for all operations.Each timeout can also be modified on a per-request basis in their respective options blocks.
- Parameters:
timeoutConfig
- the custom timeout config to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
timeoutConfig
Returns the currently stored config builder.- Returns:
- the current builder.
-
loggerConfig
Deprecated.This method clobbers any previously configured values. Please useloggerConfig(Consumer)
instead.Allows to provide a custom configuration for the default logger used.The default logger attaches itself to the
EventBus
on the environment and logs consumed events. This configuration allows to customize its behavior, diagnostic context etc.- Parameters:
loggerConfig
- the custom logger config to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
loggerConfig
Returns the currently stored config builder.- Returns:
- the current builder.
-
eventBus
Customizes the event bus for the SDK.The SDK ships with a high-performance implementation of a event bus. Only swap out if you have special needs, usually what you want instead is to register your own consumer on the event bus instead (
EventBus.subscribe(Consumer)
)!- Parameters:
eventBus
- the event bus to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
scheduler
Customizes the default Reactor scheduler used for parallel operations.Usually you do not need to modify the scheduler, use with care.
- Parameters:
scheduler
- a custom scheduler to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
schedulerThreadCount
Customizes the thread count for theCoreEnvironment.scheduler()
if not customized byscheduler(Scheduler)
.By default,
Schedulers.DEFAULT_POOL_SIZE
is used. Note that if the scheduler itself is customized, this value is ignored.- Parameters:
schedulerThreadCount
- the number of threads to use for the scheduler.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
retryStrategy
Allows to customize the default retry strategy.Note that this setting modifies the SDK-wide retry strategy. It can still be overridden on a per-request basis in the respective options block.
- Parameters:
retryStrategy
- the default retry strategy to use for all operations.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
requestTracer
Allows to configure a custom tracer implementation.IMPORTANT: this is a volatile, likely to change API!
- Parameters:
requestTracer
- the custom request tracer to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
meter
Allows to configure a custom metrics implementation.IMPORTANT: this is a volatile, likely to change API!
- Parameters:
meter
- the custom metrics implementation to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
transactionsConfig
Allows configuring the transactions config.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
addRequestCallback
Allows to configure callbacks across the lifetime of a request.IMPORTANT: this is internal API and might change at any point in time.
- Parameters:
requestCallback
- the callback to use.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
build
Turns this builder into a realCoreEnvironment
.- Returns:
- the created core environment.
-
applyProfile
Applies custom properties based on a profile name.At the moment only the "wan-development" profile is supported, but its actual values are not determined yet. Since this is volatile API, the actual profile names and their properties are subject to change.
New profiles can be registered by utilizing the ServiceRegistry mechanism. Create a file with the name of "com.couchbase.client.core.env.ConfigurationProfile" in your META-INF/services folder and the content contains each line of classes that implement the "EnvironmentProfile" interface. See the
WanDevelopmentProfile
for examples and usage.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
preferredServerGroup
Sets a preferred server group, that will be used for operations that support this feature.- Returns:
- this
CoreEnvironment.Builder
for chaining purposes.
-
loadSystemProperties
You might wonder why callers can't useload(PropertyLoader)
to load system properties.It's because that method requires a raw builder type, while
SystemPropertyPropertyLoader
's builder type has an unbounded wildcard.Fixing the types would be a source-incompatible change. We'll get it right next time!
-