PostgresDistributedStore
@Deprecated(since = "2.1", forRemoval = true) public class PostgresDistributedStore implements DistributedStore
io/agentscope/extensions/postgresql/PostgresDistributedStore.java:63–101Postgres 分布式存储,负责持久化与读取数据。位于 io.agentscope.extensions.postgresql 包,实现 DistributedStore。核心成员包括 create、agentStateStore、baseStore、sandboxSnapshotSpec、sandboxExecutionGuard。
PostgreSQL-backed DistributedStore.
Usage:
`DataSource dataSource = ... // HikariCP, Druid, etc.
HarnessAgent agent = HarnessAgent.builder()
.name("my-agent")
.model("dashscope:qwen-plus")
.distributedStore(PostgresDistributedStore.create(dataSource))
.filesystem(new DockerFilesystemSpec()
.image("ubuntu:24.04"))
.build();
`
This configures:
-
PostgresAgentStateStore— agent session state in PostgreSQL -
PostgresBaseStore— workspace filesystem KV in PostgreSQL -
PostgresSnapshotSpec— sandbox snapshots as BYTEAs in PostgreSQL -
PostgresSandboxExecutionGuard— distributed lock via PostgreSQL advisory locks
The target database must already exist; schema and tables are created automatically by default.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static PostgresDistributedStore create(DataSource dataSource)static | 创建PostgreSQL 分布式存储。 Creates a PostgreSQL distributed store. |
public AgentStateStore agentStateStore() | 返回智能体状态存储。 Returns the agent state store. |
public BaseStore baseStore() | 返回基类存储。 Returns the base store. |
public SandboxSnapshotSpec sandboxSnapshotSpec() | 返回沙箱快照规格。 Returns the sandbox snapshot spec. |
public SandboxExecutionGuard sandboxExecutionGuard() | 返回沙箱执行守卫。 Returns the sandbox execution guard. |
方法详情Method Detail
create
public static PostgresDistributedStore create(DataSource dataSource)
创建PostgreSQL 分布式存储。
Creates a PostgreSQL distributed store.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
dataSource | DataSource | 用于PostgreSQL的JDBC 数据来源。JDBC data source for PostgreSQL |
PostgresDistributedStoreio/agentscope/extensions/postgresql/PostgresDistributedStore.java:78–80agentStateStore
public AgentStateStore agentStateStore()
返回智能体状态存储。
Returns the agent state store.
AgentStateStoreio/agentscope/extensions/postgresql/PostgresDistributedStore.java:82–85baseStore
public BaseStore baseStore()
返回基类存储。
Returns the base store.
BaseStoreio/agentscope/extensions/postgresql/PostgresDistributedStore.java:87–90sandboxSnapshotSpec
public SandboxSnapshotSpec sandboxSnapshotSpec()
返回沙箱快照规格。
Returns the sandbox snapshot spec.
SandboxSnapshotSpecio/agentscope/extensions/postgresql/PostgresDistributedStore.java:92–95sandboxExecutionGuard
public SandboxExecutionGuard sandboxExecutionGuard()
返回沙箱执行守卫。
Returns the sandbox execution guard.
SandboxExecutionGuardio/agentscope/extensions/postgresql/PostgresDistributedStore.java:97–100