WeixinStateStore
public interface WeixinStateStore
io/agentscope/extensions/channel/weixin/WeixinStateStore.java:26–77定义 Weixin 状态存储契约的接口。位于 io.agentscope.extensions.channel.weixin 包。核心成员包括 loadCursor、loadContextToken、saveContextToken、acquireLease、renewLease、isLeaseCurrent。
Account-scoped state for at-least-once message processing. Implementations must atomically validate the unexpired lease on every mutation. External Agent and provider side effects are not part of this transaction and can be repeated after a crash.
方法摘要Method Summary
方法详情Method Detail
loadCursor
public String loadCursor(String accountId)
加载游标。
Loads the cursor.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
Stringio/agentscope/extensions/channel/weixin/WeixinStateStore.java:27loadContextToken
public String loadContextToken(String accountId, String peerId)
加载上下文令牌。
Loads the context token.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
peerId | String | 对端标识(类型 `String`)。The peer id. |
Stringio/agentscope/extensions/channel/weixin/WeixinStateStore.java:29saveContextToken
public boolean saveContextToken(String accountId, WeixinLease lease, String peerId, String token)
保存上下文令牌。
Saves the context token.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
peerId | String | 对端标识(类型 `String`)。The peer id. |
token | String | 令牌(类型 `String`)。The token. |
booleanio/agentscope/extensions/channel/weixin/WeixinStateStore.java:31acquireLease
public Optional<WeixinLease> acquireLease(String accountId, String holderId, long leaseMs)
执行 acquireLease 方法。
A released or expired lease must never reuse its generation, even for the same holder.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
holderId | String | holder 标识(类型 `String`)。The holder id. |
leaseMs | long | lease Ms(类型 `long`)。The lease ms. |
Optional<WeixinLease>io/agentscope/extensions/channel/weixin/WeixinStateStore.java:34renewLease
public boolean renewLease(String accountId, WeixinLease lease, long leaseMs)
执行 renewLease 方法。
Performs the renew lease operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
leaseMs | long | lease Ms(类型 `long`)。The lease ms. |
booleanio/agentscope/extensions/channel/weixin/WeixinStateStore.java:36isLeaseCurrent
public boolean isLeaseCurrent(String accountId, WeixinLease lease)
判断是否 isLeaseCurrent。
Returns whether the lease current.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
booleanio/agentscope/extensions/channel/weixin/WeixinStateStore.java:38releaseLease
public void releaseLease(String accountId, WeixinLease lease)
执行 releaseLease 方法。
Performs the release lease operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
io/agentscope/extensions/channel/weixin/WeixinStateStore.java:40acceptBatch
public boolean acceptBatch(String accountId, WeixinLease lease, String nextCursor, List<WeixinInboxMessage> messages)
接受 acceptBatch。
Saves the whole batch and its cursor in one transaction, deduplicating message IDs.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
nextCursor | String | 下一个游标(类型 `String`)。The next cursor. |
messages | List<WeixinInboxMessage> | 消息列表(类型 `List`)。The messages. |
booleanio/agentscope/extensions/channel/weixin/WeixinStateStore.java:43–47claimMessages
public List<WeixinInboxClaim> claimMessages(String accountId, WeixinLease lease, int limit, long claimMs)
执行 claimMessages 方法。
Claims in reception order.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
limit | int | 数量上限(类型 `int`)。The limit. |
claimMs | long | claim Ms(类型 `long`)。The claim ms. |
List<WeixinInboxClaim>io/agentscope/extensions/channel/weixin/WeixinStateStore.java:50–51completeMessage
public boolean completeMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim)
执行 completeMessage 方法。
Only the exact, unexpired claim may finish.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
claim | WeixinInboxClaim | claim(类型 `WeixinInboxClaim`)。The claim. |
booleanio/agentscope/extensions/channel/weixin/WeixinStateStore.java:54failMessage
public boolean failMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim)
执行 failMessage 方法。
Performs the fail message operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
claim | WeixinInboxClaim | claim(类型 `WeixinInboxClaim`)。The claim. |
booleanio/agentscope/extensions/channel/weixin/WeixinStateStore.java:56abandonMessage
public boolean abandonMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim)
执行 abandonMessage 方法。
Drops a claimed message the consumer will not retry again — the dispatch kept failing, or the provider kept refusing the reply.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
lease | WeixinLease | lease(类型 `WeixinLease`)。The lease. |
claim | WeixinInboxClaim | claim(类型 `WeixinInboxClaim`)。The claim. |
booleanio/agentscope/extensions/channel/weixin/WeixinStateStore.java:63removeAccount
default public void removeAccount(String accountId)
移除 removeAccount。
Forgets everything held for accountId: cursor, peer context tokens and inbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accountId | String | account 标识(类型 `String`)。The account id. |
io/agentscope/extensions/channel/weixin/WeixinStateStore.java:72inMemory
static public WeixinStateStore inMemory()
返回in 记忆。
Returns the in memory.
WeixinStateStoreio/agentscope/extensions/channel/weixin/WeixinStateStore.java:74–76