Skip to content

feat: allow selecting payload encoding per value#87

Open
raszi wants to merge 5 commits into
manetu:masterfrom
metrictech:feat/select-data-converter
Open

feat: allow selecting payload encoding per value#87
raszi wants to merge 5 commits into
manetu:masterfrom
metrictech:feat/select-data-converter

Conversation

@raszi
Copy link
Copy Markdown
Contributor

@raszi raszi commented May 13, 2026

Summary

Allows callers to explicitly select which payload converter (nippy, json, or null) is used when serializing a value, instead of relying on the default best-match selection. This is useful when interoperating with non-Clojure Temporal workers that expect a specific encoding.

Changes

  • temporal.converter.encoding (new): introduces a Tagged record and with helper for annotating a value with a target encoding (:null, :nippy, :json, or a raw encoding string like "json/plain").
  • temporal.converter.default:
    • create now returns a proxy over DefaultDataConverter that intercepts toPayload and routes Tagged values to the requested converter, falling back to default behavior otherwise.
    • Overrides withContext to propagate SerializationContext to a fresh proxy while reusing the original converters/failure-converter via reflection into PayloadAndFailureDataConverter's private fields.
    • Throws DataConverterException with a clear message when the requested encoding has no registered converter, or when the registered converter can't encode the value.
  • temporal.client.core: adds an encode helper that runs values through the client's configured DataConverter.
  • temporal.converter.optional: removes unused optional?.
  • Tests: expand default_test to cover tagged values across :null/:nippy/:json (both keyword and raw string forms), withContext propagation, and error paths for unregistered/unencodable values.

Test plan

  • lein test passes
  • Round-trip a (encoding/with x :json) value through a workflow and confirm the resulting Payload metadata reports json/plain
  • Confirm untagged values still serialize via the default nippy path (no regression)
  • Confirm withContext produces a converter that still honors tagged values

raszi added 4 commits May 13, 2026 14:19
Signed-off-by: KARASZI István <ikaraszi@gmail.com>
Signed-off-by: KARASZI István <ikaraszi@gmail.com>
Signed-off-by: KARASZI István <ikaraszi@gmail.com>
Signed-off-by: KARASZI István <ikaraszi@gmail.com>
@raszi raszi force-pushed the feat/select-data-converter branch from fa29e6c to e3e1505 Compare May 13, 2026 12:23
Signed-off-by: KARASZI István <ikaraszi@gmail.com>
@dotemacs dotemacs mentioned this pull request May 13, 2026
Copy link
Copy Markdown
Contributor

@dotemacs dotemacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already used in production, so yes, approving.

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.

3 participants