-
Notifications
You must be signed in to change notification settings - Fork 927
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
Provide a consistent configuration to Armeria Dropwizard #2373
Conversation
Motivation: Armeria's Spring Boot auto configure module offers to customize the Armeria server from JSON YAML. Dropwizard module has been added to Armeria by line#2236. It can also customize Armeria Server from YAML. But the configuration style is different. Sometimes it may confuse the user. Modification: * Apply Spring Boot's YAML convention to the Dropwizard module. * Add ArmeriaConfigurationUtil for applying ArmeriaSettings to * ServerBuilder. * Copy `CustomAliasKeyManagerFactory` and `CustomAliasX509ExtendedKeyManager` from `amreria/spring/boot-autoconfigure` to configure TLS fluenltly. * Add meter exporsition for `DropwizardMeterRegistry` * Remove unused configuration files. Result: Provide a consistent configuration to Armeria Dropwizard.
Test failure:
|
@Cricket007 PTAL |
Oops... let me take a look. 😅 |
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.
Not really a fan of this redundancy
type: armeria
armeria:
... settings...
If it cannot be flattened, that's fine
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaConfigurationUtil.java
Show resolved
Hide resolved
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaConfigurationUtil.java
Show resolved
Hide resolved
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaConfigurationUtil.java
Show resolved
Hide resolved
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaServerFactory.java
Show resolved
Hide resolved
My initial intention was to have a minimal rewrite from existing dropwizard http configuration to just replace the server type, not match any Spring config similarities |
I agreed, wanted to remove it but... I think we need own name to avoid conflict.
That is a nice suggestion. This is a fork of the original code. Line 107 in 9546b28
There are lots of duplication code between Dropwizard and Spring Boot configure. After releasing 1.0 we plan to merge that APIs to provide a general interface. But now we decided to keep the code as equal as possible. Let me add your review to TODO for further refactoring.
This one too.
I understand your intention. As you mentioned in |
I'm not sure there's a conflict, I simply mean move "up" all properties of the ArmeriaSettings class directly into the ServerFactory. |
Let me remove the |
- Remove `armeria` namespace in ArmeriaServerFactory - Document `accessLog` property - Add TODO commented by @Cricket007
Codecov Report
@@ Coverage Diff @@
## master #2373 +/- ##
============================================
- Coverage 73.49% 73.32% -0.18%
- Complexity 10620 10690 +70
============================================
Files 928 934 +6
Lines 40845 41193 +348
Branches 5048 5142 +94
============================================
+ Hits 30021 30206 +185
- Misses 8272 8370 +98
- Partials 2552 2617 +65
Continue to review full report at Codecov.
|
Sorry about the conflict. 😅 |
No worries. Let me resolve it :-) |
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaConfigurationUtil.java
Outdated
Show resolved
Hide resolved
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaSettings.java
Show resolved
Hide resolved
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaSettings.java
Outdated
Show resolved
Hide resolved
- Remove metricsPath from ArmeriaSettings - Update Javadoc
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.
some nits. 😄
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaConfigurationUtil.java
Outdated
Show resolved
Hide resolved
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaConfigurationUtil.java
Outdated
Show resolved
Hide resolved
Hey, btw, I noticed the docs aren't on the main page yet |
Did you mean the Armeria official homepage? |
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.
Nice work, @ikhoon !
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.
Oops forgot to approve this.
Thanks @ikhoon!
Any other comments, @Cricket007 ? Would like to pull this in once you approve. |
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.
Minor feedback. Good work, otherwise
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaSettings.java
Outdated
Show resolved
Hide resolved
dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaSettings.java
Show resolved
Hide resolved
dropwizard/src/test/java/com/linecorp/armeria/dropwizard/TestApplication.java
Outdated
Show resolved
Hide resolved
@@ -1 +0,0 @@ | |||
com.linecorp.armeria.dropwizard.logging.AccessLogWriterFactory |
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.
Is this (and related files) really not needed?
Or did you just remove the @JsonTypeInfo
usages?
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.
@JsonTypeInfo
for AccessLogWriter has been removed, so I think we can remove it.
Because:
- The
AccessLogWriter
type and format can be configured viaAccessLog
inArmeriaSettings
.
armeria/dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaSettings.java
Lines 919 to 955 in 3d6d805
/** * Configurations for the access log. */ static class AccessLog { /** * The access log type that is supposed to be one of * {@code "common"} {@code "combined"} or {@code "custom"}. */ @Nullable private String type; /** * The access log format string. */ @Nullable private String format; @Nullable String getType() { return type; } void setType(String type) { this.type = type; } @Nullable String getFormat() { return format; } void setFormat(String format) { this.format = format; } } } - The
AccessLogWriter
is set toServerBuilder
statically inconfigureAccessLog
armeria/dropwizard/src/main/java/com/linecorp/armeria/dropwizard/ArmeriaConfigurationUtil.java
Lines 469 to 478 in 7413d19
private static void configureAccessLog(ServerBuilder serverBuilder, AccessLog accessLog) { if ("common".equals(accessLog.getType())) { serverBuilder.accessLogWriter(AccessLogWriter.common(), true); } else if ("combined".equals(accessLog.getType())) { serverBuilder.accessLogWriter(AccessLogWriter.combined(), true); } else if ("custom".equals(accessLog.getType())) { serverBuilder .accessLogWriter(AccessLogWriter.custom(accessLog.getFormat()), true); } }
Let me know if there is something I missed.
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.
Just making sure it wasn't needed anymore.
Ref. https://www.dropwizard.io/en/stable/manual/configuration.html#polymorphic-configuration
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.
Personally, I think statically assigned if-else (or switch on string) are code-smells.
https://refactoring.guru/replace-conditional-with-polymorphism
- Remove unused code - Use MediaType constants for compresssion
Thanks a lot, @ikhoon and reviewers! |
Motivation: Armeria's Spring Boot auto configure module offers to customize the Armeria server from JSON YAML. Dropwizard module has been added to Armeria by line#2236. It can also customize Armeria Server from YAML. But the configuration style is different between Spring Boot and Dropwizard. The user should learn how to configure Armeria in each module. It may confuse the user. Modification: * Apply Spring Boot's YAML convention to the Dropwizard module. * Add ArmeriaConfigurationUtil for applying ArmeriaSettings to ServerBuilder. * Copy `CustomAliasKeyManagerFactory` and `CustomAliasX509ExtendedKeyManager` from `amreria/spring/boot-autoconfigure` to configure TLS fluenltly. * Add meter exporsition for `DropwizardMeterRegistry`. * Remove unused configuration files. Result: Provide a consistent configuration to Armeria Dropwizard.
Motivation:
Armeria's Spring Boot auto configure module offers to customize the Armeria server from JSON YAML.
Dropwizard module has been added to Armeria by #2236. It can also customize Armeria Server from YAML.
But the configuration style is different between Spring Boot and Dropwizard.
The user should learn how to configure Armeria in each module. It may confuse the user.
Modification:
ServerBuilder.
CustomAliasKeyManagerFactory
andCustomAliasX509ExtendedKeyManager
fromamreria/spring/boot-autoconfigure
to configure TLS fluenltly.DropwizardMeterRegistry
.Result:
Provide a consistent configuration to Armeria Dropwizard.