ServiceResources
Provides managed resources for initialising and managing services in the application.
This object encapsulates the lifecycle management of core services like MechanismService
, ReactionService
, ReaktoroService
, and various caching services. By using Resource
, it ensures that resources are properly initialised and cleaned up.
Attributes
- Source
- ServiceResources.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ServiceResources.type
Members list
Value members
Concrete methods
Creates a managed resource for the DistributedCacheService
.
Creates a managed resource for the DistributedCacheService
.
This method initialises a distributed cache backed by Akka Cluster. It ensures proper integration with the actor system and cluster configuration while managing the lifecycle and logging events.
Value parameters
- ex
-
An implicit
ExecutionContext
for asynchronous operations. - logger
-
An implicit logger instance for logging lifecycle events.
- selfUniqueAddress
-
The unique address of the current actor system instance, used for cluster data.
- system
-
The
ActorSystem
used for Akka-based concurrency and distributed data. - ttl
-
The time-to-live duration for cache entries.
Attributes
- Returns
-
A
Resource[IO, DistributedCacheService[IO]]
for the managed lifecycle of theDistributedCacheService
. - Source
- ServiceResources.scala
Creates a managed resource for the LocalCacheService
.
Creates a managed resource for the LocalCacheService
.
This method initialises a simple in-memory cache for local caching needs. The cache lifecycle is managed, and events are logged during creation and release.
Value parameters
- logger
-
An implicit logger instance for logging lifecycle events.
- ttl
-
The time-to-live duration for cache entries.
Attributes
- Returns
-
A
Resource[IO, LocalCacheService[IO]]
for the managed lifecycle of theLocalCacheService
. - Source
- ServiceResources.scala
Creates a managed resource for the MechanismService
.
Creates a managed resource for the MechanismService
.
The MechanismService
interacts with caching and HTTP APIs to manage mechanisms. This method ensures that the service is initialised and cleaned up correctly, with logging for lifecycle events.
Example usage:
val mechanismResource = ServiceResources.mechanismServiceResource(cacheService, httpClient, baseUri)
mechanismResource.use { mechanismService =>
// Use the mechanismService
}
Value parameters
- baseUri
-
The base URI for the mechanism service's API endpoints.
- cacheService
-
The distributed cache service used for storing and retrieving mechanisms.
- client
-
The HTTP client instance used for making API requests.
- logger
-
An implicit logger instance for logging lifecycle events.
Attributes
- Returns
-
A
Resource[IO, MechanismService[IO]]
for the managed lifecycle of theMechanismService
. - Source
- ServiceResources.scala
Creates a managed resource for the ReactionService
.
Creates a managed resource for the ReactionService
.
The ReactionService
handles caching and API interactions for reactions. This method manages its lifecycle, ensuring proper initialisation and cleanup with appropriate logging.
Value parameters
- baseUri
-
The base URI for the reaction service's API endpoints.
- cacheService
-
The distributed cache service used for storing and retrieving reactions.
- client
-
The HTTP client instance used for making API requests.
- logger
-
An implicit logger instance for logging lifecycle events.
Attributes
- Returns
-
A
Resource[IO, ReactionService[IO]]
for the managed lifecycle of theReactionService
. - Source
- ServiceResources.scala
Creates a managed resource for the ReaktoroService
.
Creates a managed resource for the ReaktoroService
.
The ReaktoroService
builds on the ReactionService
to provide extended functionality for managing reactions. This method ensures its lifecycle is properly managed, with detailed logging for creation and shutdown.
Value parameters
- baseUri
-
The base URI for the Reaktoro service's API endpoints.
- client
-
The HTTP client instance used for making API requests.
- logger
-
An implicit logger instance for logging lifecycle events.
- reactionService
-
The
ReactionService
used for providing dependencies to theReaktoroService
.
Attributes
- Returns
-
A
Resource[IO, ReaktoroService[IO]]
for the managed lifecycle of theReaktoroService
. - Source
- ServiceResources.scala