ZLayer

sealed abstract class ZLayer[-RIn, +E, +ROut]

A ZLayer[A, E, B] describes a layer of an application: every layer in an application requires some services (the input) and produces some services (the output).

Layers can be thought of as recipes for producing bundles of services, given their dependencies (other services).

Construction of layers can be effectful and utilize resources that must be acquired and safely released when the services are done being utilized.

By default layers are shared, meaning that if the same layer is used twice the layer will only be allocated a single time.

Because of their excellent composition properties, layers are the idiomatic way in ZIO to create services that depend on other services.

Companion:
object
class Object
trait Matchable
class Any
ZLayer[RIn, E, ROut]

Value members

Concrete methods

final def !(implicit ev1: E <:< Throwable, ev2: CanFail[E]): ZLayer[RIn, Nothing, ROut]

A symbolic alias for orDie.

A symbolic alias for orDie.

final def +!+[E1 >: E, RIn2, ROut1 >: ROut, ROut2](that: ZLayer[RIn2, E1, ROut2])(implicit ev: UnionAll[ROut1, ROut2]): ZLayer[RIn & RIn2, E1, ROut1 & ROut2]
final def ++[E1 >: E, RIn2, ROut1 >: ROut, ROut2](that: ZLayer[RIn2, E1, ROut2])(implicit ev: Union[ROut1, ROut2], tag: Tag[ROut2]): ZLayer[RIn & RIn2, E1, ROut1 & ROut2]

Combines this layer with the specified layer, producing a new layer that has the inputs of both layers, and the outputs of both layers.

Combines this layer with the specified layer, producing a new layer that has the inputs of both layers, and the outputs of both layers.

final def <&>[E1 >: E, RIn2, ROut2](that: ZLayer[RIn2, E1, ROut2]): ZLayer[RIn & RIn2, E1, (ROut, ROut2)]

A symbolic alias for zipPar.

A symbolic alias for zipPar.

def <>[RIn1 <: RIn, E1, ROut1 >: ROut](that: ZLayer[RIn1, E1, ROut1])(implicit ev: CanFail[E]): ZLayer[RIn1, E1, ROut1]

A symbolic alias for orElse.

A symbolic alias for orElse.

final def >+>[E1 >: E, RIn2 >: ROut, ROut1 >: ROut, ROut2](that: ZLayer[RIn2, E1, ROut2])(implicit ev: Union[ROut1, ROut2], tagged: Tag[ROut2]): ZLayer[RIn, E1, ROut1 & ROut2]

Feeds the output services of this layer into the input of the specified layer, resulting in a new layer with the inputs of this layer, and the outputs of both this layer and the specified layer.

Feeds the output services of this layer into the input of the specified layer, resulting in a new layer with the inputs of this layer, and the outputs of both this layer and the specified layer.

final def >>>[E1 >: E, ROut2](that: ZLayer[ROut, E1, ROut2]): ZLayer[RIn, E1, ROut2]

Feeds the output services of this layer into the input of the specified layer, resulting in a new layer with the inputs of this layer, and the outputs of the specified layer.

Feeds the output services of this layer into the input of the specified layer, resulting in a new layer with the inputs of this layer, and the outputs of the specified layer.

final def and[E1 >: E, RIn2, ROut1 >: ROut, ROut2](that: ZLayer[RIn2, E1, ROut2])(implicit ev: Union[ROut1, ROut2], tagged: Tag[ROut2]): ZLayer[RIn & RIn2, E1, ROut1 & ROut2]

A named alias for ++.

A named alias for ++.

final def andTo[E1 >: E, RIn2 >: ROut, ROut1 >: ROut, ROut2](that: ZLayer[RIn2, E1, ROut2])(implicit ev: Union[ROut1, ROut2], tagged: Tag[ROut2]): ZLayer[RIn, E1, ROut1 & ROut2]

A named alias for >+>.

A named alias for >+>.

final def build: ZManaged[RIn, E, ROut]

Builds a layer into a managed value.

Builds a layer into a managed value.

final def catchAll[RIn1 <: RIn, E1, ROut1 >: ROut](handler: ZLayer[(RIn1, E), E1, ROut1]): ZLayer[RIn1, E1, ROut1]

Recovers from all errors.

Recovers from all errors.

final def flatMap[RIn1 <: RIn, E1 >: E, ROut2](f: ROut => ZLayer[RIn1, E1, ROut2]): ZLayer[RIn1, E1, ROut2]

Constructs a layer dynamically based on the output of this layer.

Constructs a layer dynamically based on the output of this layer.

final def fold[E1, RIn1 <: RIn, ROut2](failure: ZLayer[(RIn1, Cause[E]), E1, ROut2], success: ZLayer[ROut, E1, ROut2])(implicit ev: CanFail[E]): ZLayer[RIn1, E1, ROut2]

Feeds the error or output services of this layer into the input of either the specified failure or success layers, resulting in a new layer with the inputs of this layer, and the error or outputs of the specified layer.

Feeds the error or output services of this layer into the input of either the specified failure or success layers, resulting in a new layer with the inputs of this layer, and the error or outputs of the specified layer.

final def fresh: ZLayer[RIn, E, ROut]

Creates a fresh version of this layer that will not be shared.

Creates a fresh version of this layer that will not be shared.

final def launch(implicit ev: Any <:< RIn): IO[E, Nothing]

Builds this layer and uses it until it is interrupted. This is useful when your entire application is a layer, such as an HTTP server.

Builds this layer and uses it until it is interrupted. This is useful when your entire application is a layer, such as an HTTP server.

final def map[ROut1](f: ROut => ROut1): ZLayer[RIn, E, ROut1]

Returns a new layer whose output is mapped by the specified function.

Returns a new layer whose output is mapped by the specified function.

final def mapError[E1](f: E => E1)(implicit ev: CanFail[E]): ZLayer[RIn, E1, ROut]

Returns a layer with its error channel mapped using the specified function.

Returns a layer with its error channel mapped using the specified function.

final def memoize: ZManaged[Any, Nothing, ZLayer[RIn, E, ROut]]

Returns a managed effect that, if evaluated, will return the lazily computed result of this layer.

Returns a managed effect that, if evaluated, will return the lazily computed result of this layer.

final def orDie(implicit ev1: E <:< Throwable, ev2: CanFail[E]): ZLayer[RIn, Nothing, ROut]

Translates effect failure into death of the fiber, making all failures unchecked and not a part of the type of the layer.

Translates effect failure into death of the fiber, making all failures unchecked and not a part of the type of the layer.

final def orElse[RIn1 <: RIn, E1, ROut1 >: ROut](that: ZLayer[RIn1, E1, ROut1])(implicit ev: CanFail[E]): ZLayer[RIn1, E1, ROut1]

Executes this layer and returns its output, if it succeeds, but otherwise executes the specified layer.

Executes this layer and returns its output, if it succeeds, but otherwise executes the specified layer.

def passthrough(implicit ev: Union[RIn, ROut], tag: Tag[ROut]): ZLayer[RIn, E, RIn & ROut]
Implicitly added by ZLayerPassthroughOps

Returns a new layer that produces the outputs of this layer but also passes through the inputs to this layer.

Returns a new layer that produces the outputs of this layer but also passes through the inputs to this layer.

final def project[B : Tag](f: A => B)(implicit evidence$1593: Tag[B], tag: Tag[A]): ZLayer[R, E, Has[B]]
Implicitly added by ZLayerProjectOps

Projects out part of one of the layers output by this layer using the specified function

Projects out part of one of the layers output by this layer using the specified function

final def retry[RIn1 <: RIn & Clock](schedule: Schedule[RIn1, E, Any]): ZLayer[RIn1, E, ROut]

Retries constructing this layer according to the specified schedule.

Retries constructing this layer according to the specified schedule.

final def tap[RIn1 <: RIn, E1 >: E](f: ROut => ZIO[RIn1, E1, Any]): ZLayer[RIn1, E1, ROut]

Performs the specified effect if this layer succeeds.

Performs the specified effect if this layer succeeds.

final def tapError[RIn1 <: RIn, E1 >: E](f: E => ZIO[RIn1, E1, Any]): ZLayer[RIn1, E1, ROut]

Performs the specified effect if this layer fails.

Performs the specified effect if this layer fails.

final def to[E1 >: E, ROut2](that: ZLayer[ROut, E1, ROut2]): ZLayer[RIn, E1, ROut2]

A named alias for >>>.

A named alias for >>>.

final def toRuntime(p: Platform)(implicit ev: Any <:< RIn): Managed[E, Runtime[ROut]]

Converts a layer that requires no services into a managed runtime, which can be used to execute effects.

Converts a layer that requires no services into a managed runtime, which can be used to execute effects.

final def update[A : Tag](f: A => A)(implicit evidence$1: Tag[A], ev1: IsHas[ROut], ev2: ROut <:< Has[A]): ZLayer[RIn, E, ROut]

Updates one of the services output by this layer.

Updates one of the services output by this layer.

final def zipPar[E1 >: E, RIn2, ROut2](that: ZLayer[RIn2, E1, ROut2]): ZLayer[RIn & RIn2, E1, (ROut, ROut2)]

Combines this layer with the specified layer, producing a new layer that has the inputs of both layers, and the outputs of both layers combined into a tuple.

Combines this layer with the specified layer, producing a new layer that has the inputs of both layers, and the outputs of both layers combined into a tuple.

final def zipWithPar[E1 >: E, RIn2, ROut1 >: ROut, ROut2, ROut3](that: ZLayer[RIn2, E1, ROut2])(f: (ROut, ROut2) => ROut3): ZLayer[RIn & RIn2, E1, ROut3]

Combines this layer with the specified layer, producing a new layer that has the inputs of both layers, and the outputs of both layers combined using the specified function.

Combines this layer with the specified layer, producing a new layer that has the inputs of both layers, and the outputs of both layers combined using the specified function.

Concrete fields

final lazy override val hashCode: Int

Returns the hash code of this layer.

Returns the hash code of this layer.