Provides managed resources for system-level components.
This object encapsulates the lifecycle management of system-level components like the ActorSystem, ensuring proper initialisation and termination using the Resource abstraction.
This method manages the lifecycle of an ActorSystem instance, ensuring it is properly initialised and terminated. Lifecycle events, including creation and termination, are logged for observability. Any errors during termination are captured and logged.
Example usage:
implicit val system: ActorSystem = ActorSystem("my-system")
implicit val logger: Logger[IO] = Slf4jLogger.getLogger[IO]
implicit val ec: ExecutionContext = system.dispatcher
val systemResource = SystemResources.actorSystemResource
systemResource.use { actorSystem =>
// Use the actor system
}
Value parameters
ec
The ExecutionContext to be used by the ActorSystem.
logger
An implicit logger instance for logging lifecycle events.
system
The ActorSystem instance to be managed.
Attributes
Returns
A Resource[IO, ActorSystem] that ensures proper initialisation and termination of the ActorSystem.