Generally if I put quota and reset quota in the same shared flow or if put quota in api proxy preflow and reset quota in FaultRules - all will work. But if I'd like split logic to shared flow so that one policy stay in proxy and other moved in shared flow - it doesn't work. Can please anybody help me how I can defined quota in shared flow and reset it in FaultRules? Second question: is it possible to reset quota in separeate call? errir is: Quota policy impose-quota is not attached.
Hi @Aliaksei Drapun, I didn't have any issue with this config,
how I can defined quota in shared flow and reset it in FaultRules
I used Quota(2 calls per minute) in SharedFlow and ResetQuota(5 calls per minutes) in Proxy FaultRules.
In Fault Rules, I am using an Assign Message policy to provide some custom message and a ResetQuota to add 5 more calls. This config is illogical, just for the sake of this example.
<FaultRules> <FaultRule name="quota-violation"> <Step> <Name>fault_Quota-Limit</Name> </Step> <Step> <Name>Add-Quota</Name> </Step> <Condition>(fault.name == "QuotaViolation")</Condition> </FaultRule> </FaultRules>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="fault_Quota-Limit"> <DisplayName>fault_Quota-Limit</DisplayName> <Set> <Headers> <Header name="X-API-Error">{faultString}</Header> </Headers> <Payload contentType="application/json"> \{"error":"Rate limit quota violation.", "detail":"Quota is set at 2pm", "note":"Reset Quota in fault rules would active after this error and add 5 more request to quota"} </Payload> <StatusCode>429</StatusCode> <ReasonPhrase>Quota Requests Exceeded</ReasonPhrase> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ResetQuota async="false" continueOnError="false" enabled="true" name="Add-Quota"> <DisplayName>Add-Quota</DisplayName> <Properties/> <!-- Quota name - should be the same name used for Quota policy in SharedFlow --> <Quota name="Quota-1"> <Identifier name="_default"> <Allow>5</Allow> </Identifier> </Quota> </ResetQuota>
Second question: is it possible to reset quota in separeate call? errir is: Quota policy impose-quota is not attached.
This error is given by ResetQuota Policy, check the name of the Quota used.
What do you mean by the separate call?
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |