-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
Allow grouping servers #654
Comments
A server, to the application, is in most cases an endpoint (for WS and HTTP, it is a little bit more), that the application can connect to. In my mind, it should not know anything about the physical infrastructure (physical servers) as that has a tendency to be volatile. So defining the endpoint has always been enough for my use case when designing the API. So even though it is not possible to explicitly describe the physical servers, my rebound question would be why do you really want to describe them? 🤔
Sorry, I think you need to specify this one a bit further, as I don't see the use-case 😅 |
@jonaslagoni I've updated the description of the PR and title to simplify the concept. It's just about grouping servers. A way of grouping servers under a group name, that can map with a service name, a bounded context, a team, etc. |
I'm surprised you didn't play the "environment" card. Some people already requested we add a way to group servers by the environment, e.g., production, staging, development, etc. This way, you could have generators or Glee to run the code for Since there are a myriad of cases, I'm wondering if we shouldn't just allow |
Yeah, after the simplification I made, this is mostly the same as #623 (different fashion). The downside is that tooling won't be able to assume any those tags are present, nor set an expected tag name. For example, the html-template won't be able to group by environment but just by tags, which loses a bit the context and perhaps some specific logic (we might want to do in the future) behind. I think going with a generic approach makes total sense; making servers be discoverable, filtered, and categorized by anything is the best extendable approach. Not adding anything you didn't mention already @fmvilas. |
I think they're unrelated. This proposal is suggesting a way to prefix channel names, which I'd highly discourage now that we can associate channels with servers. And in v3 you'll be able to fully reuse channels so no need for it IMHO. But yeah, not sure what does it have to do with this proposal here 🤔 |
The fact that just one field could work for both features. I just wanted to mention it here. Of course, it could be done by selecting a tag for the prefix. But not important to this issue. |
🤔 If we ever implement support for channel prefix, I don't think it should be a tag. That would be super unexpected 😅 |
I would prefer to go in the direction of something more generic like the mentioned tags, but there is one problem, because currently tags work like classic tags, so their key (the - name: environment
values: [production, ...]
Why a list of values and not a single value? In the case of the environment it's not that necessary, but for other keys there may be a need to define several values for better filtering, e.g. adding a given server etc to the given group(s). Thanks to such solution it would be possible to filter (in Studio and html-template) by given type of object (server/operation etc) and key and tag value. Additionally, we could always create official tags (just like Kubernetes has created official labels, which can be overwritten, but then the tooling stops working) - like this one |
The reality is that with current tags you can make it work by composing a unique tag, such as However, this gives too much flexibility to users, but it will penalize tooling and it's UX since no format standard will be in place. Especially hard when displaying those tags in documentation, or when filtering by any of those tags. For example, filtering by the Regarding your suggestion @magicmatatjahu, I like the idea of adding a new field for declaring the value. We should be mindful that by allowing multiple values, filters/selectors will be harder to implement because you will need to specify which strategy the user wants to follow (so implementation as well), especially around inclusion/exclusion of values. - name: privacy-policy
values: [soc, soc1, soc2, gdpr]
Another alternative solution for not having an array in there will be to declare the same tag multiple times but with different value. But this is just the same afaik. |
I know it can be done through a discriminator but I want to avoid it.
Yeah, but have in mind that this "problem" is in tooling side, not in the spec itself. You have possibility to cover you cases with
You cannot do this, you can define only one time given name in |
I created the following PR's for adding the
If we finally move forward, I will then create a new PR allowing Tags to be defined at server level. |
Well, yes, I know, I'm pretty late in this convo, but still.. 😄 After looking on the PR and also this issue I'm not sure what use case are we exactly solving. I saw description about concept with file with common servers, I also saw this:
but I do not understand how it helps. Would you expect a kind of possibility to reference from The only use case I see is from a documentation perspective, that you can somehow mark a set of servers as Anyway, my entire convo is about the fact that I can see only one use case - environments, that some time ago was already brought in, when we talked about connecting "servers" with specific "channels" |
No, I wouldn't expect that at all. If we wanted to somehow do that we would need to change how servers:
development:
server1:
url: https://api.foo.systems:8080
protocol: http
server2:
url: https://ws.foo.systems:5000
protocol: was Which I don't think it is ideal nor needed.
Exactly, that's the right case at this moment. As you can see, we just need a way of marking servers with a tag or label, that can be added to any servers.
I took a look at it. Even though I see Metadata-style object could be a fit, it seems that Metadata's purpose is not to categorize or group things together. However, If we read the tags description beginning:
Which made me give another think to this. See below.
At this moment, and after giving several thoughts, I'm more convinced than ever about the fact Tags are enough for what we need here. Let me explain it. By reading our current description or what Tags are for, it reveals the nature of it, which is adding metadata to resources that can be used for grouping:
The question I'm doing myself is: Should we really add this new I pronounced earlier about this with:
But the reality is that everything is possible. For most of the use cases, composable tags (i.e. - name: "env:prod"
- name: "env:dev" However, In the case we need composable tag names, such as - name: "owner:team_a"
- name: "owner:team_b" In summary, I would say we could go discard this PR, and rather write some examples or even an optional format convention (like the one I suggested in my examples above) that can be later on supported by tooling. Do you think it makes more sense to use Tags now @derberg ? cc @magicmatatjahu @fmvilas @dalelane |
For reference: Maybe there are more use cases or needs for Tags. #744 |
I'm going to create an RFC adding Tags to the Server Object. Candidate for 2.5.0 version of the spec. |
PRs adding support for Tags at Server level: |
🎉 This issue has been resolved in version 3.0.0-next-major-spec.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 2.5.0-next-spec.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Recent comments about the release from the bot were added by mistake. More details in #899 |
Context
Current Server Object is identified by the key on
servers
map. E.g.:In the previous example, the word
production
identifies the server. We could also call it by it's server machine name or service name, e.g.yavin04.yavin.systems
.No matters what name do we use for the server as far as are unique in the
servers
map.One common pattern (See #628) is to declare reusable servers in common AsyncAPI files, then reference them in the specific AsyncAPI files. E.g.
What if a server exposes multiple ports with different protocols? Current Spec forces to create a different Server Object for this matter, since only one protocol is allowed per server. E.g.:
The problem
How can a user answer the question: "How can I identify the list of real/physical servers or service names in my system?", where
system
refers to the infrastructure around this or all my applications.Also from the point of view of code generators, the same answer could be formulated. For example. "Generate all servers from service name
yavin04.yavin.systems
". This will end up generating one forhttp
protocol, and another one forws
.Another example is for tooling like the Event-Gateway, where several servers relate to the same service. See this.
Possible solutions
Solution 1: Use the
url
fieldBy using the
url
field, we could group all described servers. Of course getting rid of any variable on it such as the port, etc.This seems a quick and easy solution, but it has some important drawbacks; the most important to me is that URLs can differ from one protocol to another. Not only the port but also the DSN on it. E.g.:
Having reached this point, there is no way to identify the real server behind, unless we play with some particular server name format. More in next bullet.
Solution 2: Use a custom name format
The user could set a known format for the server name, e.g.
{servername}-{protocol}-{port}
, which will look likeyavin04.yavin.systems-http-8080
andyavin04.yavin.systems-ws-5000
. This way, we could identify the physic/real server behind by extracting it from the name, in this case{servername}
section.Even though I consider this a really good practice that should be followed anyway, there is a clear drawback: not supported by tooling. As it is no a standard in the spec, tooling won't care that much about the name following a format. Grouping Server Objects by real/physic servers when for example generating documentation won't be a thing.
Solution 3: Add a new field on Server Object.
Supporting a new optional field on Server Object, such as
service
,serviceName
or justgroup
. E.g.:This new field would be totally optional and won't act as a object identifier.
Thanks to this new field, we could generate some cool documentation, grouping servers by their serviceName, or rather just add a new tag to those with a value on it. I generated a simple mock of the most simple solution, but I think we could do much better 😅
Suggestion
I would prefer following Solution 3 and adding a new field to the Server Object.
What do you all think? Do you find it useful?
The text was updated successfully, but these errors were encountered: