feat: Dynamic socket-name URL routing for multi-service support #17

Merged
mahmoud merged 1 commit from development_hero_compute_support into development 2026-04-08 11:31:27 +00:00
Owner

Summary

  • Add two-segment URL routing: /{service}/{socket_name}/* with dynamic filesystem lookup
  • Fix test mock backends to use per-service directory layout
  • Backward compatible — existing /{service}/* routing unchanged as fallback

How it works

When a request arrives at /{service}/{second_segment}/*, hero_proxy checks if $HERO_SOCKET_DIR/{service}/{second_segment}.sock exists on disk. If found, routes to it with the prefix stripped. Otherwise falls back to existing find_socket_for() single-segment routing.

/hero_compute/rpc/api/root/cloud/rpc
  → exists: hero_compute/rpc.sock ✓
  → forward: /api/root/cloud/rpc

/hero_compute/explorer_rpc/api/root/explorer/rpc
  → exists: hero_compute/explorer_rpc.sock ✓
  → forward: /api/root/explorer/rpc

/hero_compute/unknown
  → exists: hero_compute/unknown.sock ✗
  → fallback: find_socket_for("hero_compute")

No hardcoded socket types — any .sock file a service creates is automatically routable.

Test plan

  • cargo build --workspace passes
  • cargo clippy --workspace --all-targets -- -D warnings passes
  • cargo test --workspace — 97 passed, 0 failed
  • Integration test with hero_compute multi-node

Closes #16

## Summary - Add two-segment URL routing: `/{service}/{socket_name}/*` with dynamic filesystem lookup - Fix test mock backends to use per-service directory layout - Backward compatible — existing `/{service}/*` routing unchanged as fallback ## How it works When a request arrives at `/{service}/{second_segment}/*`, hero_proxy checks if `$HERO_SOCKET_DIR/{service}/{second_segment}.sock` exists on disk. If found, routes to it with the prefix stripped. Otherwise falls back to existing `find_socket_for()` single-segment routing. ``` /hero_compute/rpc/api/root/cloud/rpc → exists: hero_compute/rpc.sock ✓ → forward: /api/root/cloud/rpc /hero_compute/explorer_rpc/api/root/explorer/rpc → exists: hero_compute/explorer_rpc.sock ✓ → forward: /api/root/explorer/rpc /hero_compute/unknown → exists: hero_compute/unknown.sock ✗ → fallback: find_socket_for("hero_compute") ``` No hardcoded socket types — any `.sock` file a service creates is automatically routable. ## Test plan - [x] `cargo build --workspace` passes - [x] `cargo clippy --workspace --all-targets -- -D warnings` passes - [x] `cargo test --workspace` — 97 passed, 0 failed - [ ] Integration test with hero_compute multi-node Closes #16
feat: dynamic socket-name URL routing for multi-service support
All checks were successful
Test / test (push) Successful in 1m21s
Test / test (pull_request) Successful in 1m29s
4918fc3929
Add two-segment URL routing: /{service}/{socket_name}/*

When a request arrives at /{service}/{second_segment}/*, hero_proxy
checks if $HERO_SOCKET_DIR/{service}/{second_segment}.sock exists.
If found, routes to it directly with the prefix stripped.
Falls back to the existing find_socket_for() single-segment routing.

This enables callers to target specific sockets by name:
  /hero_compute/rpc/*           → hero_compute/rpc.sock
  /hero_compute/explorer_rpc/* → hero_compute/explorer_rpc.sock
  /hero_compute/ui/*           → hero_compute/ui.sock

No hardcoded socket types — any .sock file is automatically routable.

Also fixes test mock backends to use per-service directory layout
(rpc.sock inside service subdirectory) matching current socket strategy.

Closes #16
mahmoud merged commit bee53618c7 into development 2026-04-08 11:31:27 +00:00
mahmoud deleted branch development_hero_compute_support 2026-04-08 11:31:33 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_proxy!17
No description provided.