Skip to content

config: wire message_interval_time into the rate limiter#529

Open
ZayanKhan-12 wants to merge 1 commit into
teslamotors:mainfrom
ZayanKhan-12:wire-rate-limit-interval
Open

config: wire message_interval_time into the rate limiter#529
ZayanKhan-12 wants to merge 1 commit into
teslamotors:mainfrom
ZayanKhan-12:wire-rate-limit-interval

Conversation

@ZayanKhan-12

Copy link
Copy Markdown

Problem

The websocket rate limiter is constructed from RateLimit.MessageIntervalTimeSecond (server/streaming/socket.go):

rl = rate.New(sm.config.RateLimit.MessageLimit, sm.config.RateLimit.MessageIntervalTimeSecond)

But that field has no JSON tag and is never populated when the config is loaded — only tests set it directly (grep -rn MessageIntervalTimeSecond over non-test code finds only the declaration and the read above). For every config-driven deployment the interval is 0, and go-rate's Try() never limits with a zero interval (diff < r.interval can't be true).

Net effect: "rate_limit": {"enabled": true, ...} — as in examples/server_config.json — silently does nothing.

Fix

  • Populate MessageIntervalTimeSecond from the decoded message_interval_time value (seconds, matching the example config) in loadApplicationConfig.
  • Document message_interval_time in the README's rate_limit block, which previously omitted it.

go build and go vet ./config/... pass locally (the config test binary needs an arm64 libzmq to link, which this machine lacks — CI will exercise it).

🤖 Generated with Claude Code

The websocket rate limiter is constructed with
RateLimit.MessageIntervalTimeSecond, but that field has no JSON tag
and was never populated from the decoded config: only tests set it
directly. For every config-driven deployment, the interval was 0,
and go-rate's Try() never limits with a zero interval - so
"rate_limit": {"enabled": true, ...} silently did nothing.

Populate MessageIntervalTimeSecond from message_interval_time (as
used by examples/server_config.json) when loading the config, and
document the key in the README's rate_limit block.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant