-
Notifications
You must be signed in to change notification settings - Fork 3
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
JSON Array splitting #77
base: main
Are you sure you want to change the base?
Conversation
…tests for splitType
IMessageHandler conversion = new RelpConversion(pool, securityConfig, basicAuthentication, lookupConfig); | ||
|
||
// apply splitting if configured | ||
switch (payloadConfig.splitType) { // payloadConfig is Validateable, no need to check wrong config here |
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.
could switch-case be replaced with another object?
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.
Tried to refactor code for creating a decorator for this in NettyHttpServer and even some other objects that use / forward the RelpConversion object. This was so that I could put the config checking code there so it doesn't clutter the other code. This however seems to be impossible now with objects extending and implementing 3rd party objects that are not immutable. Would need a complete refactoring really.
Would it be terrible to create an object just for creating this Conversion object with the config? Not really OOP style, but the code would be somewhere else than in the Main class.
splitRegex = propertiesReader.getStringProperty("payload.splitRegex"); | ||
splitEnabled = propertiesReader.getBooleanProperty("payload.splitEnabled"); | ||
this.regexPattern = propertiesReader.getStringProperty("payload.splitType.regex.pattern"); | ||
this.splitType = propertiesReader.getStringProperty("payload.splitType"); |
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.
in constructor code is not ideal
Adds a new splitting option: json_array. Takes HTTP requests with this kind of format:
and converts each of the JSON objects to their own syslog message and sends them forward.
Configuration had changes:
payload.splitEnabled
was changed topayload.splitType
. Valid values are regex, json_array or none. none is the default.payload.splitRegex
was moved topayload.splitType.regex.pattern
.Regex splitting was already supported, but the design was not scalable. Therefore it was refactored as well to allow json_array to be implemented.
There was a problem with Jakarta's way of getting a JSON object as a string. It removes any whitespace from the String representation. This is okay as the content stays the same.
Tests most importantly include:
JsonPayloadTest
for unit tests for the new functionalityJsonSplittingTest
for end-to-end testing the functionality with actual HTTP-requests sent to the component