-
Notifications
You must be signed in to change notification settings - Fork 442
feat: Make serializer configurable via YAML configuration #1390
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
base: master
Are you sure you want to change the base?
feat: Make serializer configurable via YAML configuration #1390
Conversation
- Add support for configuring serializers through YAML in RdKafkaContext - Allow serializer specification as a class name, array with options, or instance
- Ensures robustness by providing a default serializer - Refactoring
pkg/rdkafka/RdKafkaContext.php
Outdated
/** | ||
* @return void | ||
* JsonSerializer should be the default fallback if no serializer is specified | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to re-specify the return type, since it's already present in the PHP declaration.
As for the description, I'm not sure it's worthwile - but nothing against it either.
/** | |
* @return void | |
* JsonSerializer should be the default fallback if no serializer is specified | |
*/ | |
/** | |
* JsonSerializer is the default fallback, if no serializer is specified. | |
*/ |
@@ -36,6 +36,34 @@ public function testShouldSetJsonSerializerInConstructor() | |||
$this->assertInstanceOf(JsonSerializer::class, $context->getSerializer()); | |||
} | |||
|
|||
public function testShouldUseStringSerializerClassFromConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding unit test that checks assertSame
instance when serializer object is passed. If you are able you might want to check constructor options with method call assertions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean by checking constructor options with method call assertions. Could you please explain in more detail? Do you mean I should check how configureSerializer
is being called from constructor of RdKafkaContext? I think, I think, I cannot assert private methods in Mocks.
P.S sorry for delayed response. I took a break from coding. Now I am really up to finish this.
This change enables users to specify custom serializers with configuration
options in their Enqueue bundle YAML configuration, improving flexibility
when working with different message formats.