RateLimitCounter class

Rate limit counts shared by all isolates of the app.

The main isolate owns the counts. The other isolates send each increment to it through a SendPort and wait for the new count. DoxIsolate gives every isolate it starts the port of the main isolate, and the isolate calls connect with it.

In the main isolate (and in an app with one isolate) the count is made in place, with no message.

Properties

hashCode → int
The hash code for this object.
no setterinherited
port → SendPort
The port other isolates send their increments to. Opened on the first call, in the isolate that owns the counts (the main isolate).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → void
close the ports and forget all counts
connect(SendPort? owner) → void
count in the isolate that owns owner (a port) from now on. null counts in this isolate.
increment(String key, Duration ttl) → Future<int>
Adds one to key and gives the new count. A new key, or a key older than ttl, starts at 1.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

instance → RateLimitCounter
one per isolate
final

Constants

timeout → const Duration
the most time to wait for the main isolate. After it, the count is made in this isolate, so a request never hangs (eg. during shutdown).