LoadBalancer class

A pool of runners, ordered by load.

Keeps a pool of runners, and allows running function through the runner with the lowest current load.

The number of pool runner entries is fixed when the pool is created. When the pool is closed, all runners are closed as well.

The load balancer is not reentrant. Executing a run function should not synchronously call methods on the load balancer.

Implemented types

Constructors

LoadBalancer(Iterable<Runner> runners)
Create a load balancer backed by the Runners of runners.

Properties

hashCode int
The hash code for this object.
no setterinherited
length int
The number of runners currently in the pool.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() Future<void>
Stop the runner.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run<R, P>(FutureOr<R> function(P argument), P argument, {Duration? timeout, FutureOr<R> onTimeout()?, int load = 100}) Future<R>
Execute the command in the currently least loaded isolate.
override
runMultiple<R, P>(int count, FutureOr<R> function(P argument), P argument, {Duration? timeout, FutureOr<R> onTimeout()?, int load = 100}) List<Future<R>>
Execute the same function in the least loaded count isolates.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

create(int size, Future<Runner> createRunner()) Future<LoadBalancer>
Asynchronously create size runners and create a LoadBalancer of those.