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

Expose styx provider object database in YAML via admin interface #637

Merged

Conversation

chrisgresty
Copy link
Contributor

See #635

Copy link
Contributor

@mikkokar mikkokar left a comment

Choose a reason for hiding this comment

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

Hi Chris. Could you check my last comment regarding list vs map? I think we should render this out as a map as opposed to list. Unless there are good reasons to do otherwise. What do you think?

.stream()
.map(entry -> createObjectDef(entry.getKey(), entry.getValue()))
.collect(Collectors.toList());
String output = serialise(objects);
Copy link
Contributor

Choose a reason for hiding this comment

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

An opinionated comment, but I would inline the objects because it is only ever passed on to serialise method. ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. In this case I find it flows better as it is, because the stream construction is (in my mind) quite different to the method call, and inlining just results in my eye bouncing around a little more than I'd like.
Ideally I'd have liked to be able to follow the .collect() with .serialise() (or some construction with ::serialise) but that's not available. Visually, I think this is the next best thing. But I'll change it (and the others) if you feel moderately strongly about it.

.build());
}

private Eventual<HttpResponse> handleRequestForOneObject(HttpRequest request, HttpInterceptor.Context context,
Copy link
Contributor

Choose a reason for hiding this comment

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

The request and context arguments are never used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not exactly sure why I left them in.

.collect(joining("\n"));
.map(entry -> createObjectDef(entry.getKey(), entry.getValue()))
.collect(Collectors.toList());
String output = serialise(objects);
Copy link
Contributor

Choose a reason for hiding this comment

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

Opinionated: I would inline objects because it is only ever passed, unconditionally, as an argument to objects. Therefore it just adds noise. :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly below, too.

timeoutMillis: 250
intervalMillis: 500
healthyThreshold: 3
unhealthyThreshold: 2
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add here another object. So that the list would render at least two or more objects.

tags: []
config:
status: 200
content: "Root"
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... 🤔

So conceptually this is a map. Also in styx yaml configuration this is represented as a map. But now this implementation renders it as a list.

For consistency, I would prefer the admin interface also to render it as a map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, of course. I should have noticed that the config yaml uses maps, not lists here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the case where we are requesting a single object, should it be as now (with name as an attribute) or in a map format (with name as the key)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eh, forget that, it should be the single object payload with no name: attribute and no key.

}

scenario("YAML configuration for a single provider is available") {
val body = styxServer.adminRequest("/admin/providers/objects/myMonitor")
Copy link
Contributor

Choose a reason for hiding this comment

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

A small nag: IMHO the url should be /admin/provider/objects (The provider component should be in singular). /admin/providers/objects sounds wrong because both providers and objects are plural.

Do you think we could change it as a part of this PR, or would this warrant a separate PR?

Copy link
Contributor Author

@chrisgresty chrisgresty Mar 5, 2020

Choose a reason for hiding this comment

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

There are a number of related URLs that could be changed like this - raised a new issue #641 to cover this.

@chrisgresty chrisgresty merged commit 7e1154e into ExpediaGroup:master Mar 6, 2020
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