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

Br/taco 385 - adding builders for ProxyRouteConfig and ClientConfig to make these at runtime #279

Merged
merged 4 commits into from
Jul 12, 2018

Conversation

Rivukis
Copy link
Collaborator

@Rivukis Rivukis commented Jul 12, 2018

No description provided.

Brian Radebaugh added 2 commits July 12, 2018 15:16
…e easily create these objects at runtime while having the ability to use default config values
@Rivukis Rivukis changed the title Br/taco 385 Br/taco 385 - adding builders for ProxyRouteConfig and ClientConfig to make these at runtime Jul 12, 2018
private InetSocketAddress remote;
private IdleTimeoutConfig idleTimeoutConfig;

private Builder(ClientConfig fallbackObject) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a ClientConfig instead of a Config so that the user has the capabilities to create a default object once and use it over and over instead of newing up one everytime with the same Config

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same reasoning in ProxyRouteConfig as well

ClientConfig fallbackObject = new ClientConfig(config.getConfig("xio.clientTemplate"));
Map expectedBootstrapOptions = Maps.newHashMap(ChannelOption.AUTO_READ, new Object());
String expectedName = "name";
TlsConfig expectedTls = new TlsConfig(ConfigFactory.load("tls-reference"));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm trying to avoid having to make a builder for TlsConfig for now in hopes that we won't need one. If we need to be able to create different ones at runtime, we can add it then

Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn’t need a builder for TlsConfig. We’ll always want something typesafe config based so we can pull in defaults from reference.conf

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's what I was hoping for 👍

* <p>If a value is not set, it defaults to using the default object's value.
*/
public static class Builder {
private ClientConfig fallbackObject;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name is fallbackObject the javadoc says default object. I would pick one name and stick with it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

this.fallbackObject = fallbackObject;
}

public Builder setBootstrapOptions(Map<ChannelOption<Object>, Object> bootstrapOptions) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I was writing this from scratch i’d use a google auto builder. Don’t change anything here. Just look into it for next time so you don’t have to create a bunch of boilerplate. Then again. I’m hand crafting code with sed and you’re using intellij so i’m sure this was painless.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh no, it was painful. I just didn't know about auto builder. I'll look into it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

looked into it. got close to making it work, but it's not compiling and the output is not showing me the error. I'm out of ideas so moving forward with my hand rolled version

* <p>If a value is not set, it defaults to using the default object's value.
*/
public static class Builder {
private ProxyRouteConfig fallbackObject;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same note as before either default or fallback as the name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

ClientConfig fallbackObject = new ClientConfig(config.getConfig("xio.clientTemplate"));
Map expectedBootstrapOptions = Maps.newHashMap(ChannelOption.AUTO_READ, new Object());
String expectedName = "name";
TlsConfig expectedTls = new TlsConfig(ConfigFactory.load("tls-reference"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn’t need a builder for TlsConfig. We’ll always want something typesafe config based so we can pull in defaults from reference.conf

@@ -209,12 +209,6 @@ xio {
name = "test client"
}

proxyRouteTemplate = ${xio.routeTemplate} {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice. We missed this before.

@khappucino khappucino self-requested a review July 12, 2018 22:51
@coveralls
Copy link

coveralls commented Jul 12, 2018

Coverage Status

Coverage increased (+0.6%) to 45.536% when pulling 92de0c9 on br/TACO-385 into 0853f88 on master.

@Rivukis Rivukis merged commit 57bd461 into master Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants