SessionEventLog
@Service public class SessionEventLog
io/agentscope/builder/web/managed/service/SessionEventLog.java:48–410会话事件日志,承载智能体的部署、调度与服务化运行。位于 io.agentscope.builder.web.managed.service 包。核心成员包括 append、appendLocal、appendIdempotent、appendIdempotentLocal、list、listAfter。
Append-only session event log. Sequence numbers are allocated with conflict retry so control and
data planes can append concurrently against the shared (session_id, seq) unique
constraint. Live SSE fan-out is notification-driven and always reads from the durable sequence
cursor, so events written by any plane or replica are visible without treating notifications as
data.
构造器摘要Constructor Summary
方法摘要Method Summary
构造器详情Constructor Detail
SessionEventLog
public SessionEventLog(SessionEventEntityRepository repository, ManagedJsonHelper jsonHelper, TransactionTemplate transactionTemplate, DeletedSessionRegistry deletedSessions, SessionEventNotifier notifier, List<SessionEventMirror> mirrors, long recoveryIntervalMs)
初始化 SessionEventLog 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repository | SessionEventEntityRepository | 仓库(类型 `SessionEventEntityRepository`)。The repository. |
jsonHelper | ManagedJsonHelper | JSON Helper(类型 `ManagedJsonHelper`)。The json helper. |
transactionTemplate | TransactionTemplate | 事务模板(类型 `TransactionTemplate`)。The transaction template. |
deletedSessions | DeletedSessionRegistry | 已删除会话(类型 `DeletedSessionRegistry`)。The deleted sessions. |
notifier | SessionEventNotifier | notifier(类型 `SessionEventNotifier`)。The notifier. |
mirrors | List<SessionEventMirror> | mirrors(类型 `List`)。The mirrors. |
recoveryIntervalMs | long | recovery 间隔 Ms(类型 `long`)。The recovery interval ms. |
io/agentscope/builder/web/managed/service/SessionEventLog.java:62–78SessionEventLog
public SessionEventLog(SessionEventEntityRepository repository, ManagedJsonHelper jsonHelper, TransactionTemplate transactionTemplate, DeletedSessionRegistry deletedSessions, SessionEventNotifier notifier, long recoveryIntervalMs)
初始化 SessionEventLog 实例。
Constructor retained for focused tests and embedders without event mirrors.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repository | SessionEventEntityRepository | 仓库(类型 `SessionEventEntityRepository`)。The repository. |
jsonHelper | ManagedJsonHelper | JSON Helper(类型 `ManagedJsonHelper`)。The json helper. |
transactionTemplate | TransactionTemplate | 事务模板(类型 `TransactionTemplate`)。The transaction template. |
deletedSessions | DeletedSessionRegistry | 已删除会话(类型 `DeletedSessionRegistry`)。The deleted sessions. |
notifier | SessionEventNotifier | notifier(类型 `SessionEventNotifier`)。The notifier. |
recoveryIntervalMs | long | recovery 间隔 Ms(类型 `long`)。The recovery interval ms. |
io/agentscope/builder/web/managed/service/SessionEventLog.java:81–96方法详情Method Detail
append
public SessionEventDto append(String sessionId, String type, Map<String, Object> payload)
执行追加相关操作。
Appends an event with the next monotonic sequence number.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
type | String | 类型(类型 `String`)。The type. |
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
SessionEventDtoio/agentscope/builder/web/managed/service/SessionEventLog.java:103–105appendLocal
public SessionEventDto appendLocal(String sessionId, String type, Map<String, Object> payload, String eventId)
追加本地。
Appends locally without invoking generic mirrors; caller supplies an immutable scope.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
type | String | 类型(类型 `String`)。The type. |
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
eventId | String | 事件标识(类型 `String`)。The event id. |
SessionEventDtoio/agentscope/builder/web/managed/service/SessionEventLog.java:108–111append
public SessionEventDto append(String sessionId, String type, Map<String, Object> payload, String eventId)
执行追加相关操作。
Appends an event, optionally reusing a pre-allocated eventId so stream previews can reconcile with the persisted row.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
type | String | 类型(类型 `String`)。The type. |
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
eventId | String | 事件标识(类型 `String`)。The event id. |
SessionEventDtoio/agentscope/builder/web/managed/service/SessionEventLog.java:117–120appendIdempotent
public SessionEventDto appendIdempotent(String sessionId, String type, Map<String, Object> payload, String eventId)
追加 appendIdempotent。
Appends an event once using a caller-owned stable id.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
type | String | 类型(类型 `String`)。The type. |
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
eventId | String | 事件标识(类型 `String`)。The event id. |
SessionEventDtoio/agentscope/builder/web/managed/service/SessionEventLog.java:169–172appendIdempotentLocal
public SessionEventDto appendIdempotentLocal(String sessionId, String type, Map<String, Object> payload, String eventId)
追加 appendIdempotentLocal。
Appends/replays locally without an unscoped generic mirror.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
type | String | 类型(类型 `String`)。The type. |
payload | Map<String, Object> | 负载(类型 `Map`)。The payload. |
eventId | String | 事件标识(类型 `String`)。The event id. |
SessionEventDtoio/agentscope/builder/web/managed/service/SessionEventLog.java:175–178list
public List<SessionEventDto> list(String sessionId)
设置列表。
Lists all events for a session in sequence order.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
List<SessionEventDto>io/agentscope/builder/web/managed/service/SessionEventLog.java:263–266list
public List<SessionEventDto> list(String sessionId, Collection<String> types)
执行列表相关操作。
Lists events for a session, optionally restricted to types.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
types | Collection<String> | 类型(类型 `Collection`)。The types. |
List<SessionEventDto>io/agentscope/builder/web/managed/service/SessionEventLog.java:272–282listAfter
public List<SessionEventDto> listAfter(String sessionId, long afterSeq)
列出之后。
Lists events with sequence strictly greater than afterSeq.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
afterSeq | long | 之后 Seq(类型 `long`)。The after seq. |
List<SessionEventDto>io/agentscope/builder/web/managed/service/SessionEventLog.java:285–288listAfter
public List<SessionEventDto> listAfter(String sessionId, long afterSeq, Collection<String> types)
列出之后。
Lists events after afterSeq, optionally restricted to types.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
afterSeq | long | 之后 Seq(类型 `long`)。The after seq. |
types | Collection<String> | 类型(类型 `Collection`)。The types. |
List<SessionEventDto>io/agentscope/builder/web/managed/service/SessionEventLog.java:293–305getByEventId
public SessionEventDto getByEventId(String eventId)
获取通过事件标识。
Looks up a single event by its public identifier.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
eventId | String | 事件标识(类型 `String`)。The event id. |
SessionEventDtoio/agentscope/builder/web/managed/service/SessionEventLog.java:308–317subscribe
public Flux<SessionEventDto> subscribe(String sessionId)
设置订阅。
Returns a live flux of events for SSE streaming, starting after sequence 0.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
Flux<SessionEventDto>io/agentscope/builder/web/managed/service/SessionEventLog.java:320–322subscribe
public Flux<SessionEventDto> subscribe(String sessionId, long afterSeq)
执行订阅相关操作。
Reads events with sequence strictly greater than afterSeq after an immediate, in-process, or PostgreSQL cross-replica notification.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
afterSeq | long | 之后 Seq(类型 `long`)。The after seq. |
Flux<SessionEventDto>io/agentscope/builder/web/managed/service/SessionEventLog.java:333–356deleteBySessionId
public void deleteBySessionId(String sessionId)
删除通过会话标识。
Deletes all persisted events for a session that keeps running (transcript clear).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/builder/web/managed/service/SessionEventLog.java:368–371purgeDeletedSession
public void purgeDeletedSession(String sessionId)
设置该参数。
Deletes a session's events and refuses any later append for it.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/builder/web/managed/service/SessionEventLog.java:378–384