Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Initial push #2

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Initial push #2

wants to merge 3 commits into from

Conversation

utobi
Copy link
Contributor

@utobi utobi commented Mar 27, 2017

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
}

dependencies {
compile "io.grpc:grpc-all:${grpcVersion}"
Copy link
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?

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
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
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
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
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
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
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.

read -p "Enter the version (e.g. 0.0.1) " -r VERSION
if [ -z "$VERSION" ]; then
echo "Version cannot be empty!"
exit
Copy link
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
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
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) {

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");

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 {

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.

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

Choose a reason for hiding this comment

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

why this outer ( ... ) ?

Copy link

@thgreiner thgreiner left a comment

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants