squadron_service library

Classes

BaseSquadronLogger
Base class for simple loggers
CancellationToken
Base cancellation token.
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).
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
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.
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 or WorkerRequest.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.

Functions

run(WorkerInitializer initializer, [Map? command]) → void
Instantiates a WorkerService via the initializer and installs the service in a platform worker. The command argument is ignored on Web platforms. On native platforms, the command 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.