IsolateInfo class final

The isolate the code runs in: its name, as the logs show it (%thread), and its place in the application's pool of isolates.

An application runs in one isolate, main, unless the web server runs a pool (server.isolates.count): then every isolate of the pool runs the whole application, with its own beans, and the first one is the primary. Use it for work that must happen once for the application and not once per isolate: a scheduled job, a data migration, a warm-up.

@Component()
class Migrations {
  Migrations(this.isolate);
  final IsolateInfo isolate;

  @PostConstruct()
  void run() {
    if (isolate.primary) migrate();
  }
}

The bean isolateInfo is current; the condition @ConditionalOnPrimaryIsolate() keeps a whole bean to the primary.

Spring has no counterpart: its beans share one JVM and its threads.

Constructors

IsolateInfo({String name = 'main', int index = 0, bool primary = true})
The isolate named name, number index of its pool.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
index → int
Its number in the pool; 0 for the primary.
final
name → String
The isolate's name in the logs: main, or isolate-2 in a pool.
final
primary → bool
Whether it is the first isolate of the application: the one that started the others, and the only one without a pool.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

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

Static Properties

current ↔ IsolateInfo
The isolate this code runs in. A pool sets it in each isolate it starts, before the application starts there.
getter/setter pair