Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Initial push#2

Open
utobi wants to merge 3 commits into
developfrom
feature/initial
Open

Initial push#2
utobi wants to merge 3 commits into
developfrom
feature/initial

Conversation

@utobi

@utobi utobi commented Mar 27, 2017

Copy link
Copy Markdown
Contributor

No description provided.

* Intitial commit
* Update gitignore
* Implement review feedback
* Add travis.yml
* Add gradle wrappers
* Renamed consulresolver -> consulnameresolver, added deploy script
* move ossh credentials
Comment thread build.gradle
}

dependencies {
compile "io.grpc:grpc-all:${grpcVersion}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From what I read at a glance here, you need either grpc-all or the other deps?

Comment thread build.gradle
testCompile "junit:junit:4.12"
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.awaitility:awaitility:2.0.0'
testCompile 'com.pszymczyk.consul:embedded-consul:0.2.3'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting! 👍

private ImmutableCatalogOptions buildCatalogOptions() {
ImmutableCatalogOptions.Builder options = ImmutableCatalogOptions.builder();

if (this.datacenter.isPresent()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For conciseness I'd use ifPresent here like so

this.datacenter.ifPresent(d -> options.datacenter(com.google.common.base.Optional.of(d)));

but that's just matter of taste though.

options.datacenter(com.google.common.base.Optional.of(this.datacenter.get()));
}

if (this.tags.isPresent()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this.tags.ifPresent(tags -> tags.forEach(options::tag));

return options.build();
}

private void updateListenerWithEmptyResult() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably rename method to something like propagateServiceUnavailableToListeners?


public Builder(String service) {
if (service == null) {
throw new RuntimeException("Service cannot be null");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is a RuntimeException required here? Otherwise I favor a NullPointerException and go with

this.service = Preconditions.checkNotNull(service, "Service cannot be null"); 

Optional<String> address = Optional.ofNullable(this.consulAddress);
Optional<String> datacenter = Optional.ofNullable(this.datacenter);
Optional<List<String>> tags;
if (this.tags.isEmpty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does using Optional<List<String>> have a special semantic here? If not, I'd rather go with just using an empty list.

This also applies to ConsulNameResolver.

Comment thread deploy.sh
read -p "Enter the version (e.g. 0.0.1) " -r VERSION
if [ -z "$VERSION" ]; then
echo "Version cannot be empty!"
exit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

exit 1

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've seen other test classes below omit the test prefix, probably the test methods in this class should be renamed to avoid the superfluous prefix.

private final int port;

public PingPongServer() {
this(55551);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably better use a random value here to decrease possibility of already taken ports?

public final Optional<List<String>> tags;

private ConsulQueryParameter(Optional<String> consulAddress, String service,
Optional<String> datacenter, Optional<List<String>> tags) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

private ConsulQueryParameter(Builder builder) {

@Override
public void start(Listener listener) {
Preconditions.checkState(this.listener == null, "already started");
this.listener = Preconditions.checkNotNull(listener, "listener");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

error message "listener"? Should probably be more informative: "listener cannot be empty".

}

@Test
public void testSanitizeInputBadScheme() throws Exception {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

please remove test prefix, like in other test class.

Comment thread deploy.sh
echo "Deploying artifact to maven central"
read -p "Are you sure you want to deploy? (yes/NO)? " -r DO_DEPLOYMENT

if ( [ "$DO_DEPLOYMENT" == "yes" ] ); then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why this outer ( ... ) ?

@thgreiner thgreiner left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Getting rid of this review

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants