LocalPeriodicGate
public final class LocalPeriodicGate implements PeriodicGate
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
minGap | Duration | 最小 Gap(类型 `Duration`)。The min gap. |
booleanio/agentscope/harness/agent/coordination/LocalPeriodicGate.java:39–52cleanupStaleEntries
public void cleanupStaleEntries(Duration maxAge)
设置该参数。
Removes entries whose last claim is older than maxAge.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
maxAge | Duration | 最大 Age(类型 `Duration`)。The max age. |
io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:58–64clearForTests
public static void clearForTests()
清空 clearForTests。
Clears all entries — for unit tests only.
io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:67–69seedLastClaimAtForTests
public static void seedLastClaimAtForTests(String name, Instant instant)
执行 seedLastClaimAtForTests 方法。
Seeds a claim timestamp — for unit tests only.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
instant | Instant | instant(类型 `Instant`)。The instant. |
io/agentscope/harness/agent/coordination/LocalPeriodicGate.java:72–76hasClaimForTests
public static boolean hasClaimForTests(String name)
判断是否具有 hasClaimForTests。
Returns whether a named slot exists — for unit tests only.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
booleanio/agentscope/harness/agent/coordination/LocalPeriodicGate.java:79–81