Package software.amazon.lambda.durable
Class DurableConfig.Builder
java.lang.Object
software.amazon.lambda.durable.DurableConfig.Builder
- Enclosing class:
- DurableConfig
Builder for DurableConfig. Provides fluent API for configuring SDK components.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the DurableConfig instance.withCheckpointDelay(Duration duration) Sets how often the SDK checkpoints updates to backend.withDurableExecutionClient(DurableExecutionClient durableExecutionClient) Sets a custom DurableExecutionClient.withExecutorService(ExecutorService executorService) Sets a custom ExecutorService for running user-defined operations.withLambdaClientBuilder(software.amazon.awssdk.services.lambda.LambdaClientBuilder lambdaClientBuilder) Sets a custom LambdaClient for production use.withLoggerConfig(LoggerConfig loggerConfig) Sets a custom LoggerConfig.withPlugins(DurableExecutionPlugin... plugins) Deprecated.This is a preview API that is experimental and may be changed or removed in future releases.withPollingStrategy(PollingStrategy pollingStrategy) Sets the polling strategy.withSerDes(SerDes serDes) Sets a custom SerDes implementation.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
withLambdaClientBuilder
public DurableConfig.Builder withLambdaClientBuilder(software.amazon.awssdk.services.lambda.LambdaClientBuilder lambdaClientBuilder) Sets a custom LambdaClient for production use. Use this method to customize the AWS SDK client with specific regions, credentials, timeouts, or retry policies.Example:
LambdaClientBuilder lambdaClientBuilder = LambdaClient.builder() .region(Region.US_WEST_2) .credentialsProvider(ProfileCredentialsProvider.create("my-profile")); DurableConfig.builder() .withLambdaClientBuilder(lambdaClientBuilder) .build();- Parameters:
lambdaClientBuilder- Custom LambdaClientBuilder instance- Returns:
- This builder
- Throws:
NullPointerException- if lambdaClient is null
-
withDurableExecutionClient
public DurableConfig.Builder withDurableExecutionClient(DurableExecutionClient durableExecutionClient) Sets a custom DurableExecutionClient.Note: This method is primarily intended for testing with mock clients (e.g.,
LocalMemoryExecutionClient). For production use with a custom AWS SDK client, preferwithLambdaClientBuilder(LambdaClientBuilder).- Parameters:
durableExecutionClient- Custom DurableExecutionClient instance- Returns:
- This builder
- Throws:
NullPointerException- if durableExecutionClient is null
-
withSerDes
Sets a custom SerDes implementation.- Parameters:
serDes- Custom SerDes instance- Returns:
- This builder
- Throws:
NullPointerException- if serDes is null
-
withExecutorService
Sets a custom ExecutorService for running user-defined operations. If not set, a default cached thread pool will be created.This executor is used exclusively for running user-defined operations. Internal SDK coordination (polling, checkpointing) uses the SDK InternalExecutor thread pool and is not affected by this setting.
- Parameters:
executorService- Custom ExecutorService instance- Returns:
- This builder
-
withLoggerConfig
Sets a custom LoggerConfig. If not set, defaults to suppressing replay logs.- Parameters:
loggerConfig- Custom LoggerConfig instance- Returns:
- This builder
-
withPollingStrategy
Sets the polling strategy. If not set, defaults to 1 second with full jitter and 2x backoff.- Parameters:
pollingStrategy- Custom PollingStrategy instance- Returns:
- This builder
-
withCheckpointDelay
Sets how often the SDK checkpoints updates to backend. If not set, defaults to 0, SDK will checkpoint the updates as soon as possible.- Parameters:
duration- the checkpoint delay in Duration- Returns:
- This builder
-
withPlugins
Deprecated.This is a preview API that is experimental and may be changed or removed in future releases.Registers one or more plugins for lifecycle event instrumentation.Plugins receive hooks at invocation, operation, and user function boundaries. Errors thrown by plugins are isolated and never disrupt SDK execution.
Calling this method replaces any previously registered plugins. Plugins are called in registration order.
- Parameters:
plugins- the plugins to register- Returns:
- This builder
- Throws:
NullPointerException- if any plugin is null
-
build
Builds the DurableConfig instance.- Returns:
- Immutable DurableConfig instance
-