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

golang SDK: Introduce serde opts for subject auto(ish)-creation #19823

Conversation

oleiman
Copy link
Member

@oleiman oleiman commented Jun 12, 2024

Includes unit tests.

The primary purpose here is to generate a correct subject name based
on user-provided info:

  • output topic name
  • subject name strategy
  • whether it is a key or a value
  • record name (depending on SNS)

Users may include a nameless function, parameterized by the derived
subject name, where they can perform the actual creation of the subject
version in SR. The idea here is to keep Serde[T] more ore less decoupled
from the particular schema it's working on.

Closes CORE-3123

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.1.x
  • v23.3.x
  • v23.2.x

Release Notes

Improvements

  • Golang Transforms SDK (Serde): Adds the ability to specify subject name strategy for output topics. Transforms can also provide a function to be called after the subject name is derived - e.g. to ensure that the subject is created before emitting records.

@oleiman oleiman self-assigned this Jun 12, 2024
@github-actions github-actions bot added the area/wasm WASM Data Transforms label Jun 12, 2024
@oleiman oleiman marked this pull request as draft June 12, 2024 19:22
@oleiman oleiman force-pushed the xform/sdk/core-3123/auto-output-subject-schema branch 4 times, most recently from bb94ffe to 05e6205 Compare June 13, 2024 03:47
@oleiman oleiman marked this pull request as ready for review June 13, 2024 03:48
@oleiman oleiman requested review from a team, aanthony-rp and michael-redpanda and removed request for a team June 13, 2024 18:00
Copy link
Contributor

@aanthony-rp aanthony-rp left a comment

Choose a reason for hiding this comment

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

I think users might have a better experience with one of the refactorings I described. Happy to talk it through.

src/transform-sdk/go/transform/sr/serde.go Outdated Show resolved Hide resolved
src/transform-sdk/go/transform/sr/serde.go Outdated Show resolved Hide resolved
oleiman added 2 commits June 14, 2024 15:41
Includes unit tests.

The primary purpose here is to generate a correct subject name based
on user-provided topic and/or record names.

Users may include a nameless function, parameterized by the derived
subject name, where they can perform the actual creation of the subject
version in SR. The idea here is to keep Serde[T] more ore less decoupled
from the particular schema it's working on while avoiding repeated, error
prone subject name generation code all over the place in user transforms.

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>

o
For the golang version:
Add a (useless) ValueSubjectTopicName for the input topic.

Previously, this transform created the schema it needs in the main function,
looking it up by ID and adding to the Serde instance.

The new version moves the subject creation logic to the Serde.Register call,
adding a ValueSubject to produce that effect. This has no functional effect
on the transform and is not something a user would normally do. It is meant
only to confirm that {Key,Value}Subject is working and not interfering with
normal operation.

For the rust version:

Instead of creating subject "demo-topic-value", create "avro-value" so that
we can check the effect of the golang version in integration_test.go. This
also has no functional effect on the test transform.

Signed-off-by: Oren Leiman <oren.leiman@redpanda.com>
@oleiman oleiman force-pushed the xform/sdk/core-3123/auto-output-subject-schema branch from 06267e2 to e91efdd Compare June 14, 2024 22:43
@oleiman oleiman dismissed aanthony-rp’s stale review June 17, 2024 17:24

took suggestion; stale

@oleiman oleiman merged commit dfccb1b into redpanda-data:dev Jun 17, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/wasm WASM Data Transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants