Commit adba72d
webserver: decompose on_methods_ under the CCN 10 bar (28 -> 7)
webserver::on_methods_ was a 171-line registration entry point doing
input validation, v1-map find-or-create-shim, atomicity pre-check,
slot installation, v1 insertion across three maps, and v2 3-tier
table mirror (radix vs exact vs regex_, with fresh-insert vs methods-
merge sub-paths). CCN 28.
Decomposed into private member helpers on detail::webserver_impl:
prepare_or_create_lambda_shim v1 find-or-create + atomicity pre-check
commit_handlers_to_shim install the handler into every slot
insert_fresh_v1_entries v1 maps insertion (str + regex tiers)
upsert_v2_table_entry v2 3-tier orchestrator
upsert_v2_param_route radix tier (read-merge-reinsert)
insert_fresh_v2_entry exact / regex_ first-insert
update_existing_v2_entry merge methods into existing entry
on_methods_ on webserver now reads as: validate args, build endpoint,
acquire registered_resources_mutex once for the v1 work, release it,
do the v2 work under route_table_mutex_ internally, invalidate cache.
CCN 7. Every new helper sits at CCN <= 7.
Also dedupes the pre-check loop (line 539) vs commit loop (line 558)
duplication flagged by `make lint-duplication` at low minimum-tokens
sensitivity: extracts a file-scope `for_each_requested_method` template
helper that iterates http_method::count_ in enum order (TASK-021's
Allow-header serialization order) and invokes the callback only for
methods set in the requested mask. Both former loops collapse to two-
line callback invocations.
Locking discipline preserved: registered_resources_mutex (unique_lock)
held across the v1 helpers, dropped at end of inner scope; route_table_mutex_
held inside upsert_v2_table_entry only. Lock order is registered_resources
-> route_table -> route_cache, identical to the original.
Verified locally: full `make check`.
scripts/check-complexity.sh CCN_MAX ratcheted 29 -> 23 (the new worst
offender is http_endpoint::http_endpoint at CCN 22).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b24eb7c commit adba72d
3 files changed
Lines changed: 207 additions & 143 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
478 | 480 | | |
479 | 481 | | |
480 | 482 | | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
481 | 516 | | |
482 | 517 | | |
483 | 518 | | |
| |||
0 commit comments