Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/laget-se/laget.limiter
A generic rate limiter, Useful for API clients, web crawling, or other tasks that need to be throttled...
https://github.com/laget-se/laget.limiter
nuget
Last synced: 22 days ago
JSON representation
A generic rate limiter, Useful for API clients, web crawling, or other tasks that need to be throttled...
- Host: GitHub
- URL: https://github.com/laget-se/laget.limiter
- Owner: laget-se
- License: apache-2.0
- Created: 2020-12-08T15:29:33.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-03T12:21:07.000Z (7 months ago)
- Last Synced: 2024-06-04T08:11:58.407Z (7 months ago)
- Topics: nuget
- Language: C#
- Homepage:
- Size: 79.1 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# laget.Limiter
A generic rate limiter, Useful for API clients, web crawling, or other tasks that need to be throttled...![Nuget](https://img.shields.io/nuget/v/laget.Limiter)
![Nuget](https://img.shields.io/nuget/dt/laget.Limiter)## Configuration
> This example is shown using Autofac since this is the go-to IoC for us.
```c#
builder.Register(c =>
new AuthorizationLimit(new MemoryStore(),
new StandardLimit(300, TimeSpan.FromHours(3)))
).SingleInstance();
```## Usage
> You can specifiy that a limiter should be used by the following
```c#
_limiter.Limit(() =>
{
...
});
```> You can also specify that a kown amount of call will be hit by the following
```c#
_limiter.Limit(2, () =>
{
...
});
```> You can aslo specify additional calls by the following
```c#
limiter.Limit(() =>
{
limiter.Register(3);
});
```> You can aslo use it asynchronous by the following
```c#
await limiter.LimitAsync(() => Task.CompletedTask);
```## Stores
### Mongo
> This example is shown using Autofac since this is the go-to IoC for us.
```c#
builder.Register(c =>
new AuthorizationLimit(new MongoStore(new MongoUrl(c.Resolve().GetConnectionString("MongoConnectionString")), "authorization.calls"),
new StandardLimit(300, TimeSpan.FromHours(3)))
).SingleInstance();
```