Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

WIP Cloud Map Service Discovery #551

Draft
fitzoh wants to merge 7 commits into spring-attic:main
base: main
Choose a base branch
Loading
from fitzoh:master
Draft

Conversation

@fitzoh
Copy link

@fitzoh fitzoh commented May 2, 2020

Super janky minimal implementation of an AWS Cloud Map based Service Discovery client (#398).
Currently meant as more of a conversation starter than something ready for a full review.

Note that @darylrobbins has a more fleshed out version of this parked in a branch, but I didn't feel comfortable opening a PR with his code.

hjander reacted with thumbs up emoji hjander reacted with heart emoji hjander reacted with rocket emoji
// TODO filter on health?
return aws.listInstances(listInstancesRequest).getInstances().stream()
.map(summary -> getInstance(serviceId, summary.getId()))
.collect(Collectors.toList());
Copy link
Author

Choose a reason for hiding this comment

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

Currently making a bunch of sequential HTTP requests, any suggested alternatives?
Is it reasonable to pull in reactor here?

Copy link
Contributor

@spencergibb spencergibb May 5, 2020

Choose a reason for hiding this comment

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

potentially, there's also ReactiveDiscoveryClient

Copy link
Author

Choose a reason for hiding this comment

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

Added a reactive client in fdffdf1.

@Override
public List<ServiceInstance> getInstances(String serviceId) {
ListInstancesRequest listInstancesRequest = new ListInstancesRequest()
.withServiceId(serviceId);
Copy link
Author

Choose a reason for hiding this comment

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

Should we always be filtering for healthy instances only, or is that generally a configurable option?

Copy link
Contributor

@spencergibb spencergibb May 5, 2020

Choose a reason for hiding this comment

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

Could be an option or also could go in a filter for instance in ribbon or spring cloud loadbalancer

Copy link
Author

Choose a reason for hiding this comment

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

ServiceInstance doesn't appear to have a health property, would that mean it would just need to look it up as a string via getMetadata?

Copy link
Author

fitzoh commented May 2, 2020

Any particular implementations I should take a look at for testing inspiration?

Copy link
Contributor

@spencergibb spencergibb left a comment

Choose a reason for hiding this comment

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

Looks interesting, needs to provide ReactiveDiscoveryClient

// TODO filter on health?
return aws.listInstances(listInstancesRequest).getInstances().stream()
.map(summary -> getInstance(serviceId, summary.getId()))
.collect(Collectors.toList());
Copy link
Contributor

@spencergibb spencergibb May 5, 2020

Choose a reason for hiding this comment

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

potentially, there's also ReactiveDiscoveryClient

@Override
public List<ServiceInstance> getInstances(String serviceId) {
ListInstancesRequest listInstancesRequest = new ListInstancesRequest()
.withServiceId(serviceId);
Copy link
Contributor

@spencergibb spencergibb May 5, 2020

Choose a reason for hiding this comment

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

Could be an option or also could go in a filter for instance in ribbon or spring cloud loadbalancer


@Override
public boolean isSecure() {
return getPort() == 443;
Copy link
Contributor

@spencergibb spencergibb May 5, 2020

Choose a reason for hiding this comment

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

Is this always the case?

Copy link
Author

Choose a reason for hiding this comment

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

That's more of a best guess at the moment:

$ aws servicediscovery list-instances --service-id=srv-blah
{
 "Instances": [
 {
 "Id": "fitz-test-instance",
 "Attributes": {
 "AWS_INSTANCE_IPV4": "blah",
 "AWS_INSTANCE_IPV6": "blah blah blah",
 "AWS_INSTANCE_PORT": "8080"
 }
 }
 ]
}

Copy link
Author

fitzoh commented May 10, 2020

Got some of the configuration boilerplate knocked out, not sure what's next/what kind of testing makes sense for this

Comment on lines +47 to +52
ListInstancesRequest listInstancesRequest = new ListInstancesRequest().withServiceId(serviceId);
// TODO pagination
// TODO parallel requests?
// TODO filter on health?
return aws.listInstances(listInstancesRequest).getInstances().stream()
.map(summary -> getInstance(serviceId, summary.getId())).collect(Collectors.toList());
Copy link

Choose a reason for hiding this comment

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

I'd recommend using the DiscoverInstances API that is built for this use-case.

  • No need for pagination
  • Filter on the health status is included out of the box

https://docs.aws.amazon.com/cloud-map/latest/api/API_DiscoverInstances.html

fmalhe, liammooney, and priiiiit reacted with thumbs up emoji
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers

@spencergibb spencergibb spencergibb left review comments

@vanekjar vanekjar vanekjar left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

status: waiting-for-triage An issue we've not yet triaged

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /