MechanismService

core.services.preprocessor.MechanismService
class MechanismService[F[_]](cacheService: DistributedCacheService[F], client: Client[F], baseUri: Uri)(implicit evidence$1: Concurrent[F])

Service for managing mechanisms using both a distributed cache and remote HTTP service.

This service provides methods to fetch, create, and delete mechanisms. It interacts with a distributed cache for efficient data retrieval and synchronises with a remote service via HTTP for data persistence and updates.

Type parameters

F

The effect type (e.g., IO, SyncIO, etc.) that supports concurrency.

Value parameters

baseUri

The base URI of the remote mechanism service.

cacheService

The distributed cache service used for storing and retrieving mechanisms.

client

The HTTP client for making requests to the remote mechanism service.

Attributes

Source
MechanismService.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def createMechanism(mechanism: Mechanism): F[Mechanism]

Creates a new mechanism.

Creates a new mechanism.

This method sends a POST request to the remote mechanism service to create a new mechanism. The created mechanism is then added to the distributed cache.

Value parameters

mechanism

The mechanism to create.

Attributes

Returns

An effectful computation that yields the created Mechanism upon success.

Source
MechanismService.scala
def deleteMechanism(id: MechanismId): F[Either[MechanismError, Boolean]]

Deletes a mechanism by its ID.

Deletes a mechanism by its ID.

This method sends a DELETE request to the remote mechanism service. If the deletion is successful, the cache is updated to remove any stale data.

Value parameters

id

The unique identifier of the mechanism to delete.

Attributes

Returns

An effectful computation that yields:

  • Right(true) if the mechanism was successfully deleted.
  • Left(MechanismError) if an error occurred during deletion.
Source
MechanismService.scala

Fetches a mechanism by its ID.

Fetches a mechanism by its ID.

This method first checks the distributed cache for the requested mechanism. If the mechanism is not found in the cache, it fetches the data from the remote mechanism service and updates the cache.

Value parameters

id

The unique identifier of the mechanism to fetch.

Attributes

Returns

An effectful computation that yields the MechanismDetails for the given ID.

Source
MechanismService.scala