Class MongoSessionStoreOptions

java.lang.Object
com.google.genkit.plugins.mongodb.session.MongoSessionStoreOptions

public final class MongoSessionStoreOptions extends Object
Configuration for MongoSessionStore.

The store persists all records in a single MongoDB collection (default database "genkit", collection "genkit_sessions"). Each document's _id combines the per-tenant prefix (default "global") with the record id; the record kind is discriminated by the id. Each document carries a version field used for optimistic concurrency.

The default getShardSize() is 1048576 bytes, kept safely under MongoDB's 16 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_COLLECTION

      public static final String DEFAULT_COLLECTION
      Default collection 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 16 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 MongoDB database name (default "genkit").
      Returns:
      the database name
    • getCollectionName

      public String getCollectionName()
      Returns the MongoDB collection name (default "genkit_sessions").
      Returns:
      the collection 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 prefix from the per-request store options (default o -> "global").
      Returns:
      the prefix function
    • getPollIntervalMs

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

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

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