Lifecycle

izumi.functional.lifecycle.Lifecycle
See theLifecycle companion trait
object Lifecycle

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Lifecycle.type

Members list

Type members

Classlikes

trait Basic[+F[_], A] extends Lifecycle[F, A]

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.

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() }
 }

Attributes

Supertypes
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
class ContainerResource[F, Tag]
class Resource[F]
class NetworkResource[F, T]
class Make[F, A]
class Make_[F, A]
class NoClose[F, A]
trait Simple[A]
Show all
open class FromAutoCloseable[+F[_], +A <: AutoCloseable](acquire: => F[A])(using evidence$1: QuasiIO[F]) extends Of[F, A]

Class-based variant of fromAutoCloseable:

Class-based variant of fromAutoCloseable:

 class FileOutputRes extends Lifecycle.FromAutoCloseable(
   acquire = IO(new FileOutputStream("abc"))
 )

For binding resources using class syntax in distage.ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Supertypes
class Of[F, A]
trait OfInner[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Show all
trait FromCats[F[_], A] extends Lifecycle[F, A]

Attributes

Supertypes
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
trait FromPair[F[_], A] extends Lifecycle[F, A]

Attributes

Supertypes
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
class MakePair[F, A]
object FromZIO

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
FromZIO.type
trait FromZIO[R, E, A] extends Lifecycle[[_] =>> ZIO[R, E, _$76], A]

Attributes

Companion
object
Supertypes
trait Lifecycle[[_] =>> ZIO[R, E, _$76], A]
class Object
trait Matchable
class Any
Known subtypes
trait FromZIOManaged[R, E, A]
trait FromZIOScoped[R, E, A]
open class LiftF[+F[_], A] extends NoCloseBase[F, A]

Class-based variant of liftF:

Class-based variant of liftF:

 class IntRes extends Lifecycle.LiftF(acquire = IO(1000))

For binding resources using class syntax in distage.ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Note

acquire is performed interruptibly, unlike in Make

Supertypes
class NoCloseBase[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
open class Make[+F[_], A] extends Basic[F, A]

Class-based variant of make:

Class-based variant of make:

 class IntRes extends Lifecycle.Make(
   acquire = IO(1000)
 )(release = _ => IO.unit)

For binding resources using class syntax in distage.ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Supertypes
trait Basic[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
class Make_[F, A]
open class MakePair[F[_], A] extends FromPair[F, A]

Class-based variant of makePair:

Class-based variant of makePair:

 class IntRes extends Lifecycle.MakePair(IO(1000 -> IO.unit))

For binding resources using class syntax in distage.ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Supertypes
trait FromPair[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
open class Make_[+F[_], A](acquire: => F[A])(release: => F[Unit]) extends Make[F, A]

Class-based variant of make_:

Class-based variant of make_:

 class IntRes extends Lifecycle.Make_(IO(1000))(IO.unit)

For binding resources using class syntax in distage.ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Supertypes
class Make[F, A]
trait Basic[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Show all
trait Mutable[+A] extends Self[Identity, A]

Attributes

Supertypes
trait Self[Identity, A]
trait Lifecycle[Identity, A]
class Object
trait Matchable
class Any
Self type
A
trait MutableNoClose[+A] extends SelfNoClose[Identity, A]

Attributes

Supertypes
class SelfNoClose[Identity, A]
class NoCloseBase[Identity, A]
trait Lifecycle[Identity, A]
class Object
trait Matchable
class Any
Show all
Self type
A
trait MutableOf[+A] extends SelfOf[Identity, A]

Attributes

Supertypes
trait SelfOf[Identity, A]
trait Lifecycle[Identity, A]
class Object
trait Matchable
class Any
Self type
A
abstract class NoClose[+F[_], A] extends NoCloseBase[F, A], Basic[F, A]

Attributes

Supertypes
trait Basic[F, A]
class NoCloseBase[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Show all
abstract class NoCloseBase[+F[_], +A] extends Lifecycle[F, A]

Attributes

Supertypes
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
class LiftF[F, A]
class NoClose[F, A]
class SelfNoClose[F, A]
trait MutableNoClose[A]
open class Of[+F[_], +A] extends OfInner[F, A]

Class-based proxy over a Lifecycle value

Class-based proxy over a Lifecycle value

 class IntRes extends Lifecycle.Of(Lifecycle.pure(1000))

For binding resource values using class syntax in distage.ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Note

when the expression passed to Lifecycle.Of defines many local methods it can hit a Scalac bug https://github.com/scala/bug/issues/11969 and fail to compile, in that case you may switch to Lifecycle.OfInner

Supertypes
trait OfInner[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
class FromAutoCloseable[F, A]
class OfCats[F, A]
class OfZIO[R, E, A]
class OfZLayer[R, E, A]
class OfZManaged[R, E, A]
open class OfCats[F[_], A](inner: => Resource[F, A])(using evidence$1: Sync[F]) extends Of[F, A]

Class-based proxy over a cats.effect.Resource value

Class-based proxy over a cats.effect.Resource value

 class IntRes extends Lifecycle.OfCats(Resource.pure(1000))

For binding resource values using class syntax in distage.ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Supertypes
class Of[F, A]
trait OfInner[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Show all
trait OfInner[+F[_], +A] extends Lifecycle[F, A]

Trait-based proxy over a Lifecycle value

Trait-based proxy over a Lifecycle value

 class IntRes extends Lifecycle.OfInner[IO, Int] {
   override val lifecycle: Lifecycle[IO, Int] = Lifecycle.pure(1000)
 }

For binding resource values using class syntax in distage.ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Note

This class may be used instead of Lifecycle.Of to workaround scalac bug https://github.com/scala/bug/issues/11969 when defining local methods

Supertypes
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
class Of[F, A]
class FromAutoCloseable[F, A]
class OfCats[F, A]
class OfZIO[R, E, A]
class OfZLayer[R, E, A]
class OfZManaged[R, E, A]
Show all
open class OfZIO[-R, +E, +A](inner: => ZIO[Scope & R, E, A]) extends Of[[_] =>> ZIO[R, E, _$60], A]

Class-based proxy over a scoped zio.ZIO value

Class-based proxy over a scoped zio.ZIO value

 class IntRes extends Lifecycle.OfZIO(ZIO.acquireRelease(ZIO.succeed(1000))(_ => ZIO.unit))

For binding resource values using class syntax in ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Supertypes
class Of[[_] =>> ZIO[R, E, _$60], A]
trait OfInner[[_] =>> ZIO[R, E, _$60], A]
trait Lifecycle[[_] =>> ZIO[R, E, _$60], A]
class Object
trait Matchable
class Any
Show all
open class OfZLayer[-R, +E, +A](inner: => ZLayer[R, E, A])(using evidence$1: Tag[A]) extends Of[[_] =>> ZIO[R, E, _$62], A]

Class-based proxy over a zio.ZLayer value

Class-based proxy over a zio.ZLayer value

 class IntRes extends Lifecycle.OfZLayer(ZLayer.succeed(1000))

For binding resource values using class syntax in ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Supertypes
class Of[[_] =>> ZIO[R, E, _$62], A]
trait OfInner[[_] =>> ZIO[R, E, _$62], A]
trait Lifecycle[[_] =>> ZIO[R, E, _$62], A]
class Object
trait Matchable
class Any
Show all
open class OfZManaged[-R, +E, +A](inner: => ZManaged[R, E, A]) extends Of[[_] =>> ZIO[R, E, _$61], A]

Class-based proxy over a zio.managed.ZManaged value

Class-based proxy over a zio.managed.ZManaged value

 class IntRes extends Lifecycle.OfZManaged(ZManaged.succeed(1000))

For binding resource values using class syntax in ModuleDef:

 val module = new ModuleDef {
   make[Int].fromResource[IntRes]
 }

Attributes

Supertypes
class Of[[_] =>> ZIO[R, E, _$61], A]
trait OfInner[[_] =>> ZIO[R, E, _$61], A]
trait Lifecycle[[_] =>> ZIO[R, E, _$61], A]
class Object
trait Matchable
class Any
Show all
trait Self[+F[_], +A] extends Lifecycle[F, A]

Attributes

Supertypes
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
trait Mutable[A]
Self type
A
abstract class SelfNoClose[+F[_], +A] extends NoCloseBase[F, A]

Attributes

Supertypes
class NoCloseBase[F, A]
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
trait MutableNoClose[A]
Self type
A
trait SelfOf[+F[_], +A] extends Lifecycle[F, A]

Attributes

Supertypes
trait Lifecycle[F, A]
class Object
trait Matchable
class Any
Known subtypes
trait MutableOf[A]
Self type
A
trait Simple[A] extends Basic[Identity, A]

Attributes

Supertypes
trait Basic[Identity, A]
trait Lifecycle[Identity, A]
class Object
trait Matchable
class Any
final implicit class SyntaxLifecycleCats[+F[_], +A](resource: Lifecycle[F, A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final class SyntaxLifecycleFromZIO[R](dummy: Boolean = ...) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxLifecycleIdentity[+A](resource: Lifecycle[Identity, A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxLifecycleZIO[-R, +E, +A](resource: Lifecycle[[_] =>> ZIO[R, E, _$54], A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxLifecycleZManaged[-R, +E, +A](resource: Lifecycle[[_] =>> ZIO[R, E, _$56], A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxPure[F[_]](dummy: Boolean = ...) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxUnsafeGet[F[_], A](resource: Lifecycle[F, A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxUse[+F[_], +A](resource: Lifecycle[F, A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxUseEffect[F[_], A](resource: Lifecycle[F, F[A]]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxUseIdentity[+A](resource: Lifecycle[Identity, A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
final implicit class SyntaxWidenError[F[_, _], +E, +A](resource: Lifecycle[[_] =>> F[E, _$45], A]) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any

Value members

Concrete methods

def fail[F[_], A](error: => Throwable)(implicit F: QuasiIO[F]): Lifecycle[F, A]
def fork[F[_, _] : Fork2, E, A](f: F[E, A]): Lifecycle[[_] =>> F[Nothing, _$21], Fiber2[F, E, A]]

Fork the specified action into a new fiber. When this Lifecycle is released, the fiber will be interrupted using izumi.functional.bio.Fiber2#interrupt

Fork the specified action into a new fiber. When this Lifecycle is released, the fiber will be interrupted using izumi.functional.bio.Fiber2#interrupt

Attributes

Returns

The fiber running f action

def forkCats[F[_], E, A](f: F[A])(implicit F: GenConcurrent[F, E]): Lifecycle[F, Fiber[F, E, A]]

Fork the specified action into a new fiber. When this Lifecycle is released, the fiber will be interrupted using cats.effect.Fiber#cancel

Fork the specified action into a new fiber. When this Lifecycle is released, the fiber will be interrupted using cats.effect.Fiber#cancel

Attributes

Returns

The fiber running f action

def fork_[F[_, _] : Fork2 : Functor2, E, A](f: F[E, A]): Lifecycle[[_] =>> F[Nothing, _$25], Unit]

Attributes

See also
def fromAutoCloseable[F[_], A <: AutoCloseable](acquire: => F[A])(implicit F: QuasiIO[F]): Lifecycle[F, A]
def fromAutoCloseable[A <: AutoCloseable](acquire: => A): Lifecycle[Identity, A]
def fromCats[F[_], A](resource: Resource[F, A])(implicit F: Sync[F]): FromCats[F, A]

Convert cats.effect.Resource to Lifecycle

Convert cats.effect.Resource to Lifecycle

Attributes

def fromExecutorService[F[_], A <: ExecutorService](acquire: => F[A])(implicit F: QuasiIO[F]): Lifecycle[F, A]
def fromExecutorService[A <: ExecutorService](acquire: => A): Lifecycle[Identity, A]

Convert a Scoped zio.ZIO to Lifecycle

Convert a Scoped zio.ZIO to Lifecycle

  def fromZIO[R, E, A](f: ZIO[Scope with R, E, A]): Lifecycle.FromZIO[R, E, A]

Attributes

def fromZLayer[R, E, A : Tag](layer: ZLayer[R, E, A]): FromZIO[R, E, A]

Convert zio.ZLayer to Lifecycle

Convert zio.ZLayer to Lifecycle

Attributes

def fromZLayerZEnv[R, E, A](layer: ZLayer[R, E, A]): FromZIO[R, E, ZEnvironment[A]]

Convert zio.ZLayer to Lifecycle

Convert zio.ZLayer to Lifecycle

Attributes

def fromZManaged[R, E, A](managed: ZManaged[R, E, A]): FromZIO[R, E, A]

Convert zio.managed.ZManaged to Lifecycle

Convert zio.managed.ZManaged to Lifecycle

Attributes

def liftF[F[_], A](effect: => F[A])(implicit F: QuasiApplicative[F]): Lifecycle[F, A]

Value parameters

effect

is performed interruptibly, unlike in make

Attributes

def make[F[_], A](acquire: => F[A])(release: A => F[Unit]): Lifecycle[F, A]
def makePair[F[_], A](allocate: F[(A, F[Unit])]): Lifecycle[F, A]
def makeSimple[A](acquire: => A)(release: A => Unit): Lifecycle[Identity, A]
def makeSimpleInit[A](create: => A)(init: A => Unit)(release: A => Unit): Lifecycle[Identity, A]

For stateful objects that have a separate post-creation init method.

For stateful objects that have a separate post-creation init method.

Attributes

def makeUninterruptibleExcept[F[_], A](acquire: RestoreInterruption1[F] => F[A])(release: A => F[Unit])(implicit F: QuasiPrimitives[F]): Lifecycle[F, A]
def make_[F[_], A](acquire: => F[A])(release: => F[Unit]): Lifecycle[F, A]
def pure[F[_]]: SyntaxPure[F]
def suspend[F[_] : QuasiPrimitives, A](effect: => F[Lifecycle[F, A]]): Lifecycle[F, A]

Value parameters

effect

is performed interruptibly, unlike in make

Attributes

def traverse[F[_] : QuasiPrimitives, A, B](l: Iterable[A])(f: A => Lifecycle[F, B]): Lifecycle[F, List[B]]
def traverse_[F[_] : QuasiPrimitives, A](l: Iterable[A])(f: A => Lifecycle[F, Unit]): Lifecycle[F, Unit]
def unit[F[_]](implicit F: QuasiApplicative[F]): Lifecycle[F, Unit]

Implicits

Implicits

final implicit def SyntaxLifecycleCats[F[_], A](resource: Lifecycle[F, A]): SyntaxLifecycleCats[F, A]
final implicit def SyntaxLifecycleIdentity[A](resource: Lifecycle[Identity, A]): SyntaxLifecycleIdentity[A]
final implicit def SyntaxLifecycleZIO[R, E, A](resource: Lifecycle[[_] =>> ZIO[R, E, _$54], A]): SyntaxLifecycleZIO[R, E, A]
final implicit def SyntaxLifecycleZManaged[R, E, A](resource: Lifecycle[[_] =>> ZIO[R, E, _$56], A]): SyntaxLifecycleZManaged[R, E, A]
final implicit def SyntaxPure[F[_]](dummy: Boolean = ...): SyntaxPure[F]
final implicit def SyntaxUnsafeGet[F[_], A](resource: Lifecycle[F, A]): SyntaxUnsafeGet[F, A]
final implicit def SyntaxUse[F[_], A](resource: Lifecycle[F, A]): SyntaxUse[F, A]
final implicit def SyntaxUseEffect[F[_], A](resource: Lifecycle[F, F[A]]): SyntaxUseEffect[F, A]
final implicit def SyntaxUseIdentity[A](resource: Lifecycle[Identity, A]): SyntaxUseIdentity[A]
final implicit def SyntaxWidenError[F[_, _], E, A](resource: Lifecycle[[_] =>> F[E, _$45], A]): SyntaxWidenError[F, E, A]

Inherited implicits

final implicit def catsFunctorForLifecycle[F[_], Functor[_[_]]](implicit evidence$1: cats.Functor[Functor], F: QuasiFunctor[F]): Functor[[_] =>> Lifecycle[F, _$101]]

Attributes

Inherited from:
LifecycleCatsInstancesLowPriority (hidden)
final implicit def catsMonadForLifecycle[Monad[_[_]], F[_]](implicit evidence$1: cats.Monad[Monad], P: QuasiPrimitives[F]): Monad[[_] =>> Lifecycle[F, _$93]]

Attributes

Inherited from:
LifecycleCatsInstances (hidden)
final implicit def catsMonoidForLifecycle[Monoid[_], F[_], A](implicit evidence$1: cats.kernel.Monoid[Monoid], F: QuasiPrimitives[F], A0: Monoid[A]): Monoid[Lifecycle[F, A]]

Attributes

Inherited from:
LifecycleCatsInstances (hidden)
final implicit def monad2ForLifecycle[F[_, _]](implicit evidence$1: Functor2[F], P: QuasiPrimitives[[_] =>> F[Any, _$80]]): Monad2[[_, _] =>> Lifecycle2[F, _$81, _$82]]

Attributes

Inherited from:
LifecycleInstances (hidden)