A sub-trait of izumi.distage.model.definition.Lifecycle suitable for less-complex resource definitions via inheritance
that do not require overriding izumi.distage.model.definition.Lifecycle#InnerResource.
final class BufferedReaderResource(
file: File
) extends Lifecycle.Basic[IO, BufferedReader] {
def acquire: IO[BufferedReader] = IO { new BufferedReader(new FileReader(file)) }
def release(reader: BufferedReader): IO[BufferedReader] = IO { reader.close() }
}
The action in F used to release, close or deallocate the resource
after it has been acquired and used through izumi.distage.model.definition.Lifecycle.SyntaxUse#use.
The action in F used to release, close or deallocate the resource
after it has been acquired and used through izumi.distage.model.definition.Lifecycle.SyntaxUse#use.
Attributes
Note:
the release action is performed uninterruptibly,
when F is an effect type that supports interruption/cancellation.
Concrete methods
final override def extract[B >: A](resource: A): Right[Nothing, A]
Either an action in F or a pure function used to
extract the A from the InnerResource
Either an action in F or a pure function used to
extract the A from the InnerResource
The effect in the Left branch will be performed interruptibly,
it is not afforded the same kind of safety as acquire and release actions
when F is an effect type that supports interruption/cancellation.
When F is Identity, it doesn't matter whether the output is a Left or Right branch.
When consuming the output of extract you can use _.fold(identity, F.pure) to convert the Either to F[B]
Attributes
See also:
Lifecycle.Basicextract doesn't have to be defined when inheriting from Lifecycle.Basic