Class AsyncDynamoSimplifiedClient

java.lang.Object
dev.hogwai.dynamodb.simplified.async.AsyncDynamoSimplifiedClient
All Implemented Interfaces:
AsyncDynamoSimplifiedClientInterface, AutoCloseable

public class AsyncDynamoSimplifiedClient extends Object implements AsyncDynamoSimplifiedClientInterface
Async entry point for the DynamoDB Simplified library.

Provides factory methods to create an async client and access typed AsyncTable instances for DynamoDB table operations. Wraps a DynamoDbEnhancedAsyncClient and a DynamoDbAsyncClient.

Thread safety: this client is safe to use from multiple threads once created. The table() factory method may be called concurrently. Individual builders returned by AsyncTable methods are single-use and not thread-safe.

See Also:
  • AsyncTable
  • DynamoDbEnhancedAsyncClient
  • DynamoDbAsyncClient
  • Method Details

    • create

      public static @NonNull AsyncDynamoSimplifiedClient create()
      Creates an AsyncDynamoSimplifiedClient with default AWS credentials and region.
      Returns:
      a new instance
    • create

      public static @NonNull AsyncDynamoSimplifiedClient create(@NonNull software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient client)
      Creates an AsyncDynamoSimplifiedClient with a custom DynamoDbAsyncClient.
      Parameters:
      client - the async DynamoDB client to use
      Returns:
      a new instance
    • builder

      public static @NonNull AsyncDynamoSimplifiedClientBuilder builder()
      Returns a builder for creating an AsyncDynamoSimplifiedClient with extensions and a custom DynamoDB async client.
      Returns:
      a new builder instance
    • table

      public <T> @NonNull AsyncTable<T> table(@NonNull String tableName, @NonNull Class<T> itemClass)
      Returns a typed AsyncTable for the given table name and item class.
      Specified by:
      table in interface AsyncDynamoSimplifiedClientInterface
      Type Parameters:
      T - the item type
      Parameters:
      tableName - the name of the DynamoDB table
      itemClass - the class of items stored in the table
      Returns:
      an AsyncTable<T> for the specified table
    • table

      public <T> @NonNull AsyncTable<T> table(@NonNull String tableName, @NonNull software.amazon.awssdk.enhanced.dynamodb.TableSchema<T> schema)
      Returns a typed AsyncTable for the given table name and custom schema.
      Specified by:
      table in interface AsyncDynamoSimplifiedClientInterface
      Type Parameters:
      T - the item type
      Parameters:
      tableName - the name of the DynamoDB table
      schema - the table schema defining item mapping
      Returns:
      an AsyncTable<T> for the specified table
    • table

      public <T> @NonNull AsyncTable<T> table(@NonNull String tableName, @NonNull Class<T> itemClass, @NonNull Consumer<software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema.Builder<T>> configurator)
      Returns a typed AsyncTable for the given table name and item class, using a StaticTableSchema configured by the provided consumer.

      This is useful when you want to define the table schema programmatically rather than using annotations.

      Specified by:
      table in interface AsyncDynamoSimplifiedClientInterface
      Type Parameters:
      T - the item type
      Parameters:
      tableName - the name of the DynamoDB table
      itemClass - the class of items stored in the table
      configurator - a consumer to configure the StaticTableSchema.Builder
      Returns:
      an AsyncTable<T> for the specified table
    • entityTable

      public <T> @NonNull AsyncEntityTable<T> entityTable(@NonNull Class<T> entityClass)
      Returns an AsyncEntityTable for the given entity class, enabling single-table design with auto-computed composite keys and discriminator filtering.

      The entity class must be annotated with @Entity. Key components are defined via @KeyComponent and automatically composed into the table's partition/sort keys before every put and update operation. Queries are automatically filtered by the entity's discriminator value.

      Specified by:
      entityTable in interface AsyncDynamoSimplifiedClientInterface
      Type Parameters:
      T - the entity type
      Parameters:
      entityClass - the entity class annotated with @Entity
      Returns:
      an AsyncEntityTable<T> for single-table design
    • transactGet

      public @NonNull AsyncTransactGetBuilder transactGet()
      Starts building an async transactional read operation across one or more tables.

      All items are read atomically in a single all-or-nothing transaction.

      Specified by:
      transactGet in interface AsyncDynamoSimplifiedClientInterface
      Returns:
      an AsyncTransactGetBuilder for configuring and executing the transaction
    • transactWrite

      public @NonNull AsyncTransactWriteBuilder transactWrite()
      Starts building an async transactional write operation across one or more tables.

      All put, update, delete, and condition check actions are applied atomically.

      Specified by:
      transactWrite in interface AsyncDynamoSimplifiedClientInterface
      Returns:
      an AsyncTransactWriteBuilder for configuring and executing the transaction
    • batchGet

      public @NonNull AsyncCrossTableBatchGetBuilder batchGet()
      Returns an async cross-table batch get builder for retrieving items from multiple tables.
      Specified by:
      batchGet in interface AsyncDynamoSimplifiedClientInterface
      Returns:
      an async cross-table batch get builder
    • batchWrite

      public @NonNull AsyncCrossTableBatchWriteBuilder batchWrite()
      Returns an async cross-table batch write builder for putting/deleting items across multiple tables.
      Specified by:
      batchWrite in interface AsyncDynamoSimplifiedClientInterface
      Returns:
      an async cross-table batch write builder
    • getEnhancedClient

      public @NonNull software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedAsyncClient getEnhancedClient()
      Returns the underlying DynamoDbEnhancedAsyncClient.
      Specified by:
      getEnhancedClient in interface AsyncDynamoSimplifiedClientInterface
      Returns:
      the enhanced async DynamoDB client
    • getDynamoDbClient

      public @NonNull software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient getDynamoDbClient()
      Returns the underlying DynamoDbAsyncClient.
      Specified by:
      getDynamoDbClient in interface AsyncDynamoSimplifiedClientInterface
      Returns:
      the DynamoDB async client
    • listTables

      public @NonNull CompletableFuture<List<String>> listTables()
      Lists all DynamoDB tables asynchronously.
      Specified by:
      listTables in interface AsyncDynamoSimplifiedClientInterface
      Returns:
      a CompletableFuture containing a list of table names
    • executeStatement

      public @NonNull CompletableFuture<software.amazon.awssdk.services.dynamodb.model.ExecuteStatementResponse> executeStatement(@NonNull software.amazon.awssdk.services.dynamodb.model.ExecuteStatementRequest request)
      Executes a PartiQL statement against DynamoDB asynchronously.

      This is a passthrough to the underlying low-level DynamoDbAsyncClient.executeStatement(ExecuteStatementRequest).

      Specified by:
      executeStatement in interface AsyncDynamoSimplifiedClientInterface
      Parameters:
      request - the PartiQL request to execute
      Returns:
      a CompletableFuture containing the response
    • close

      public void close()
      Closes the underlying DynamoDB async clients, releasing any network resources.

      After calling this method, the client instance is no longer usable.

      Specified by:
      close in interface AsyncDynamoSimplifiedClientInterface
      Specified by:
      close in interface AutoCloseable