PostgresSandboxExecutionGuard
public final class PostgresSandboxExecutionGuard implements SandboxExecutionGuard
io/agentscope/extensions/postgresql/sandbox/PostgresSandboxExecutionGuard.java:48–200Postgres 沙箱执行守卫,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.extensions.postgresql.sandbox 包,实现 SandboxExecutionGuard。核心成员包括 builder、tryEnter。
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
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 A class in io.agentscope.extensions.postgresql.sandbox that persists and restores session and memory data across calls. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Builder builder(DataSource dataSource)static | 返回构建器实例。 Performs the builder operation. |
public SandboxLease tryEnter(SandboxIsolationKey key) throws InterruptedException | 设置该参数。 Performs the try enter operation. |
方法详情Method Detail
builder
public static Builder builder(DataSource dataSource)
返回构建器实例。
Performs the builder operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
dataSource | DataSource | 数据来源(类型 `DataSource`)。The data source. |
Builderio/agentscope/extensions/postgresql/sandbox/PostgresSandboxExecutionGuard.java:64–66tryEnter
public SandboxLease tryEnter(SandboxIsolationKey key) throws InterruptedException
设置该参数。
Performs the try enter operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | SandboxIsolationKey | 键(类型 `SandboxIsolationKey`)。The key. |
SandboxLeaseInterruptedException可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
io/agentscope/extensions/postgresql/sandbox/PostgresSandboxExecutionGuard.java:68–127嵌套类详情Nested Class Detail
Builder
public static final class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.extensions.postgresql.sandbox 包。核心成员包括 keyPrefix、lockTimeout、build。
A class in io.agentscope.extensions.postgresql.sandbox that persists and restores session and memory data across calls. Declared in io.agentscope.extensions.postgresql.sandbox.