Commit 21296ac
refactor: extract route_table collaborator from webserver_impl
C-4 of the webserver_impl god-object decomposition. Move the v2 3-tier
route table (exact / radix / regex) and its LRU cache front-end out of
detail::webserver_impl into a dedicated detail::route_table collaborator.
route_table owns route_table_mutex_, the three tiers (exact_routes_,
param_and_prefix_routes_, regex_routes_ + the nested regex_route struct),
route_lru_cache, the tier_hit / lookup_result types, and the routing
primitives: the lookup pipeline (lookup_v2 + canonicalize_lookup_path),
invalidate_route_cache, register_v2_route, and the locked upsert/reject
family (find_v2_entry_by_path_, upsert_v2_table_entry_locked_ and its
sub-helpers, reject_terminus_collision, reject_duplicate_v2_entry_).
Lock ownership stays with the orchestrator (scoped-lock design): the
on_*/route registration sequence in webserver::on_methods_ holds
routes_.lock_for_write() across the conflict probe + table mutation, and
the lambda_resource shim-creation POLICY (prepare_or_create_lambda_shim /
commit_handlers_to_shim) stays on webserver_impl -- only the containers,
the lookup, and the locked table primitives moved. register/unregister
sweep the tiers directly under lock_for_write() (route_table members are
public, matching the webserver_impl / hook_bus stance). The
table-before-cache lock order is now an internal invariant of route_table.
webserver_impl keeps thin lookup_v2 / invalidate_route_cache forwarders
plus tier_hit / lookup_result type aliases, so every dispatch call site
and all ~8 white-box routing test/bench files compile unchanged.
resolve_resource_for_request stays on webserver_impl as dispatch glue
(applies captured params to the request, sets matched_path_template).
New files: src/httpserver/detail/route_table.hpp + src/detail/route_table.cpp.
Build clean; 109/109 tests PASS; file-size gate PASS.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 1f9a82e commit 21296ac
10 files changed
Lines changed: 833 additions & 649 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
0 commit comments