Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow key value based transformers with custom replacement function #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dfangl
Copy link
Member

@dfangl dfangl commented Mar 6, 2025

Motivation

Currently our KeyValueBasedTransformer only allows static values for replacement.
However, this limits us in the kind of transformers we can build - for me, I wanted to build a key value based transformer where the length of the value was part of the transformation.

Changes

  • Allow replacement function instead of static value and rename to KeyValueBasedTransformerFunctionReplacement (a bit bulky)
  • Create a new KeyValueBasedTransformer with a simple function returning the static value for compatibility with existing code (and convenience)

Open questions

  • The reference replacement is based on the replacement value - so different length replacement within the same snapshot session will have different counters - they are still identifiable, but we do have two ":1" replacements for the same transformer, if the generated replacement differs. I think this is not a big problem, but maybe something we do not want.
  • In general, we can ask ourselves the question if a transformer asserting the length is really something we need (however I argue the more accurate the better).

@dfangl dfangl marked this pull request as ready for review March 6, 2025 14:08
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