Skip to content

alexeyinkin/dart-limit-rate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guards access to a given resource according to request rate limits.

Usage

In this setup, the handler may be called at most once per second and at most 10 times a minute. Calls over that limit will be delayed.

void main() async {
  final delayer = MessageDelayer<int, String>(
    rateLimits: [
      const RateLimit(requestCount: 1, timeMs: 1000),
      const RateLimit(requestCount: 10, timeMs: 60000),
    ],
    handler: (n) => n.toString(),
  );

  final str = await delayer.sendMessage(1);
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages