Class PostgresSandboxExecutionGuard
java.lang.Object
io.agentscope.extensions.postgresql.sandbox.PostgresSandboxExecutionGuard
- All Implemented Interfaces:
io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
public final class PostgresSandboxExecutionGuard
extends Object
implements io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
PostgreSQL advisory-lock-based
SandboxExecutionGuard.
Each lock is identified by a 64-bit key derived from the SandboxIsolationKey's scope
and value via MurmurHash3. The lock is acquired with pg_advisory_lock(key) and released
with pg_advisory_unlock(key).
The lock is tied to the database connection — when the connection closes, the lock is
automatically released. The returned SandboxLease.close() calls
pg_advisory_unlock(key) and closes the underlying connection.
A configurable timeout is supported by polling pg_try_advisory_lock(key) until the
lock is acquired or the timeout expires, matching the semantics of MySQL's
GET_LOCK(name, timeout).
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.agentscope.harness.agent.sandbox.SandboxExecutionGuard
io.agentscope.harness.agent.sandbox.SandboxExecutionGuard.NoopSandboxExecutionGuard -
Method Summary
Modifier and TypeMethodDescriptionbuilder(DataSource dataSource) io.agentscope.harness.agent.sandbox.SandboxLeasetryEnter(io.agentscope.harness.agent.sandbox.SandboxIsolationKey key)
-
Method Details
-
builder
-
tryEnter
public io.agentscope.harness.agent.sandbox.SandboxLease tryEnter(io.agentscope.harness.agent.sandbox.SandboxIsolationKey key) throws InterruptedException - Specified by:
tryEnterin interfaceio.agentscope.harness.agent.sandbox.SandboxExecutionGuard- Throws:
InterruptedException
-