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

Add Consul publisher #100

Merged
merged 1 commit into from
Oct 29, 2015
Merged

Add Consul publisher #100

merged 1 commit into from
Oct 29, 2015

Conversation

xla
Copy link
Member

@xla xla commented Aug 17, 2015

open questions

  • Is it allowed to return stale endpoints?
  • Are publishers expected to return ip:port or are hostnames equally valid?
  • Does it suffice to only be able to filter by one tag?

todos

  • only emit endpoints when different
  • documentation
  • example
  • tests

The commits in this branch will be cleaned up in time and likely stashed into a single coherent change-set.

@peterbourgon
Copy link
Member

Is it allowed to return stale endpoints?

Is stale a term of art in Consul? In the normal case, if the publisher knows an endpoint is broken, it shouldn't emit it via Endpoints. If a publisher suspects an endpoint might be broken, then it's a gray area, perhaps best resolved with a configuration setting during construction, or deferring to best practice of the SD system.

Are publishers expected to return ip:port or are hostnames equally valid?

Is a hostname sufficient to create a connection to the remote service? If yes, then it's fine. But that means you're carrying the service along implicitly—I can't think of a good use case for that. Do you have one?

Does it suffice to only be able to filter by one tag?

Per our discussion yesterday, I'm guessing not.

@peterbourgon peterbourgon mentioned this pull request Aug 27, 2015
@peterbourgon peterbourgon mentioned this pull request Sep 3, 2015
@brendan-munro
Copy link

I've been integrating this code into our migration to using a full publisher/loadbalancer implementation with go-kit and have been very happy with it! One thing I have noticed about the implementation:

When reading a service from a Consul health API check there are actually two potential fields the address of a service can appear in, either ServiceEntry.Node.Address or ServiceEntry.Service.Address.

The reason these two can differ is as a result of the configuration of a particular Consul datacenter. The service address field is populated if a specific address has been specified for a service configuration on a given node. This is usually a result of loading a service into Consul that cannot have a Consul agent run on its host OS. This results in the Node address referring to the hosting agent, and the service address referring to the actual resolved service location.

In our use cases, we treat the service address as an override to the node address, as it is empty when not in use. This is helpful in development environments when you want to run a local Consul server pointing to external dependencies.

@peterbourgon
Copy link
Member

@EcofitBrendan Great to hear! Would you be willing to contribute your implementation as a PR when you're happy with it?

@brendan-munro
Copy link

@peterbourgon Definitely, I should have something functional available over the next few days.

@peterbourgon
Copy link
Member

@EcofitBrendan I'm going to pick this up now, unless you have something ready to go?

@xla
Copy link
Member Author

xla commented Oct 10, 2015

This is ready for review, in the meantime I'll work on the README with examples and high-level documentation. As soon as approved I'm going to stash the changes.

@EcofitBrendan Thanks for pointing out this intricacy. I added a test case to make sure the publisher accounts for it.

/cc @dlsniper @peterbourgon @tsenart

@xla
Copy link
Member Author

xla commented Oct 10, 2015

Currently not covered is the case for an update to the entries in Consul. This might be better suited for integration tests. Happy to cover it here as well, if deemed important for acceptance.

@xla xla changed the title [WIP] Add Consul publisher Add Consul publisher Oct 10, 2015
}
}

// GetInstances returns the list of entries for a given service filtered by
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is outdated.

@peterbourgon
Copy link
Member

Haven't audited for correctness or tested with a real Consul, but code structure LGTM. Do you want me to test in a live environment, or are you confident to merge?

@xla
Copy link
Member Author

xla commented Oct 19, 2015

@peterbourgon Would appreciate a real world test, if it doesn't mean too much time consumption for you.

@peterbourgon
Copy link
Member

I tested this with a live Consul cluster and it works well. I am happy to merge it. Is there anything else you'd like to do before I click the green button?

@xla
Copy link
Member Author

xla commented Oct 26, 2015

@peterbourgon Thanks for taking the time. I squashed the commits and am fine with merging this one. Will work on examples and documentation independently. Unfortunately the tests are failing since rebasing against master, it looks to be a change in the go-etcd dependency.

@peterbourgon
Copy link
Member

Yep, I will wait until etcd #246 is fixed and we can get a greenlight on CI before merging.

@xla
Copy link
Member Author

xla commented Oct 26, 2015

@peterbourgon Full ack.

@peterbourgon
Copy link
Member

Sorry, can you rebase on master and fix the build error? (I think that's what's causing the Travis failure...)

Implements a Publisher which connects to Consul and returns the
Endpoints for the requested service. Addtionally filtered by tags where
every tag beyond the first one needs to be filtered in the client.
@xla
Copy link
Member Author

xla commented Oct 29, 2015

@peterbourgon Done.

@peterbourgon
Copy link
Member

Woop woop

peterbourgon added a commit that referenced this pull request Oct 29, 2015
@peterbourgon peterbourgon merged commit 3978dae into go-kit:master Oct 29, 2015
@xla xla deleted the consul-publisher branch October 29, 2015 11:11
guycook pushed a commit to codelingo/kit that referenced this pull request Oct 12, 2016
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.

None yet

4 participants