You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/features/graphql.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ We wanted to show how easy it is to integrate the `GraphQL for .NET <https://git
12
12
Please see the sample project `OcelotGraphQL <https://github.com/ThreeMammals/Ocelot/tree/main/samples/OcelotGraphQL>`_.
13
13
Using a combination of the `graphql-dotnet <https://github.com/graphql-dotnet/graphql-dotnet>`_ project and Ocelot :doc:`../features/delegatinghandlers` features, this is pretty easy to do.
14
14
However we do not intend to integrate more closely with **GraphQL** at the moment.
15
-
Check out the samples `README.md <https://github.com/ThreeMammals/Ocelot/blob/main/samples/OcelotGraphQL/README.md>`_ and that should give you enough instruction on how to do this!
15
+
Check out the samples `README.md <https://github.com/ThreeMammals/Ocelot/blob/main/samples/GraphQL/README.md>`_ and that should give you enough instruction on how to do this!
Copy file name to clipboardexpand all lines: docs/features/ratelimiting.rst
+44-19
Original file line number
Diff line number
Diff line change
@@ -27,23 +27,25 @@ To implement *rate limiting* for a Route, you need to incorporate the following
27
27
"Limit": 1
28
28
}
29
29
30
-
* **ClientWhitelist** - An array containing the whitelisted clients. Clients listed here will be exempt from rate limiting.
31
-
For more information on the **ClientIdHeader** option, refer to the :ref:`rl-global-configuration` section.
32
-
* **EnableRateLimiting** - This setting enables rate limiting on endpoints.
33
-
* **Period** - This parameter defines the duration for which the limit is applicable, such as ``1s`` (seconds), ``5m`` (minutes), ``1h`` (hours), and ``1d`` (days).
34
-
If you reach the exact **Limit** of requests, the excess occurs immediately, and the **PeriodTimespan** begins.
35
-
You must wait for the **PeriodTimespan** duration to pass before making another request.
36
-
Should you exceed the number of requests within the period more than the **Limit** permits, the **QuotaExceededMessage** will appear in the response, accompanied by the **HttpStatusCode**.
37
-
* **PeriodTimespan** - This parameter indicates the time in **seconds** after which a retry is permissible.
38
-
During this interval, the **QuotaExceededMessage** will appear in the response, accompanied by an **HttpStatusCode**.
30
+
* ``ClientWhitelist``: An array containing the whitelisted clients. Clients listed here will be exempt from rate limiting.
31
+
For more information on the ``ClientIdHeader`` option, refer to the :ref:`rl-global-configuration` section.
32
+
* ``EnableRateLimiting``: This setting enables rate limiting on endpoints.
33
+
* ``Period``: This parameter defines the duration for which the limit is applicable, such as ``1s`` (seconds), ``5m`` (minutes), ``1h`` (hours), and ``1d`` (days).
34
+
If you reach the exact ``Limit`` of requests, the excess occurs immediately, and the ``PeriodTimespan`` begins.
35
+
You must wait for the ``PeriodTimespan`` duration to pass before making another request.
36
+
Should you exceed the number of requests within the period more than the ``Limit`` permits, the ``QuotaExceededMessage`` will appear in the response, accompanied by the ``HttpStatusCode``.
37
+
* ``PeriodTimespan``: This parameter indicates the time in **seconds** after which a retry is permissible.
38
+
During this interval, the ``QuotaExceededMessage`` will appear in the response, accompanied by an ``HttpStatusCode``.
39
39
Clients are advised to consult the ``Retry-After`` header to determine the timing of subsequent requests.
40
-
* **Limit** - This parameter defines the upper limit of requests a client is allowed to make within a specified **Period**.
40
+
* ``Limit``: This parameter defines the upper limit of requests a client is allowed to make within a specified ``Period``.
41
41
42
42
.. _rl-global-configuration:
43
43
44
44
Global Configuration
45
45
^^^^^^^^^^^^^^^^^^^^
46
46
47
+
Global options are only accessible in the special :ref:`routing-dynamic` mode.
48
+
47
49
You can set the following in the ``GlobalConfiguration`` section of `ocelot.json`_:
48
50
49
51
.. code-block:: json
@@ -58,26 +60,49 @@ You can set the following in the ``GlobalConfiguration`` section of `ocelot.json
58
60
}
59
61
}
60
62
61
-
* **DisableRateLimitHeaders** - Determines if the ``X-Rate-Limit`` and ``Retry-After`` headers are disabled.
62
-
* **QuotaExceededMessage** - Defines the message displayed when the quota is exceeded. It is optional and the default message is informative.
63
-
* **HttpStatusCode** - Indicates the HTTP status code returned during *rate limiting*. The default value is **429** (`Too Many Requests`_).
64
-
* **ClientIdHeader** - Specifies the header used to identify clients, with ``ClientId`` as the default.
65
63
66
-
Future and ASP.NET Core Implementation
67
-
--------------------------------------
64
+
.. list-table::
65
+
:widths: 35 65
66
+
:header-rows: 1
67
+
68
+
* - *Property*
69
+
- *Description*
70
+
* - ``DisableRateLimitHeaders``
71
+
- Determines if the ``X-Rate-Limit`` and ``Retry-After`` headers are disabled
72
+
* - ``QuotaExceededMessage``
73
+
- Defines the message displayed when the quota is exceeded. It is optional and the default message is informative.
74
+
* - ``HttpStatusCode``
75
+
- Indicates the HTTP status code returned during *rate limiting*. The default value is **429** (`Too Many Requests`_).
76
+
* - ``ClientIdHeader``
77
+
- Specifies the header used to identify clients, with ``ClientId`` as the default.
78
+
79
+
Notes
80
+
"""""
81
+
82
+
1. Global ``RateLimitOptions`` are supported when the :ref:`sd-dynamic-routing` feature is configured with :doc:`../features/servicediscovery`.
83
+
Hence, if :doc:`../features/servicediscovery` is not set up, only the options for static routes need to be defined to impose limitations at the route level.
84
+
2. Global *Rate Limiting* options may not be practical because they impose limits on all routes.
85
+
It's reasonable to assert that in a Microservices architecture, it's an unusual approach to apply the same limitations to all routes.
86
+
Configuring per-route limiting could be a more tailored solution.
87
+
Global *Rate Limiting* is logical if all routes share the same downstream hosts, thus limiting the usage of a single service.
88
+
3. *Rate Limiting* is now built-in with ASP.NET Core 7, as discussed in the following topic below.
89
+
Our team holds the view that the ASP.NET ``RateLimiter`` enables global limitations through its rate limiting policies.
90
+
91
+
Future and ASP.NET Implementation
92
+
---------------------------------
68
93
69
94
The Ocelot team is contemplating a redesign of the *Rate Limiting* feature following the `Announcing Rate Limiting for .NET`_ by Brennan Conroy on July 13th, 2022.
70
95
Currently, no decision has been made, and the previous version of the feature remains part of the `20.0`_ release for .NET 7. [#f2]_
71
96
72
-
Discover the new features being introduced in the ASP.NET Core 7.0 release:
97
+
Discover the new features in the ASP.NET Core 7.0 release:
73
98
74
99
* The `RateLimiter Class <https://learn.microsoft.com/en-us/dotnet/api/system.threading.ratelimiting.ratelimiter>`_, available since ASP.NET Core 7.0
75
100
* The `System.Threading.RateLimiting <https://www.nuget.org/packages/System.Threading.RateLimiting>`_ NuGet package
76
101
* The `Rate limiting middleware in ASP.NET Core <https://learn.microsoft.com/en-us/aspnet/core/performance/rate-limit>`_ article by Arvin Kahbazi, Maarten Balliauw, and Rick Anderson
77
102
78
-
While retaining the old implementation as an Ocelot built-in feature makes sense, we plan to transition to the new Rate Limiter from the ``Microsoft.AspNetCore.RateLimiting`` namespace.
103
+
While it makes sense to retain the old implementation as a built-in feature of Ocelot, we are planning to transition to the new Rate Limiter from the ``Microsoft.AspNetCore.RateLimiting`` namespace.
79
104
80
-
Please share your thoughts with us in the `Discussions <https://github.com/ThreeMammals/Ocelot/discussions>`_ space of the repository. |octocat|
105
+
We invite you to share your thoughts with us in the `Discussions <https://github.com/ThreeMammals/Ocelot/discussions>`_ space of the repository. |octocat|
0 commit comments