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
refactor(data-plane): replace encoder::Name with ProtoName throughout (agntcy#1596)
## Description
Removes the `encoder::Name` struct entirely and replaces it with
`ProtoName` (the prost-generated protobuf message type) across all
crates in the data plane.
`encoder::Name` was a conversion shim between human-readable string
components and the 4×u64 XxHash64-encoded wire representation
(`EncodedName`). Every message already carried a `ProtoName` directly in
its `SlimHeader`, making `Name` a pure overhead layer: code would
convert `ProtoName → Name` to get ergonomic helpers (`from_strings`,
`with_id`, etc.), then immediately convert `Name → ProtoName` before
sending.
### What changed
**`ProtoName` gains constructor/utility methods** (added to `api.rs`):
- `from_strings([s0, s1, s2])` — hashes components via XxHash64 and
stores both the encoded and string forms
- `with_id(u64)`, `id()`, `has_id()`, `set_id()`, `reset_id()` — manage
the 4th component (instance ID)
- `match_prefix()` — compare first 3 components, ignoring ID (used for
subscription prefix matching)
- `str_components() -> (&str, &str, &str)` — access human-readable
components
- `NULL_COMPONENT` / `is_reserved_id()` — sentinel value for unset IDs
**Routing hot path** — `ProtoName → EncodedName` is now a direct field
access (`name.name.unwrap()`), with no intermediate `Name` allocation.
All routing table keys are `EncodedName` (a `Copy` + `Hash` + `Eq` 4×u64
struct).
**Collection types** — `HashMap<Name, _>` / `HashSet<Name>` across
session, service, and controller crates are replaced with
`HashMap<EncodedName, _>` / `HashSet<EncodedName>` for hot-path
collections, and `HashMap<ProtoName, _>` where the full name is needed
as a value.
**`SlimHeader` constructor** — the `new_from_protos(ProtoName,
ProtoName, ...)` / `new(&ProtoName, &ProtoName, ...)` split is collapsed
into a single `new(ProtoName, ProtoName, ...)` that owns its arguments
directly.
**Bindings** — the `Name` UniFFI wrapper in `bindings/rust/src/name.rs`
now holds a `ProtoName` directly rather than converting to/from
`encoder::Name`.
**`encoder.rs`** — the `Name` struct, all its `From` impls, and the
re-exports in `messages/mod.rs` are removed. The file retains only
`calculate_hash` (used internally by `ProtoName::from_strings`).
### Scope
68 files changed across `datapath`, `session`, `service`, `controller`,
`bindings/rust`, `slimctl`, `testing`, and `examples`.
## Type of Change
- [ ] Bugfix
- [x] New Feature
- [ ] Breaking Change
- [x] Refactor
- [ ] Documentation
- [ ] Other (please describe)
## Checklist
- [x] I have read the [contributing
guidelines](/agntcy/repo-template/blob/main/CONTRIBUTING.md)
- [ ] Existing issues have been referenced (where applicable)
- [x] I have verified this change is not present in other open pull
requests
- [ ] Functionality is documented
- [x] All code style checks pass
- [x] New code contribution is covered by automated tests
- [x] All new and existing tests pass
---------
Signed-off-by: Sam Betts <1769706+Tehsmash@users.noreply.github.com>
0 commit comments