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 endpoint to look up services by host and port #290

Merged
merged 8 commits into from
Dec 19, 2018

Conversation

pschoenfelder
Copy link
Contributor

No description provided.

throw Throwables.propagate(e);
}
return Optional.absent();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems horribly inefficient, but can't think of anything better since zk is backing it. Unless there's another place this data is stored I don't know about?

Copy link
Member

Choose a reason for hiding this comment

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

Check out how the state resource is grabbing this data. There should be a precompiled Collection (which includes the upstreams) in memory already

for (BaragonServiceState state : services) {
for (UpstreamInfo upstreamInfo : state.getUpstreams()) {
if (upstreamInfo.getUpstream().matches(String.format("%s\\.\\w+:%s", host, port))) {
return state;
Copy link
Member

Choose a reason for hiding this comment

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

It's possible that there is more than one, we should probably return a List/Collection

Collection<BaragonServiceState> services = objectMapper.readValue(stateCache.getState().getUncompressed(), new TypeReference<Collection<BaragonServiceState>>(){});
for (BaragonServiceState state : services) {
for (UpstreamInfo upstreamInfo : state.getUpstreams()) {
if (upstreamInfo.getUpstream().matches(String.format("%s\\.\\w+:%s", host, port))) {
Copy link
Member

Choose a reason for hiding this comment

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

why the regex here instead of a straight .equals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm assuming people will send in params like adjective-noun and 1234, but the upstreams are in the format adjective-noun.env.network.net:1234, so equals won't work. We can change the input type, or make this regex much more specific. Either is good with me.

Copy link
Member

Choose a reason for hiding this comment

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

We can expect the full dns name:port, the short hostnames is only an internal shortcut

@pschoenfelder pschoenfelder merged commit 1d958cd into master Dec 19, 2018
@pschoenfelder pschoenfelder deleted the host-port-lookup branch December 19, 2018 21:09
@ssalinas ssalinas added this to the 0.8.0 milestone May 30, 2019
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.

2 participants