Skip to content

refactor: document gRPC startup and web composition flows - #62

Merged
MrRevillod merged 4 commits into
mainfrom
dev
Sep 19, 2026
Merged

MrRevillod merged 4 commits into
mainfrom
dev

Conversation

@MrRevillod

Copy link
Copy Markdown
Member

What Changed

Sword gRPC

  • GrpcApplication::from now takes only gRPC controllers via ControllerRegistry::get_by_kind into a controller_ids: HashSet<TypeId>, instead of snapshotting the whole ControllerMap. The empty-controller guard was simplified to is_empty().
  • Registrars are collected once into a HashMap<TypeId, GrpcControllerRegistrar> and looked up per controller.
  • Reduced build/register loop to a single step and extracted the reflection setup into build_reflection_service; the reflection service now actually mounts (previously the add_service result was discarded) and the #[cfg] assignment compiles.
  • Added inline comments to start() explaining the non-obvious ordering and short rustdoc (with examples) on GrpcControllerRegistrar and its build/register closures.

Sword Web

  • Added inline comments documenting the application composition: extension seeding, controller route bucketing by controller_id, controller build before route handling, merge vs. nest per path, mandatory layer order, cookie/user/NotFound layering, and start() state attachment and graceful shutdown.

Why

The discovery/registration flow is macro-generated, so the real behavior wasn't visible in the source. These comments record the contracts (build-before-register, mapping, layering order) for maintainers. From no longer copies the whole controller map, and the reflection wiring was both broken to compile and silently dropped the service — now fixed.

Move the publisher and subscriber setup out of the application builder
into the sword-events crate. The builder now creates an event runtime
and starts it once the DI container is built. Also extract the built-in
layer registration into a helper method and drop the watch shutdown
channel from the Application instance.
Translate the recently added comments from spanish to english and fix
some of them to match the real code: the ApplicationEngine enum is now
documented per variant and the builder diagram describes how the State
is used by the container, controllers, interceptors and layers.
@MrRevillod
MrRevillod merged commit 213c39f into main Sep 19, 2026
7 checks passed
@MrRevillod
MrRevillod deleted the dev branch September 19, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant