AS AgentScopeAPI 手册 / API Reference

LocalPeriodicGate

public final class LocalPeriodicGate implements PeriodicGate
源码Source io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:32–82

本地 Periodic Gate,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.coordination 包,实现 PeriodicGate。核心成员包括 tryClaim、cleanupStaleEntries、clearForTests、seedLastClaimAtForTests、hasClaimForTests。

JVM-local PeriodicGate backed by a process-wide ConcurrentHashMap and CAS updates. Suitable for single-process deployments or as the default when no distributed store is configured.

The map is static so the throttle window survives across HarnessAgent.Builder.build() calls — each rebuild creates new middleware instances, and an instance-level map would reset to Instant#EPOCH on every request.

方法摘要Method Summary

方法Method说明Description
public boolean tryClaim(String name, Duration minGap)
执行 `tryClaim` 方法。
Performs the try claim operation.
public void cleanupStaleEntries(Duration maxAge)
设置该参数。
Removes entries whose last claim is older than `maxAge`.
public static void clearForTests()
static
清空 `clearForTests`。
Clears all entries — for unit tests only.
public static void seedLastClaimAtForTests(String name, Instant instant)
static
执行 `seedLastClaimAtForTests` 方法。
Seeds a claim timestamp — for unit tests only.
public static boolean hasClaimForTests(String name)
static
判断是否具有 `hasClaimForTests`。
Returns whether a named slot exists — for unit tests only.

方法详情Method Detail

tryClaim

public boolean tryClaim(String name, Duration minGap)

执行 tryClaim 方法。

Performs the try claim operation.

参数Parameters
名称Name类型Type说明Description
nameString名称(类型 `String`)。The name.
minGapDuration最小 Gap(类型 `Duration`)。The min gap.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:39–52

cleanupStaleEntries

public void cleanupStaleEntries(Duration maxAge)

设置该参数。

Removes entries whose last claim is older than maxAge.

参数Parameters
名称Name类型Type说明Description
maxAgeDuration最大 Age(类型 `Duration`)。The max age.
源码Source io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:58–64

clearForTests

public static void clearForTests()
static

清空 clearForTests。

Clears all entries — for unit tests only.

源码Source io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:67–69

seedLastClaimAtForTests

public static void seedLastClaimAtForTests(String name, Instant instant)
static

执行 seedLastClaimAtForTests 方法。

Seeds a claim timestamp — for unit tests only.

参数Parameters
名称Name类型Type说明Description
nameString名称(类型 `String`)。The name.
instantInstantinstant(类型 `Instant`)。The instant.
源码Source io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:72–76

hasClaimForTests

public static boolean hasClaimForTests(String name)
static

判断是否具有 hasClaimForTests。

Returns whether a named slot exists — for unit tests only.

参数Parameters
名称Name类型Type说明Description
nameString名称(类型 `String`)。The name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:79–81
基于官方固定版本源码静态生成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.