Skip to content

feat(buffa): add MessageFullName trait#108

Open
yordis wants to merge 1 commit intoanthropics:mainfrom
yordis:yordis/full-name
Open

feat(buffa): add MessageFullName trait#108
yordis wants to merge 1 commit intoanthropics:mainfrom
yordis:yordis/full-name

Conversation

@yordis
Copy link
Copy Markdown

@yordis yordis commented May 9, 2026

  • Event-sourced systems identify each event on the wire by its fully-qualified type name (e.g. user.UserCreated). To use a buffa-generated message directly as a domain event. Skipping the usual hand-written mapping layer between "domain type" and "storage type". Callers need that name as a compile-time constant on the type itself. Today it isn't there: the closest surface, ExtensionSet::PROTO_FQN, is bundled with the extension machinery and only emitted when a message opts into unknown_fields=true, which adds a hidden __buffa_unknown_fields field to the struct and forces every struct-literal construction in domain code to trail ..Default::default(). Reaching for buffa::ExtensionSet just to read the FQN therefore drags in storage and ergonomic costs the caller doesn't want.
  • Following the same shape as protocolbuffers/protobuf#27111, this PR introduces buffa::MessageFullName as a standalone trait with a single const FULL_NAME: &'static str item. Kept out of Message precisely so the FQN concern stays orthogonal and adding it doesn't break any hand-written impl Message in downstream code. Generic call sites import the trait (use buffa::MessageFullName;) and read T::FULL_NAME at compile time with no runtime indirection, so event stores, type registries, and Any type-URL construction can dispatch on it instead of maintaining a hand-written match arm per message.
  • ExtensionSet::PROTO_FQN is intentionally left in place to keep this change additive; the two consts are emitted from the same proto_fqn source in codegen so they cannot drift, and that invariant is documented at both sites.
  • The name MessageFullName / FULL_NAME mirrors the convention used across the protobuf ecosystem (and matches protocolbuffers/protobuf#27111 to keep the two PRs aligned). Not attached to it. Happy to rename if a different spelling reads better here.

Related: TrogonStack/TrogonEventStore#240.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@yordis
Copy link
Copy Markdown
Author

yordis commented May 9, 2026

To be extra clear, intentionally opt-out from unknown_fields=true since that causes extra fields that I wish to avoid to codegen, having the trait to a very specific things helps with the Interface segregation principle, which is effectively what is going on for me

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