Skip to content

feat: add encoding_strategy option (wrapped / hybrid / flat)#73

Open
pulzarraider wants to merge 1 commit into
masterfrom
enc_strategy2
Open

feat: add encoding_strategy option (wrapped / hybrid / flat)#73
pulzarraider wants to merge 1 commit into
masterfrom
enc_strategy2

Conversation

@pulzarraider

Copy link
Copy Markdown
Member

Introduces an opt-in encoding format for Pub/Sub messages that exposes serializer headers as native Pub/Sub attributes instead of nesting them inside a JSON wrapper.

  • wrapped (default, deprecated): legacy {body, headers} JSON in the message data; will be removed in 5.0.
  • flat: serializer body is published as data, serializer headers as attributes. Recommended for new projects.
  • hybrid: senders publish flat, receivers decode both formats. Use on receivers during migration.

Per-message format detection in hybrid mode uses a reserved Pub/Sub attribute (ppgps-encoding-version) set by flat/hybrid senders; messages without it (older bundle versions, including ones already in the topic at upgrade time) fall back to wrapped decoding. The reserved attribute key cannot be overridden via AttributesStamp — the sender appends it last.

In flat/hybrid mode an AttributesStamp is merged with the serializer headers (stamp wins on collision), preventing the stamp from silently dropping serializer headers.

Introduces an opt-in encoding format for Pub/Sub messages that exposes serializer headers as native Pub/Sub attributes instead of nesting them inside a JSON wrapper.
  - `wrapped` (default, deprecated): legacy `{body, headers}` JSON in the message data; will be removed in 5.0.
  - `flat`: serializer body is published as `data`, serializer headers as attributes. Recommended for new projects.
  - `hybrid`: senders publish flat, receivers decode both formats. Use on receivers during migration.

Per-message format detection in `hybrid` mode uses a reserved Pub/Sub attribute (`ppgps-encoding-version`) set by flat/hybrid senders; messages without it (older bundle versions, including ones already in the topic at upgrade time) fall back to wrapped decoding. The reserved attribute key cannot be overridden via `AttributesStamp` — the sender appends it last.

In flat/hybrid mode an `AttributesStamp` is merged with the serializer headers (stamp wins on collision), preventing the stamp from silently dropping serializer headers.
@pulzarraider pulzarraider modified the milestone: 4.0 May 9, 2026
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