Class MongoSandboxExecutionGuard.Builder

java.lang.Object
io.agentscope.extensions.mongodb.sandbox.MongoSandboxExecutionGuard.Builder
Enclosing class:
MongoSandboxExecutionGuard

public static final class MongoSandboxExecutionGuard.Builder extends Object
  • Method Details

    • databaseName

      public MongoSandboxExecutionGuard.Builder databaseName(String databaseName)
    • collectionName

      public MongoSandboxExecutionGuard.Builder collectionName(String collectionName)
    • lockTimeout

      public MongoSandboxExecutionGuard.Builder lockTimeout(Duration timeout)
      Sets the maximum time to wait for acquiring the lock before MongoSandboxExecutionGuard.tryEnter(io.agentscope.harness.agent.sandbox.SandboxIsolationKey) throws InterruptedException. This bounds queueing delay only; it does NOT bound the lock's lifetime — that is controlled by leaseTtl(Duration).

      Default: 30 minutes.

      Parameters:
      timeout - the acquisition timeout; must be positive
      Returns:
      this builder
    • leaseTtl

      Sets the lifetime of the lock document (expiresAt) written on acquisition. While the returned lease is open, a background watchdog renews the lease every leaseTtl / 3, so executions longer than the TTL keep holding their lock. The TTL only matters when the holder dies without releasing: after leaseTtl the lock becomes eligible for reclamation by the next caller (MongoDB's TTL monitor may take up to 60 additional seconds to delete the document).

      Default: 30 minutes.

      Parameters:
      ttl - the lease TTL; must be positive
      Returns:
      this builder
    • retryInterval

      public MongoSandboxExecutionGuard.Builder retryInterval(Duration interval)
      Sets the polling interval between lock acquisition attempts.

      Default: 500 ms. Lower values reduce latency at the cost of more MongoDB round-trips; higher values reduce load at the cost of increased queuing delay.

      Parameters:
      interval - the retry interval; must be positive
      Returns:
      this builder
    • owner

      Sets a human-readable owner label for diagnostics. The owner is stored in the lock document for visibility but is NOT used for renewal or release filtering — a random UUID token is used instead to guarantee uniqueness across guard instances.
      Parameters:
      owner - the owner label
      Returns:
      this builder
    • build