SystemResources

app.units.SystemResources

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.

Attributes

Source
SystemResources.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def actorSystemResource(implicit ec: ExecutionContext, system: ActorSystem, logger: Logger[IO]): Resource[IO, ActorSystem]

Creates a managed resource for the ActorSystem.

Creates a managed resource for the ActorSystem.

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.

Source
SystemResources.scala