AS AgentScopeAPI 手册 / API Reference

WeixinStateStore

public interface WeixinStateStore
源码Source 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说明Description
public String loadCursor(String accountId)
加载游标。
Loads the cursor.
public String loadContextToken(String accountId, String peerId)
加载上下文令牌。
Loads the context token.
public boolean saveContextToken(String accountId, WeixinLease lease, String peerId, String token)
保存上下文令牌。
Saves the context token.
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.
public boolean renewLease(String accountId, WeixinLease lease, long leaseMs)
执行 `renewLease` 方法。
Performs the renew lease operation.
public boolean isLeaseCurrent(String accountId, WeixinLease lease)
判断是否 `isLeaseCurrent`。
Returns whether the lease current.
public void releaseLease(String accountId, WeixinLease lease)
执行 `releaseLease` 方法。
Performs the release lease operation.
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.
public List<WeixinInboxClaim> claimMessages(String accountId, WeixinLease lease, int limit, long claimMs)
执行 `claimMessages` 方法。
Claims in reception order.
public boolean completeMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim)
执行 `completeMessage` 方法。
Only the exact, unexpired claim may finish.
public boolean failMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim)
执行 `failMessage` 方法。
Performs the fail message operation.
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.
default public void removeAccount(String accountId)
default
移除 `removeAccount`。
Forgets everything held for `accountId`: cursor, peer context tokens and inbox.
static public WeixinStateStore inMemory()
static
返回in 记忆。
Returns the in memory.

方法详情Method Detail

loadCursor

public String loadCursor(String accountId)

加载游标。

Loads the cursor.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:27

loadContextToken

public String loadContextToken(String accountId, String peerId)

加载上下文令牌。

Loads the context token.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
peerIdString对端标识(类型 `String`)。The peer id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:29

saveContextToken

public boolean saveContextToken(String accountId, WeixinLease lease, String peerId, String token)

保存上下文令牌。

Saves the context token.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
peerIdString对端标识(类型 `String`)。The peer id.
tokenString令牌(类型 `String`)。The token.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:31

acquireLease

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.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
holderIdStringholder 标识(类型 `String`)。The holder id.
leaseMslonglease Ms(类型 `long`)。The lease ms.
返回Returns Optional<WeixinLease>
返回可选。Returns optional.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:34

renewLease

public boolean renewLease(String accountId, WeixinLease lease, long leaseMs)

执行 renewLease 方法。

Performs the renew lease operation.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
leaseMslonglease Ms(类型 `long`)。The lease ms.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:36

isLeaseCurrent

public boolean isLeaseCurrent(String accountId, WeixinLease lease)

判断是否 isLeaseCurrent。

Returns whether the lease current.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:38

releaseLease

public void releaseLease(String accountId, WeixinLease lease)

执行 releaseLease 方法。

Performs the release lease operation.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:40

acceptBatch

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.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
nextCursorString下一个游标(类型 `String`)。The next cursor.
messagesList<WeixinInboxMessage>消息列表(类型 `List`)。The messages.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:43–47

claimMessages

public List<WeixinInboxClaim> claimMessages(String accountId, WeixinLease lease, int limit, long claimMs)

执行 claimMessages 方法。

Claims in reception order.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
limitint数量上限(类型 `int`)。The limit.
claimMslongclaim Ms(类型 `long`)。The claim ms.
返回Returns List<WeixinInboxClaim>
返回列出。Returns list.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:50–51

completeMessage

public boolean completeMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim)

执行 completeMessage 方法。

Only the exact, unexpired claim may finish.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
claimWeixinInboxClaimclaim(类型 `WeixinInboxClaim`)。The claim.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:54

failMessage

public boolean failMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim)

执行 failMessage 方法。

Performs the fail message operation.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
claimWeixinInboxClaimclaim(类型 `WeixinInboxClaim`)。The claim.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:56

abandonMessage

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.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
leaseWeixinLeaselease(类型 `WeixinLease`)。The lease.
claimWeixinInboxClaimclaim(类型 `WeixinInboxClaim`)。The claim.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:63

removeAccount

default public void removeAccount(String accountId)
default

移除 removeAccount。

Forgets everything held for accountId: cursor, peer context tokens and inbox.

参数Parameters
名称Name类型Type说明Description
accountIdStringaccount 标识(类型 `String`)。The account id.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:72

inMemory

static public WeixinStateStore inMemory()
static

返回in 记忆。

Returns the in memory.

返回Returns WeixinStateStore
返回WeixinStateStore。Returns weixin state store.
源码Source io/agentscope/extensions/channel/weixin/WeixinStateStore.java:74–76
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.