惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Jina AI
Jina AI
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
I
InfoQ
L
LangChain Blog
The Cloudflare Blog
IT之家
IT之家
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
博客园 - 聂微东
美团技术团队
博客园_首页

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(discord): normalize scheduler numeric options · openc...
steipete · 2026-05-29 · via Recent Commits to openclaw:main
1+

import { resolveIntegerOption } from "openclaw/plugin-sdk/number-runtime";

12

import { RateLimitError, readRetryAfter } from "./rest-errors.js";

23

import { createBucketKey, createRouteKey, readHeaderNumber, readResetAt } from "./rest-routes.js";

34

@@ -47,6 +48,29 @@ export type RestSchedulerOptions = {

4748

const INVALID_REQUEST_WINDOW_MS = 10 * 60_000;

4849

const requestPriorities = ["critical", "standard", "background"] as const;

495051+

function normalizeRestSchedulerOptions(options: RestSchedulerOptions): RestSchedulerOptions {

52+

return {

53+

lanes: {

54+

critical: normalizeLaneOptions(options.lanes.critical),

55+

standard: normalizeLaneOptions(options.lanes.standard),

56+

background: normalizeLaneOptions(options.lanes.background),

57+

},

58+

maxConcurrency: resolveIntegerOption(options.maxConcurrency, 1, { min: 1 }),

59+

maxQueueSize: resolveIntegerOption(options.maxQueueSize, 1, { min: 1 }),

60+

maxRateLimitRetries: resolveIntegerOption(options.maxRateLimitRetries, 0, { min: 0 }),

61+

};

62+

}

63+64+

function normalizeLaneOptions(options: RestSchedulerLaneOptions): RestSchedulerLaneOptions {

65+

return {

66+

maxQueueSize: resolveIntegerOption(options.maxQueueSize, 1, { min: 1 }),

67+

...(options.staleAfterMs === undefined

68+

? {}

69+

: { staleAfterMs: resolveIntegerOption(options.staleAfterMs, 0, { min: 0 }) }),

70+

weight: resolveIntegerOption(options.weight, 1, { min: 1 }),

71+

};

72+

}

73+5074

function createLaneQueues<TData>(): LaneQueues<TData> {

5175

return {

5276

critical: [],

@@ -60,6 +84,7 @@ function countPending<TData>(bucket: BucketState<TData>): number {

6084

}

61856286

export class RestScheduler<TData> {

87+

private readonly options: RestSchedulerOptions;

6388

private activeWorkers = 0;

6489

private buckets = new Map<string, BucketState<TData>>();

6590

private drainTimer: NodeJS.Timeout | undefined;

@@ -82,10 +107,11 @@ export class RestScheduler<TData> {

82107

private routeBuckets = new Map<string, string>();

8310884109

constructor(

85-

private readonly options: RestSchedulerOptions,

110+

options: RestSchedulerOptions,

86111

private readonly executor: (request: ScheduledRequest<TData>) => Promise<unknown>,

87112

) {

88-

this.laneSchedule = this.buildLaneSchedule(options.lanes);

113+

this.options = normalizeRestSchedulerOptions(options);

114+

this.laneSchedule = this.buildLaneSchedule(this.options.lanes);

89115

}

9011691117

enqueue(params: {

@@ -186,11 +212,11 @@ export class RestScheduler<TData> {

186212

}

187213188214

private get maxConcurrentWorkers(): number {

189-

return Math.max(1, Math.floor(this.options.maxConcurrency));

215+

return this.options.maxConcurrency;

190216

}

191217192218

private get maxRateLimitRetries(): number {

193-

return Math.max(0, Math.floor(this.options.maxRateLimitRetries));

219+

return this.options.maxRateLimitRetries;

194220

}

195221196222

private getBucket(key: string): BucketState<TData> {

@@ -528,7 +554,7 @@ export class RestScheduler<TData> {

528554

private buildLaneSchedule(lanes: Record<RequestPriority, RestSchedulerLaneOptions>) {

529555

const schedule: RequestPriority[] = [];

530556

for (const lane of requestPriorities) {

531-

const weight = Math.max(1, Math.floor(lanes[lane].weight));

557+

const weight = lanes[lane].weight;

532558

for (let i = 0; i < weight; i += 1) {

533559

schedule.push(lane);

534560

}