squadron library
Classes
- BaseSquadronLogger
- Base class for simple loggers
- CancellableToken
- CancellationToken
- Base cancellation token.
- Channel
- A Channel supports communication from a client to a platform worker. It is used to send a WorkerRequest to a platform worker.
- CompositeToken
- Composite cancellation token. The token is cancelled automatically depending on mode: with CompositeMode.any, the composite token is cancelled as soon as when one of the tokens is cancelled. With CompositeMode.any, the composite token is cancelled when all tokens are cancelled.
- ConcurrencySettings
- Concurrency settings governing parallelization of workers in a WorkerPool.
- ConsoleSquadronLogger
- DevSquadronLogger
- LocalSquadronLogger
- A SquadronLogger that also implements WorkerService. This logger wraps around a BaseSquadronLogger responsible for actually logging messages. The point of this logger is to use it as a LocalWorker via LocalSquadronLogger.worker so that workers can use a LocalSquadronLoggerClient.
- LocalSquadronLoggerClient
- A SquadronLogger bound to a LocalSquadronLogger. Workers using this logger can have their log messages sent to the LocalSquadronLogger. Usefull in Web scenarios where Web Workers typically log to the browser's JavaScript console (as opposed to the main app which also logs messages via Dart's debugger).
-
LocalWorker<
W extends WorkerService> - Base local worker class.
- LocalWorkerClient
- Base class used to communicate with a LocalWorker.
- PerfCounter
- Simple performance counter to consolidate statistics about woker tast execution: total number of calls, total number of errors, total elapsed time, and max elapsed time.
- PerfCounterSnapshot
- A snapshot of a PerfCounter's values.
- Squadron
- Squadron "Singleton". The main application thread and each worker thread will have their own private Squadron singleton.
- SquadronLogger
- Basic interface for logging
- SquadronLogLevel
-
Log level constants, compatible with
package:logging
-
StreamTask<
T> - Class representing a Task returning a stream of values.
-
Task<
T> - Base worker task class
- TimeOutToken
- Time-out cancellation tokens used by callers of worker services. The token is cancelled automatically after a period of time indicated by duration with a countdown starting only when the task is assigned to a platform worker.
-
ValueTask<
T> - Class representing a Task returning a single value.
- Worker
- Base worker class.
- WorkerChannel
- A WorkerChannel supports communication from a platform worker to the client that posted the WorkerRequest. It is used to send WorkerResponse back to the client.
-
WorkerPool<
W extends Worker> -
Worker pool responsible for instantiating, starting and stopping workers running in parallel.
A WorkerPool is also responsible for creating and assigning
WorkerTask
s to Workers. - WorkerRequest
-
Class used to communicate from a Channel to the Worker. Typically a WorkerRequest consists of a command ID
and a list of arguments. The command ID is used by the Worker to dispatch the WorkerRequest to the method
responsible for handling it. The WorkerRequest is effectively sent to the Worker by calling the
WorkerRequest.send
orWorkerRequest.stream
method. These methods will serialize the WorkerRequest as a Map to be transfered from the client to the worker and contains: - WorkerResponse
- Class used to communicate from a Worker to clients. WorkerResponses are used to provide individual results to the client. Future-based services simply return a single WorkerResponse with the result. Streaming services will return one WorkerResponses for each stream item and mmust send a WorkerResponse.endOfStream message to indicate completion. WorkerResponses can also send error messages.
- WorkerService
- Base class for a worker service.
- WorkerStat
- Base statistics for worker.
Enums
- CompositeMode
- Composite token cancellation mode
Functions
-
run(
WorkerInitializer initializer, [Map? command]) → void -
Instantiates a WorkerService via the
initializer
and installs the service in a platform worker. Thecommand
argument is ignored on Web platforms. On native platforms, thecommand
argument must be set to the Isolate's startup parameter.
Typedefs
- CommandHandler = FutureOr Function(WorkerRequest req)
Exceptions / Errors
- CancelledException
- Exception to keep track of task cancellation.
- SquadronError
- Squadron Error
- SquadronException
- Base abstract class for exceptions in Squadron.
- TaskTimeoutException
- Exception to keep track of task timeouts.
- WorkerException
- Exception to keep track of errors encountered in a worker.