DoxProvider class abstract

A provider sets up a part of the app when it starts, eg. the database, Redis or the auth guards. Dox finds every class that extends it (with dox_builder) and runs it in every isolate.

class RedisProvider extends DoxProvider {
  late RedisConnection redis;

  @override
  Future<void> setup() async {
    redis = await RedisConnection.open();
  }

  @override
  Future<void> shutdown() async {
    await redis.close();
  }
}

Constructors

DoxProvider()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

boot() → FutureOr<void>
Runs once in every isolate after setup() of every provider is done, so the other providers are ready. Use it for work that needs them, eg. a background worker. Optional. The web server and the queue worker (bin/queue.dart) call it. The scheduler (bin/schedule.dart) and Dox().writeOpenApi() do not: they run only setup(), so no in-process queue worker starts there. The boots run one by one, in the provider order, and each is awaited. When one throws, the start fails with its error and the next ones do not run.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setup() → FutureOr<void>
Runs once in every isolate when the app starts, before the routes are registered.
shutdown() → FutureOr<void>
Runs once in every isolate when the server stops, eg. to close database or Redis connections. It runs after the open requests are done (on SIGTERM, SIGINT or Dox().stop()). Optional.
toString() → String
A string representation of this object.
inherited

Operators

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