- endpoint/crate-init: initialize crate, Cargo.toml, module skeleton - endpoint/registry: extract HandlerRegistry (~50 lines) - endpoint/endpoint-core: AlknetEndpoint fresh build against ADR-083 shape - endpoint/dispatch: public dispatch, build_auth_context, ACME guard - endpoint/accept-quinn: quinn accept loop + extractors (extracted) - endpoint/accept-iroh: iroh accept loop + extractors (extracted) - endpoint/accept-tcp-tls: TCP+TLS accept loop (new code) - endpoint/tests: move + adapt 17 tests - endpoint/review-endpoint: review checkpoint 7 generations, 3 parallel tasks (accept loops), no cycles. Depends on tls/review-tls (Phase 1 complete).
3.7 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | |
|---|---|---|---|---|---|---|---|---|
| endpoint/registry | Extract HandlerRegistry from alknet-core/endpoint.rs into alknet-endpoint | pending |
|
narrow | low | component | implementation |
Description
Phase 2, Task 2 of the crate extraction. Extract the HandlerRegistry type from
crates/alknet-core/src/endpoint.rs (lines 66-116) into crates/alknet-endpoint/src/registry.rs.
The old code stays in endpoint.rs (duplicated) — no breakage. The new crate is
self-contained and builds standalone.
Types to extract
From endpoint.rs lines 66-116:
| Type/Function | Lines | Destination |
|---|---|---|
HandlerRegistry struct |
66-68 | registry.rs |
HandlerRegistry::new() |
71-75 | registry.rs |
HandlerRegistry::register() |
77-86 | registry.rs |
HandlerRegistry::get() |
88-90 | registry.rs |
HandlerRegistry::alpn_strings() |
92-94 | registry.rs |
impl Default for HandlerRegistry |
97-101 | registry.rs |
impl Debug for HandlerRegistry |
103-116 | registry.rs |
Adaptations
- Imports: Update
crate::types::ProtocolHandlertoalknet_core::types::ProtocolHandler. - No other changes: The
HandlerRegistryis a pure data structure with no transport deps. It maps ALPN byte strings toProtocolHandlerinstances. No feature gates needed — it's always available regardless of which transports are enabled.
Public API
// registry.rs
/// Maps ALPN byte strings to `ProtocolHandler` instances.
/// Registered statically at startup by the assembly layer; the endpoint
/// dispatches by looking up the negotiated ALPN.
pub struct HandlerRegistry {
handlers: HashMap<&'static [u8], Arc<dyn ProtocolHandler>>,
}
impl HandlerRegistry {
pub fn new() -> Self;
/// Insert a handler. Panics if the ALPN is already registered.
pub fn register(&mut self, handler: Arc<dyn ProtocolHandler>);
/// Look up a handler by ALPN string.
pub fn get(&self, alpn: &[u8]) -> Option<&Arc<dyn ProtocolHandler>>;
/// Return all registered ALPN strings.
pub fn alpn_strings(&self) -> Vec<Vec<u8>>;
}
What stays in core
The old HandlerRegistry in endpoint.rs lines 66-116 is not deleted — it stays as a
duplicate. The prune happens in Phase 4. This task only adds code to alknet-endpoint.
Acceptance Criteria
crates/alknet-endpoint/src/registry.rscontainsHandlerRegistrywith all methodsHandlerRegistry::new()creates an empty registryHandlerRegistry::register()inserts a handler, panics on duplicate ALPNHandlerRegistry::get()looks up by ALPN, returnsNonefor unknownHandlerRegistry::alpn_strings()returns all registered ALPNsDefaultimpl delegates tonew()Debugimpl lists ALPNs without exposing handler internals- All imports use
alknet_core::(notcrate::) - No feature gates (always available)
cargo check -p alknet-endpointsucceedscargo clippy -p alknet-endpointsucceeds with no warningscargo test -p alknet-corestill passes (old code untouched)
References
- docs/research/alknet-crate-extraction/findings.md — Phase 2, registry module
- docs/architecture/crates/endpoint/README.md — HandlerRegistry spec
- crates/alknet-core/src/endpoint.rs — lines 66-116 (source code to extract)
Notes
This is the simplest extraction in Phase 2 — ~50 lines of pure data structure.
HandlerRegistryhas no transport deps and no feature gates. It's extracted first becauseAlknetEndpoint::new()takes it as a parameter. The old code inendpoint.rsis NOT deleted — that's Phase 4.
Summary
To be filled on completion