ServiceResources

app.units.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 Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def distributedCacheServiceResource(system: ActorSystem, selfUniqueAddress: SelfUniqueAddress)(implicit ex: ExecutionContext, distributedTtl: Timeout, localTtlWithUnit: (Int, TimeUnit), logger: Logger[IO]): Resource[IO, DistributedCacheService[IO]]

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 the DistributedCacheService.

Source
ServiceResources.scala
def localCacheServiceResource(implicit ttl: FiniteDuration, logger: Logger[IO]): Resource[IO, LocalCacheService[IO]]

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 the LocalCacheService.

Source
ServiceResources.scala
def mechanismServiceResource(cacheService: DistributedCacheService[IO], client: Client[IO], baseUri: Uri)(implicit logger: Logger[IO]): Resource[IO, MechanismService[IO]]

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 the MechanismService.

Source
ServiceResources.scala
def reactionServiceResource(cacheService: DistributedCacheService[IO], client: Client[IO], baseUri: Uri)(implicit logger: Logger[IO]): Resource[IO, ReactionService[IO]]

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 the ReactionService.

Source
ServiceResources.scala
def reaktoroServiceResource(reactionService: ReactionService[IO], client: Client[IO], baseUri: Uri)(implicit logger: Logger[IO]): Resource[IO, ReaktoroService[IO]]

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 the ReaktoroService.

Attributes

Returns

A Resource[IO, ReaktoroService[IO]] for the managed lifecycle of the ReaktoroService.

Source
ServiceResources.scala