-
Notifications
You must be signed in to change notification settings - Fork 5
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
How to specify quotas and rates for all operations? #7
Comments
Unfortunately, currently it is not supported such a mechanism and, therefore, you should repeat the same limits specifications for all the different paths. Nevertheless, I definitively think it could be great to have some sort of "syntax sugar" to avoid that repetition; perhaps to have some keyword like "global" to replace the path and define global limits. We can discuss this issue in the next TC Meeting that is held next Thursday and boost a pull request to include it in the spec. |
If you're using YAML, you could use its anchors and aliases. |
That is quite interesting @theganyo . Could you provide an example on how you would apply such a mechanism in an example of SLA4OAI? |
Sure. Here's the sample from the spec that I rewrote to use the same rate for each request as an example:
You obviously can't set globals without changing the spec, but YAML does allow you to define and reuse chunks anywhere like this. That said, this is only YAML - JSON doesn't support this, so it may still be desirable to include more formal references within the spec itself as OpenAPI does. |
@theganyo Thanks for that! Do you know how well it is supported by YAML readers? I see that https://godoc.org/gopkg.in/yaml.v3 has fields for anchors and aliases but guess that a reader would need to handle them explicitly. |
No, I don't have any specific knowledge about parser support. |
As discussed in today's call, I am planning to submit a PR that proposes using glob patterns to specify quotas and rates for groups of paths. We discussed the YAML option but noted that it is not available in JSON and doesn't seem to be widely used in the OpenAPI community, so we chose not to take it further. |
In our 1/14 meeting we discussed a desire to support richer defaults than #14 allows. This could be addressed with globbing, regular expressions, or by using a pending "overlay" capability in discussion for OpenAPI. |
Following the discussion of 1/14 meeting, a potential method to have an overlay-friendly method could be to transform the sla: 1.0.0
...
plans:
base:
availability: R/00:00:00Z/23:00:00Z
free:
rates:
- path: /pets/{id}
operation: get
limits:
requests:
- max: 1
period: second
- target: *.
operation: get
limits:
requests:
- max: 1
period: second
- pattern: "^mypath/*$"
operation: get
limits:
requests:
- max: 1
period: second
- id: GlobalRateLimit
limits:
requests:
- max: 1
period: second In the above example we have 4 different potential ways of anchoring:
In case this is an accepted approach, a further discussion should be developed on whether you could use multiple anchoring methods or you should only use one of them for each limit. |
Following the discussion of 05/04, we put on hold this issue until OAI TSC completes the discussion about overlays. |
As I read the spec, it appears that quotas and rates are always specified with metrics that are placed under specific paths and operations. I think this might be burdensome for large APIs, particularly when limits are expected to be the same for all operations. Is there a way to specify quotas and rates for all operations or for specified subsets of operations in an API?
The text was updated successfully, but these errors were encountered: