You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add several configuration properties to ConsulFactory to permit changing the read and write timeouts for the underlying OkHttp client, as well as allowing you to set the client configuration (com.orbitz.consul.config.ClientConfig).
Add the following fields are to ConsulFactory, right below the healthCheckPath:
After the setHealthCheckPath method, add "getters" and setters for the three new properties. The getter returns Optional while the setter accepts the "raw" value. e.g.
publicOptional<Long> getNetworkWriteTimeoutMillis() {
returnnetworkWriteTimeoutMillis ;
}
publicvoidsetNetworkWriteTimeoutMillis(LongnetworkTimeout) {
this.networkWriteTimeoutMillis = toOptional(networkTimeout);
}
// Use the same pattern for networkReadTimeoutMillis and clientConfig...
The last production code change in ConsulFactory is in in the build method: after the aclToken.ifPresent, add the following three lines:
Note that the ConsulFactory implementation has equals and hashCode even though it doesn't seem like you would ever need to compare two ConsulFactory objects. I do not plan to add these new properties to the existing equals and hashCode methods, and after seeing these methods am considering several future changes:
Split ConsulFactory into separate classes, one that contains only configuration, and one for taking that configuration and building the Consul instance.
Remove equals and hashCode from the factory class
Maybe make the configuration class a "value" or "data" class, where it would (maybe) make more sense to have equals and hashCode
Change all the Optional handling across the library, i.e. don't declare fields as Optional and don't pass Optional to methods, etc.
Add several configuration properties to
ConsulFactory
to permit changing the read and write timeouts for the underlying OkHttp client, as well as allowing you to set the client configuration (com.orbitz.consul.config.ClientConfig
).Add the following fields are to
ConsulFactory
, right below thehealthCheckPath
:Replace all the
Optional.ofNullable
with calls to a private helper methodtoOptional
:After the
setHealthCheckPath
method, add "getters" and setters for the three new properties. The getter returnsOptional
while the setter accepts the "raw" value. e.g.The last production code change in
ConsulFactory
is in in thebuild
method: after theaclToken.ifPresent
, add the following three lines:Next, add the following (JUnit 4) test to
ConsulBundleTest
:We will convert to JUnit 5 in a separate issue.
And last, change the last line in the
testAclToken
test to:In the above, the
isPresent()
calls are redundant and can be removed. Asserting that anOptional
contains
a value also asserts that a value is present.The text was updated successfully, but these errors were encountered: