You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cargo): split entity-attribute generators into opt-out features (#132)
* #131 feat(cargo): split entity-attribute generators into opt-out features
Every entity-attribute group now lives behind its own Cargo feature so
users can shrink their build by switching off generators they don't need.
All new features ship default-on, so existing projects compile unchanged.
New features (default-on, non-breaking):
- events — `{Entity}Event` enum, lifecycle event variants
- commands — command structs, dispatcher trait (`#[entity(commands)]`,
`#[command(...)]`)
- hooks — `{Entity}Hooks` trait (manual wiring; #127 tracks
auto-invocation)
- transactions — `{Entity}TransactionRepo` adapter + deprecated `with_*`
builders (`#[entity(transactions)]`)
- aggregate_root — `New{Entity}` constructor and transactional `save()`
(`#[entity(aggregate_root)]`)
- migrations — compile-time `MIGRATION_UP`/`MIGRATION_DOWN` constants
(`#[entity(migrations)]`)
- projections — projection structs + `find_by_id_<projection>` methods
(`#[projection(...)]`)
Plumbing:
- Each feature in `entity-derive` activates its sibling in
`entity-derive-impl`. The facade now declares
`entity-derive-impl = { … default-features = false }` so transitive
default-on doesn't leak past the user's explicit selection.
- In `entity-derive-impl/src/entity.rs`, every gated submodule and its
`generate(&entity)` call sits under `#[cfg(feature = "<name>")]`.
- New helper `guard_disabled_attribute()` emits a friendly
`compile_error!` if the entity attribute is present but the feature is
off — much clearer than a missing-method puzzle at the call site.
- `streams` now depends on `events` (the NOTIFY payload is an event
variant; `streams` without `events` would not link).
- Crate-level `#![cfg_attr(any(not(feature = "migrations"), not(feature
= "projections")), allow(dead_code, unused_imports))]` keeps minimal
builds warning-free without touching individual parser helpers.
README feature matrix rewritten with a Default column and a "If you use
an entity attribute whose feature is disabled, the macro tells you so"
note plus a `default-features = false` example.
Bump:
- entity-derive-impl: 0.6.2 -> 0.6.3
- entity-derive: 0.8.3 -> 0.8.4
`entity-core` is unchanged.
Closes#131
* test(features): cover guard_disabled_attribute helper
|`streams`||`{Entity}Subscriber` using Postgres `LISTEN`/`NOTIFY` (pulls in `events`) |
99
+
|`api`|| Generate HTTP handlers (`axum`) and `utoipa` OpenAPI schemas |
100
+
|`validate`|| Wire up `validator::Validate` on generated DTOs |
101
+
|`tracing`|| Wrap every generated async method in `#[tracing::instrument]` carrying `entity` + `op` span fields |
102
+
103
+
Default features cover the full entity-attribute surface so existing projects work without changes. For lean builds, opt out of what you don't need:
104
+
105
+
```toml
106
+
[dependencies]
107
+
# Just repositories — no events, hooks, commands, etc.
108
+
entity-derive = { version = "0.8", default-features = false, features = ["postgres"] }
109
+
```
110
+
111
+
If you use an entity attribute whose feature is disabled (e.g. `#[entity(commands)]` without `features = ["commands"]`), the macro emits a `compile_error!` at the attribute pointing to the missing feature.
0 commit comments