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

Adds an EventBuilder to dissociate the DSL/builder from the client #84

Merged
merged 4 commits into from
Nov 20, 2017

Conversation

ggrossetie
Copy link
Contributor

The EventDSL is useful but at the same time the class is tightly coupled with the RiemannClient and the constructor is using java.net.InetAddress.getLocalHost() (which can make call to the DNS resolver... see #44).
Also in our context, we have a dedicated host that send events to Riemann (so the call to java.net.InetAddress.getLocalHost() is useless).

Using the low-level builder Proto.Event.newBuilder() as an alternative is a bit rough (at least for a newcomer).

As a result I've decided to create a new class named EventBuilder who's only job is to ease the creation of an Event. To avoid code duplication, EventDSL is using EventBuilder.
This change does not introduce a breaking change since the API of the EventDSL remains the same.

I've started to write one unit test (and I planned to write more and also add documentation) but before spending more time on it, I would like to hear from you. Are you OK with this change ?

@mcorbin
Copy link
Contributor

mcorbin commented Oct 12, 2017

+1 for this PR, i also want to be able to construct events without relying on a RiemannClient.

@jamtur01
Copy link
Member

@aphyr I am broadly +1 with test coverage but am not a regular user of the client. Do you have any thoughts?

@ggrossetie
Copy link
Contributor Author

I've added more tests and fixed a bug. The time() method was actually clearing the meticF attribute instead of the time attribute.

// health -> good
assertEquals("health", eventAttributes.get(2).getKey());
assertEquals("good", eventAttributes.get(2).getValue());
// health -> good
Copy link
Contributor

Choose a reason for hiding this comment

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

network_zone -> dmz

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch.
Actually I don't think these comments are really useful, I will remove them.

@mcorbin
Copy link
Contributor

mcorbin commented Oct 16, 2017

LGTM

@mcorbin
Copy link
Contributor

mcorbin commented Nov 20, 2017

@jamtur01 Ok to merge this PR ?

@jamtur01 jamtur01 merged commit 57d47af into riemann:master Nov 20, 2017
@jamtur01
Copy link
Member

Thanks!

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.

3 participants