Repository navigation
refactor!: one source for stores, projections, models and hosts - #348
Open
patrickleet wants to merge 1 commit into
Open
patrickleet wants to merge 1 commit into
patrickleet wants to merge 1 commit into
Conversation
The reference app restated framework knowledge in every module: an
18-line trait-bound wall per `routes()` (and a `bounds.rs` copied six
times), each projection's name and epoch three times through a
pass-through handler, the read-model list in six places, a hand-built
manifest beside `Service::application`, and two 65-line SQLite and
Postgres hosts.
- `Stores { events, locks, read_models }` and the `ServiceStores`
trait: a module is `fn routes<St: ServiceStores>(stores, projections)`
and `Routes::for_aggregate(stores)`.
- `LocalProjectionMounts::builder(..).eventual(DESC).direct(DESC)`
reads name, epoch and model from the `projection!` descriptor;
modules mount `projections.projector(TODOS)` directly.
- `AuthorizedReadModel` keeps permissions next to the model, and one
`ReadModels` catalog feeds schema bootstrap, grants, the engine, the
version store and client export. Client surfaces are declared once.
- The application manifest is `Service::application`'s; the module id
constants and their self-asserting test are gone.
- One generic host over `SqlStores` (SQLite and Postgres); the hosts'
own outbox loop is gone, since `with_bus` already drains and polls.
- `HandlerError::rejected`, `guards::authenticated` and `guards::role`
replace per-app helper copies.
Both demos: 19 files deleted (441 lines), +1,086 / -2,070 overall.
BREAKING CHANGE: `Routes::for_aggregate` takes `&impl ServiceStores`;
`LocalProjectionMounts` is built from descriptors (`eventual_model`,
`direct_model`, `direct_projection` and `projector(&str)` are gone).
The e2e manifest's identity module is named `zitadel`, after its
command namespace.
Implements [[tasks/v5-review-28]]
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task 28 stage B: remove the repetition in the reference app's service layer (review 13 findings #4, #5, #6, #7, #8, #28), in both e2e-ui and e2e-celld.
Changes
distributed::microsvc::Stores { events, locks, read_models }andtrait ServiceStores, with associatedEvents,QueuedandReadModels, and a blanket impl.AggregateDependencies<St, A>andStoreDependencies<St>.fn routes<St: ServiceStores>(stores: &St, projections: &LocalProjectionMounts)andRoutes::for_aggregate(stores).bounds.rscopies (236 lines), bothdeps.rsfiles and blob's dead_blob_directparameter.LocalProjectionMounts::builder(service, source).eventual(DESC).direct(DESC).build()reads them from theprojection!descriptor, so a mismatch can no longer exist.projector(DESC)replacesprojector("name")..consume_projection(projections.projector(TODOS)).application_manifest()comes fromService::application. DeletedMODULE_ID(×4),MODULE_IDS,MODULE_DECLARATIONS,E2E_UI_MODULE_IDS,COMMAND_PREFIX(×2) and the test that asserted a constant equals itself.AuthorizedReadModel::permissions()keeps permissions next to the model.ReadModels::new(name).model::<M>()catalog feeds schema bootstrap, grants,GraphqlEngineBuilder::read_models, the version-store table names and client export.ClientSurfaceconstants, which the engine and the export both use.trait SqlStores, implemented bySqliteStoresandPostgresStores.spawn_outbox_publish_loop(.., 30s, 5)is removed.with_busalready starts a drainer that polls pending rows, and the two were competing for the same outbox._dispatcheris gone.HandlerError::rejected,guards::authenticatedandguards::role(..)replace the per-domain copies. Also deletedClientSurfaceLocks(×2), the emptyhandlers/commands/mod.rsand e2e-celld's deadhandlers/util.rs.The two demo trees lose 19 files (441 lines); overall the diff is +1,086 / −2,070.
Breaking:
Routes::for_aggregatetakes&impl ServiceStores.LocalProjectionMountsis built from descriptors;eventual_model,direct_model,direct_projectionandprojector(&str)are gone.zitadel, after itszitadel.*command namespace. No generated file changed.Verification (local)
cargo check --workspace --all-targets --all-features: passes.cargo check -p distributed --tests --no-default-features: passes, and each of the 19 features alone passes.check-wasm32-domains.shpasses, as do the 5 celld workers andexamples/game/cells.cargo test -p distributed --all-features: 2,196 passed, 0 failed.make test-local: 2,865 passed, 0 failed.cargo test --workspace: 98 passed.make ci-offlinepasses with UI 16/16 and no generated drift.cargo test --workspace: 25 passed.distributed buildof e2e-ui and e2e-celld:drift: [].-D warnings, 68 tests and the build all pass. Game cells pass wasm32 clippy and fmt.mobpit_smoketests pass 5/5 withCELLD_BINandCELLD_ESBUILDset, as CI sets them.cargo test -p distributed_cli: 323 passed, 0 failed.Not done
projections.rs,application.rsand the engine and export helpers. They are now identical to e2e-ui's; making e2e-celld a runner over the shared crates is stage C.