-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
NET-5824 Exported services api #20015
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @tauhid621! 👏
I think you need an enterprise PR for this, so I will wait to see the enterprise PR before approving this, but nothing blocking so far!
api/config_entry_exports.go
Outdated
|
||
type ResolvedExportedService struct { | ||
// Service is the name of the service which is exported. | ||
Service string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this missing the json tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this field will always be present, I did not add the json:",omitempty"
tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just one minor comment
|
||
// If this isn't a wildcard, we can simply add it to the list of services to watch and move to the next entry. | ||
if svc.Name != structs.WildcardSpecifier { | ||
insertEntry(exportedServices, svcName, svc.Consumers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of converting to an intermediate map and then to another response why not add the list of services encountered here to a slice and pass it on to the prepareExportedServicesResponse
function? There you could just walkover the list of services and compute the response as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main purpose of the map is to avoid duplicate entries for service and consumers. Are you suggesting to create the map in the prepareExportedServicesResponse
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The map is still needed but it just looks cleaner if there a function that accepts a list of exported services and returns back the expected proto
response. The function's signature doesn't look that readable as of now. But I would leave it upto your best judgement here and let you take a call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the duplicate removal logic to a new function.
* Exported services api implemented * Tests added, refactored code * Adding server tests * changelog added * Proto gen added * Adding codegen changes * changing url, response object * Fixing lint error by having namespace and partition directly * Tests changes * refactoring tests * Simplified uniqueness logic for exported services, sorted the response in order of service name * Fix lint errors, refactored code
* Exported services api implemented * Tests added, refactored code * Adding server tests * changelog added * Proto gen added * Adding codegen changes * changing url, response object * Fixing lint error by having namespace and partition directly * Tests changes * refactoring tests * Simplified uniqueness logic for exported services, sorted the response in order of service name * Fix lint errors, refactored code
@tauhid621, a backport is missing for this PR [20015] for versions [1.17] please perform the backport manually and add the following snippet to your backport PR description:
|
NET-5824 Exported services api (#20015) * Exported services api implemented * Tests added, refactored code * Adding server tests * changelog added * Proto gen added * Adding codegen changes * changing url, response object * Fixing lint error by having namespace and partition directly * Tests changes * refactoring tests * Simplified uniqueness logic for exported services, sorted the response in order of service name * Fix lint errors, refactored code
Description
This PR adds support for an API to list exported services and their consumers. The sameness groups and wildcards are resolved to peers and services.
URL:
/v1/exported-services
Response:
Testing & Reproduction steps
Links
PR Checklist