Skip to content

Conversation

@pierredavidbelanger
Copy link
Contributor

A very little something I plan to use in my application.

It is a module that expose a client to communicate with Consul, using the nice OrbitzWorldwide/consul-client lib.

I made the extra mile to make it generic (but not too much) enough to be reusable.

It is pretty straight forward (zero config) to use as a simple service registration with health check and service discovery module (this is what I intend to use it for).

You can see the doc I started here.

I will let you have a look at it.

If you like it, I will clean it up a little, add some tests and give it to you.

Do not hesitate to make me change everything, I am not afraid to refactor :)

@jknack jknack self-requested a review April 22, 2017 13:14
Copy link
Member

@jknack jknack left a comment

Choose a reason for hiding this comment

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

Looks good, I made a couple of comments, but also:

  • add jooby-consul to modules section in parent pom
  • add jooby-consul to dependency-management section in parent pom
  • add a unit test. Tests must cover all the possible branches

@@ -0,0 +1,53 @@
# consul
Copy link
Member

Choose a reason for hiding this comment

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

move the file into md/doc/consul/consul.md

<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-consul</artifactId>
<version>1.1.1-SNAPSHOT</version>
Copy link
Member

Choose a reason for hiding this comment

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

replace version with: <version>{{version}}</version>

<dependency>
<groupId>com.orbitz.consul</groupId>
<artifactId>consul-client</artifactId>
<version>0.14.0</version>
Copy link
Member

Choose a reason for hiding this comment

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

create a <consul.version>0.14.0</consul.version> property in parent pom and use it here.

import java.util.UUID;
import java.util.concurrent.TimeUnit;

public class ConsulModule implements Jooby.Module {
Copy link
Member

Choose a reason for hiding this comment

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

add javadoc like you did in consul.md


private final String name;

public ConsulModule() {
Copy link
Member

Choose a reason for hiding this comment

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

add javadoc to default constructor

this("default");
}

public ConsulModule(String name) {
Copy link
Member

Choose a reason for hiding this comment

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

javadoc to specialized constructor

@pierredavidbelanger
Copy link
Contributor Author

Thank you for your comments!
I agree with all of them, they make sense.

I guess I need to add the module to the bom too? I never really understood this bom thing :)

Unit test is already on the way.
I understand you target 100% code coverage.

@jknack
Copy link
Member

jknack commented Apr 22, 2017

I'm impressed on how you find things that are not documented (like the bom or the startAsync in your previous pull) well done!

Bom is auto-generated with ./release.sh.

Coverage?

It is bit more tricky. There is a script to launch: ./coverage.sh but then you need to add the jooby-consul project to the classpath of coverage, checkout coverage/pom.xml
Once the script finished you will find the report at: coverage-report/target/site/jacoco/index.html

@jknack
Copy link
Member

jknack commented Apr 23, 2017

Hi @pierredavidbelanger,

I would like to release 1.1.1 later today. Should I wait for consul module?

Thanks

@pierredavidbelanger
Copy link
Contributor Author

Oh, I guess it is ready, code wise.
But there is a clear lack of documentation :)

I can write the javadoc first.
Then the web site doc.

Anyway, do not compromise your 1.1.1 release date because of this module.

@pierredavidbelanger
Copy link
Contributor Author

I guess everything you asked is now commit and pushed to this PR.

If you want to include this module into your 1.1.1 release, I can do a rebase and cleanup the commit history today before you have a look at the finished product and merge it.

Copy link
Member

@jknack jknack left a comment

Choose a reason for hiding this comment

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

Can you rename ConsulModule to Consul?

You will need to update the doc too

@pierredavidbelanger
Copy link
Contributor Author

Sure I can,
but users will have to use FQN of com.orbitz.consul.Consul or now org.jooby.consul.Consul to avoid clash if both classes are used in the same .java file.

so, either:

use(new org.jooby.consul.Consul());

or

get("/", () -> {
  com.orbitz.consul.Consul consul = require(com.orbitz.consul.Consul.class);
});

Do I make this change anyways ?
Do you propose an alternative name ?

@jknack
Copy link
Member

jknack commented Apr 27, 2017

Oh I see: Consulby :)

@pierredavidbelanger
Copy link
Contributor Author

Nice :)
So I refactor ConsulModule to Consulby.

@pierredavidbelanger
Copy link
Contributor Author

Rebased on master and also squashed into a nice single commit

@jknack jknack added the feature label Apr 27, 2017
@jknack jknack added this to the 1.1.1 milestone Apr 27, 2017
@jknack jknack added the consul label Apr 27, 2017
@jknack jknack merged commit 4b2ca5e into jooby-project:master Apr 27, 2017
@jknack jknack changed the title initial commit for a jooby consul module jooby consul module Apr 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants