Open senolatac opened 3 years ago
Hey @senolatac
Yes you're in custom plugin territory at this point. You can change the key objects directly from the plugin so can increment the quota counter by each of the possible values depending on your path/method etc.
If you write something in Go and it's sturdy we always consider inclusion into the main set of Gateway middlewares if it is a general solution for users. Or we can include any plugin solutions you come up with in this plugins meta repository.
Hey @joshblakeley,
Actually, currently I try tyk-cloud and I want to implement this option. Is it possible with tyk-cloud? or is it possible only on-premise?
Yep you can use plugins in cloud with the caveat that we need to load the code from trusted sources so you use our Mserv tool to get your custom code on S3 and then we pull from there to the gateways.
Docs are here https://tyk.io/docs/tyk-cloud/using-plugins/
Alright, how can I debug the request? Is it possible? (Because I should figure out request counter header) And is it possible implement with java? I saw some plugins with java.
On the cloud gateways hosted by Tyk it's just javascript and python currently (and Go too but it's a little more experimental) - though if you run a hybrid gateway then all plugin types will work.
You could do it without any special header if you wanted too - set the quota for a key to the GCF of the various weights and then just add them per path per request by modifying that key, there is an SDK for the javascript plugins for example that lets you call up and edit a key by some ID - that way you take advantage of the native quota mechanism.
For the development phase you could just run the APIs with the plugin on a local gateway just using the open source GW since it will operate exactly the same as on cloud.
@joshblakeley I couldn’t get the exact idea in here. You mean that?
X-Ratelimit-Remaining = X-Ratelimit-Remaining - x-custom-header
, quota will be decreased like that... I think in here the important thing is quota counter. Am I handle it via X-Ratelimit-Remaining
?
Do you mean like this?
@joshblakeley I think that there is misunderstanding in here.
Let me explain my ideal scenario:
X-Ratelimit-Limit=10
, X-Ratelimit-Remaining=10
X-Ratelimit-Remaining=3
=> 10 - 7 = 3X-Ratelimit-Remaining=0
=> 3 - 3 = 0
We would like to set custom quota usage per endpoint.
For example endpoint "xxx" will use 1 point per request, whereas endpoint "yyy" will use 5 point per request. And if the user has 100 quota limit, he can call 100 "xxx" requests or 20 "yyy" requests. Or 20 "xxx" and 16 "yyy" requests.
Is it implementable with custom-plugins?