Class CosmosSessionStoreOptions

java.lang.Object
com.google.genkit.plugins.azurefoundry.session.CosmosSessionStoreOptions

public final class CosmosSessionStoreOptions extends Object
Configuration for CosmosSessionStore.

The store persists all documents in a single Cosmos DB container (default database "genkit", container "genkit-sessions") partitioned by /pk (the per-tenant prefix). Each document's id discriminates snapshot, shard, and pointer records. All documents for a tenant share the same pk, derived from getSnapshotPathPrefix() (default "global").

The default getShardSize() is 1048576 bytes, kept safely under the Cosmos DB 2 MB document-size limit; because the store forces a checkpoint whenever a diff would exceed the shard size, diff documents stay bounded too.

  • Field Details

    • DEFAULT_DATABASE

      public static final String DEFAULT_DATABASE
      Default database name.
      See Also:
    • DEFAULT_CONTAINER

      public static final String DEFAULT_CONTAINER
      Default container name.
      See Also:
    • DEFAULT_CHECKPOINT_INTERVAL

      public static final int DEFAULT_CHECKPOINT_INTERVAL
      Default number of turns between full checkpoints.
      See Also:
    • DEFAULT_SHARD_SIZE

      public static final int DEFAULT_SHARD_SIZE
      Default shard size in bytes for checkpoint state (1 MiB, under the 2 MB document cap).
      See Also:
    • DEFAULT_POLL_INTERVAL_MS

      public static final long DEFAULT_POLL_INTERVAL_MS
      Default subscription poll interval in milliseconds.
      See Also:
  • Method Details

    • getDatabaseName

      public String getDatabaseName()
      Returns the Cosmos DB database name (default "genkit").
      Returns:
      the database name
    • getContainerName

      public String getContainerName()
      Returns the Cosmos DB container name (default "genkit-sessions").
      Returns:
      the container name
    • getCheckpointInterval

      public int getCheckpointInterval()
      Returns the number of turns between full checkpoints (default 25).
      Returns:
      the checkpoint interval
    • getShardSize

      public int getShardSize()
      Returns the shard size in bytes for checkpoint state (default 1048576).
      Returns:
      the shard size in bytes
    • getSnapshotPathPrefix

      public Function<SessionStoreOptions,String> getSnapshotPathPrefix()
      Returns the function that derives the per-tenant partition-key prefix from the per-request store options (default o -> "global").
      Returns:
      the prefix function
    • isCreateIfNotExists

      public boolean isCreateIfNotExists()
      Returns whether the store should create the database and container on first use if they do not exist (default false).
      Returns:
      true if the database/container should be created when missing
    • getPollIntervalMs

      public long getPollIntervalMs()
      Returns the subscription poll interval in milliseconds (default 2000L).
      Returns:
      the poll interval in milliseconds
    • defaults

      public static CosmosSessionStoreOptions defaults()
      Returns default options.
      Returns:
      a CosmosSessionStoreOptions with all defaults
    • builder

      public static CosmosSessionStoreOptions.Builder builder()
      Creates a new builder.
      Returns:
      a new builder