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

Should serdes functionality be exported to JS? #50

Closed
mostafa opened this issue May 8, 2022 · 3 comments · Fixed by #149
Closed

Should serdes functionality be exported to JS? #50

mostafa opened this issue May 8, 2022 · 3 comments · Fixed by #149
Labels
✨ Feature Request New feature or request ❓ Question Further information is requested

Comments

@mostafa
Copy link
Owner

mostafa commented May 8, 2022

Instead of implicitly calling the serdes functions via produce and consume, we can explicitly call them from JS and have the user control over them. This way, we can have a more flexible serializer/deserializer system, and we don't need to worry about API changes and backward compatibility. Also, we won't have to decide when to use the serializer/deserializer based on the schema and given parameters.

@enamrik
Copy link
Contributor

enamrik commented Jun 15, 2022

@mostafa I like that idea. So, for example, instead of the consume method taking a keySchema and valueSchema, it would take optional key and value serializers. We could have a serde interface like:

type SerdeInterface interface {
	serialize(model interface{}) []byte
	deserialize(data []byte) interface{}
}

and consume method:

func (k *Kafka) Consume(reader *kafkago.Reader, limit int64,
	keySerializer SerdeInterface, valueSerializer SerdeInterface) ([]map[string]interface{}, *Xk6KafkaError) 

We may not need the ConsumeWithConfiguration anymore since most of the configuration would be passed to the SerdeInterface implementation.

Is this what you were thinking? If so, I could take a shot at it. Let me know.

@mostafa
Copy link
Owner Author

mostafa commented Jun 15, 2022

@enamrik
I was thinking along the same lines as what you mentioned. However, I want to pass values directly from JS to Go in functions as JSON. So, I'll move all the function parameters into one or many JSON object(s), which is what I did with SASL and TLS configs in #86. I also created #89 to discuss the future API changes. Feel free to add your suggestions there and then link to the relevant PR.

@enamrik
Copy link
Contributor

enamrik commented Jun 15, 2022

@enamrik I was thinking along the same lines as what you mentioned. However, I want to pass values directly from JS to Go in functions as JSON. So, I'll move all the function parameters into one or many JSON object(s), which is what I did with SASL and TLS configs in #86. I also created #89 to talk about the future API changes. Feel free to add your suggestions there and then link to the relevant PR.

Oh I see. So you would pass keyConfig and valueConfig JSON objects and those configuration objects would describe the serde type and serde input configuration. Sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature Request New feature or request ❓ Question Further information is requested
Projects
Status: Release
Development

Successfully merging a pull request may close this issue.

2 participants