Skip to content

gateway: implement pipeline handler chain#44

Merged
zevorn merged 1 commit intomainfrom
feat/gateway-pipeline
Mar 16, 2026
Merged

gateway: implement pipeline handler chain#44
zevorn merged 1 commit intomainfrom
feat/gateway-pipeline

Conversation

@zevorn
Copy link
Copy Markdown
Owner

@zevorn zevorn commented Mar 16, 2026

Summary

  • Wire up the gw_handler pipeline declared in gateway.h but never implemented
  • gateway_register_handler(name, fn) adds handlers to a static chain (max 8)
  • dispatch_msg() runs handlers in registration order before service dispatch
  • Handler returns: 0 = pass, 1 = consumed (stop), <0 = error (stop + log)
  • New gateway_stats.filtered counter tracks messages consumed by pipeline

Memory cost: ~64 bytes (8 x 8B handler slots).

Enables message filtering, transformation, and rate limiting as pre-dispatch hooks without touching the service dispatch logic.

Test plan

  • make test-unit — 25/25 passed (3 new gateway handler tests)
  • scripts/check-patch.sh --staged — 0 errors, 0 warnings

Wire up the gw_handler pipeline that was declared in gateway.h but
never used. Handlers registered via gateway_register_handler() now
run in registration order before service dispatch. A handler
returning 1 consumes the message (stops the chain); returning 0
passes it to the next handler; returning <0 is an error (logged
and stops the chain).

This enables message filtering, transformation, and rate limiting
without modifying the service dispatch logic.

Added gateway_stats.filtered counter for messages consumed by
pipeline handlers.

Unit tests: 3 new tests (handler register, overflow, stats).
All 25 unit tests pass.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
@zevorn zevorn merged commit f4f4cf9 into main Mar 16, 2026
9 checks passed
@zevorn zevorn deleted the feat/gateway-pipeline branch March 16, 2026 14:36
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