Description
The main function contains a ~140-line match block (lines 118-257) that constructs each channel provider. Every arm follows the exact same pattern:
- Build a temporary provider with a dummy
SecurityGate
- Call
resolve_users
- Build the real provider with the resolved gate
- Log registration
- Push into
provider_arcs
Each new channel kind added will copy-paste this boilerplate, increasing the risk of subtle divergence between arms.
Recommendation:
Extract a ChannelProvider factory method (e.g., channel::build(ch_config, workspace, global_output) -> Result<Arc<dyn ChannelProvider>>) that encapsulates the two-phase construction. Each provider module can expose a build() or implement a ChannelProviderFactory trait that hides the temporary-provider + resolve + real-provider dance.
Description
The
mainfunction contains a ~140-linematchblock (lines 118-257) that constructs each channel provider. Every arm follows the exact same pattern:SecurityGateresolve_usersprovider_arcsEach new channel kind added will copy-paste this boilerplate, increasing the risk of subtle divergence between arms.
Recommendation:
Extract a
ChannelProviderfactory method (e.g.,channel::build(ch_config, workspace, global_output) -> Result<Arc<dyn ChannelProvider>>) that encapsulates the two-phase construction. Each provider module can expose abuild()or implement aChannelProviderFactorytrait that hides the temporary-provider + resolve + real-provider dance.