sealed abstract class ZManaged[-R, +E, +A] extends ZManagedVersionSpecific[R, E, A] with Serializable
A ZManaged[R, E, A] is a managed resource of type A, which may be used by
invoking the use method of the resource. The resource will be automatically
acquired before the resource is used, and automatically released after the
resource is used.
Resources do not survive the scope of use, meaning that if you attempt to
capture the resource, leak it from use, and then use it after the resource
has been consumed, the resource will not be valid anymore and may fail with
some checked error, as per the type of the functions provided by the resource.
- Self Type
- ZManaged[R, E, A]
- Alphabetic
- By Inheritance
- ZManaged
- Serializable
- ZManagedVersionSpecific
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def zio: ZIO[(R, ReleaseMap), E, (Finalizer, A)]
The ZIO value that underlies this ZManaged value.
The ZIO value that underlies this ZManaged value. To evaluate it, a ReleaseMap is required. The ZIO value will return a tuple of the resource allocated by this ZManaged and a finalizer that will release the resource.
Note that this method is a low-level interface, not intended for regular usage. As such, it offers no guarantees on interruption or resource safety - those are up to the caller to enforce!
Concrete Value Members
- final def !(implicit ev1: <:<[E, Throwable], ev2: CanFail[E]): ZManaged[R, Nothing, A]
A symbolic alias for
orDie. - final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def &>[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A1]
Symbolic alias for zipParRight
- def *>[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A1]
Symbolic alias for zipRight
- def <&[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A]
Symbolic alias for zipParLeft
- def <&>[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1])(implicit zippable: Zippable[A, A1]): ZManaged[R1, E1, Out]
Symbolic alias for zipPar
- def <*[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A]
Symbolic alias for zipLeft.
- def <*>[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1])(implicit zippable: Zippable[A, A1]): ZManaged[R1, E1, Out]
Symbolic alias for zip.
- def <>[R1 <: R, E2, A1 >: A](that: => ZManaged[R1, E2, A1])(implicit ev: CanFail[E]): ZManaged[R1, E2, A1]
Operator alias for
orElse. - final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def @@[LowerR <: UpperR, UpperR <: R, LowerE >: E, UpperE >: LowerE, LowerA >: A, UpperA >: LowerA](aspect: => ZManagedAspect[LowerR, UpperR, LowerE, UpperE, LowerA, UpperA]): ZManaged[UpperR, LowerE, LowerA]
Syntax for adding aspects.
- def absolve[E1 >: E, B](implicit ev: IsSubtypeOfOutput[A, Either[E1, B]]): ZManaged[R, E1, B]
Submerges the error case of an
Eitherinto theZManaged.Submerges the error case of an
Eitherinto theZManaged. The inverse operation ofZManaged.either. - def absorb(implicit ev: IsSubtypeOfError[E, Throwable]): ZManaged[R, Throwable, A]
Attempts to convert defects into a failure, throwing away all information about the cause of the failure.
- def absorbWith(f: (E) => Throwable): ZManaged[R, Throwable, A]
Attempts to convert defects into a failure, throwing away all information about the cause of the failure.
- def as[B](b: => B): ZManaged[R, E, B]
Maps this effect to the specified constant while preserving the effects of this effect.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def asSome: ZManaged[R, E, Option[A]]
Maps the success value of this effect to an optional value.
- final def asSomeError: ZManaged[R, Option[E], A]
Maps the error value of this effect to an optional value.
- def catchAll[R1 <: R, E2, A1 >: A](h: (E) => ZManaged[R1, E2, A1])(implicit ev: CanFail[E]): ZManaged[R1, E2, A1]
Recovers from all errors.
- def catchAllCause[R1 <: R, E2, A1 >: A](h: (Cause[E]) => ZManaged[R1, E2, A1]): ZManaged[R1, E2, A1]
Recovers from all errors with provided Cause.
Recovers from all errors with provided Cause.
managed.catchAllCause(_ => ZManaged.succeed(defaultConfig))- See also
absorb, sandbox, mapErrorCause - other functions that can recover from defects
- def catchSome[R1 <: R, E1 >: E, A1 >: A](pf: PartialFunction[E, ZManaged[R1, E1, A1]])(implicit ev: CanFail[E]): ZManaged[R1, E1, A1]
Recovers from some or all of the error cases.
- def catchSomeCause[R1 <: R, E1 >: E, A1 >: A](pf: PartialFunction[Cause[E], ZManaged[R1, E1, A1]]): ZManaged[R1, E1, A1]
Recovers from some or all of the error Causes.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collect[E1 >: E, B](e: => E1)(pf: PartialFunction[A, B]): ZManaged[R, E1, B]
Fail with
eif the suppliedPartialFunctiondoes not match, otherwise succeed with the returned value. - def collectManaged[R1 <: R, E1 >: E, B](e: => E1)(pf: PartialFunction[A, ZManaged[R1, E1, B]]): ZManaged[R1, E1, B]
Fail with
eif the suppliedPartialFunctiondoes not match, otherwise continue with the returned value. - def either(implicit ev: CanFail[E]): ZManaged[R, Nothing, Either[E, A]]
Returns an effect whose failure and success have been lifted into an
Either.The resulting effect cannot fail - def ensuring[R1 <: R](f: => ZIO[R1, Nothing, Any]): ZManaged[R1, E, A]
Ensures that
fis executed when this ZManaged is finalized, after the existing finalizer.Ensures that
fis executed when this ZManaged is finalized, after the existing finalizer.For usecases that need access to the ZManaged's result, see ZManaged#onExit.
- def ensuringFirst[R1 <: R](f: => ZIO[R1, Nothing, Any]): ZManaged[R1, E, A]
Ensures that
fis executed when this ZManaged is finalized, before the existing finalizer.Ensures that
fis executed when this ZManaged is finalized, before the existing finalizer.For usecases that need access to the ZManaged's result, see ZManaged#onExitFirst.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def eventually(implicit ev: CanFail[E]): ZManaged[R, Nothing, A]
Returns a ZManaged that ignores errors raised by the acquire effect and runs it repeatedly until it eventually succeeds.
- def exit: ZManaged[R, Nothing, Exit[E, A]]
Returns an effect that semantically runs the effect on a fiber, producing an zio.Exit for the completion value of the fiber.
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def firstSuccessOf[R1 <: R, E1 >: E, A1 >: A](rest: => Iterable[ZManaged[R1, E1, A1]]): ZManaged[R1, E1, A1]
Returns a managed resource that attempts to acquire this managed resource and in case of failure, attempts to acquire each of the specified managed resources in order until one of them is successfully acquired, ensuring that the acquired resource is properly released after being used.
- def flatMap[R1 <: R, E1 >: E, B](f: (A) => ZManaged[R1, E1, B]): ZManaged[R1, E1, B]
Returns an effect that models the execution of this effect, followed by the passing of its value to the specified continuation function
k, followed by the effect that it returns. - def flatMapError[R1 <: R, E2](f: (E) => ZManaged[R1, Nothing, E2])(implicit ev: CanFail[E]): ZManaged[R1, E2, A]
Effectfully map the error channel
- def flatten[R1 <: R, E1 >: E, B](implicit ev: IsSubtypeOfOutput[A, ZManaged[R1, E1, B]]): ZManaged[R1, E1, B]
Returns an effect that performs the outer effect first, followed by the inner effect, yielding the value of the inner effect.
Returns an effect that performs the outer effect first, followed by the inner effect, yielding the value of the inner effect.
This method can be used to "flatten" nested effects.
- def flattenZIO[R1 <: R, E1 >: E, B](implicit ev: IsSubtypeOfOutput[A, ZIO[R1, E1, B]]): ZManaged[R1, E1, B]
Returns an effect that performs the outer effect first, followed by the inner effect, yielding the value of the inner effect.
Returns an effect that performs the outer effect first, followed by the inner effect, yielding the value of the inner effect.
This method can be used to "flatten" nested effects.
- def flip: ZManaged[R, A, E]
Flip the error and result
- def flipWith[R1, A1, E1](f: (ZManaged[R, A, E]) => ZManaged[R1, A1, E1]): ZManaged[R1, E1, A1]
Flip the error and result, then apply an effectful function to the effect
- def fold[B](failure: (E) => B, success: (A) => B)(implicit ev: CanFail[E]): ZManaged[R, Nothing, B]
Folds over the failure value or the success value to yield an effect that does not fail, but succeeds with the value returned by the left or right function passed to
fold. - def foldCause[B](failure: (Cause[E]) => B, success: (A) => B): ZManaged[R, Nothing, B]
A more powerful version of
foldthat allows recovering from any kind of failure except interruptions. - def foldCauseManaged[R1 <: R, E1, A1](failure: (Cause[E]) => ZManaged[R1, E1, A1], success: (A) => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A1]
A more powerful version of
foldManagedthat allows recovering from any kind of failure except interruptions. - def foldManaged[R1 <: R, E2, B](failure: (E) => ZManaged[R1, E2, B], success: (A) => ZManaged[R1, E2, B])(implicit ev: CanFail[E]): ZManaged[R1, E2, B]
Recovers from errors by accepting one effect to execute for the case of an error, and one effect to execute for the case of success.
- def fork: ZManaged[R, Nothing, Fiber.Runtime[E, A]]
Creates a
ZManagedvalue that acquires the original resource in a fiber, and provides that fiber.Creates a
ZManagedvalue that acquires the original resource in a fiber, and provides that fiber. The finalizer for this value will interrupt the fiber and run the original finalizer. - final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def ignore: ZManaged[R, Nothing, Unit]
Returns a new effect that ignores the success or failure of this effect.
- def ignoreReleaseFailures: ZManaged[R, E, A]
Returns a new managed effect that ignores defects in finalizers.
- macro def inject[E1 >: E](layers: ZLayer[_, E1, _]*): ZManaged[Any, E1, A]
Automatically assembles a layer for the ZManaged effect.
Automatically assembles a layer for the ZManaged effect.
- Definition Classes
- ZManagedVersionSpecific
- macro def injectCustom[E1 >: E](layers: ZLayer[_, E1, _]*): ZManaged[zio.ZEnv, E1, A]
Automatically constructs the part of the environment that is not part of the
ZEnv, leaving an effect that only depends on theZEnv.Automatically constructs the part of the environment that is not part of the
ZEnv, leaving an effect that only depends on theZEnv. This will also satisfy transitiveZEnvrequirements withZEnv.any, allowing them to be provided later.val managed: ZManaged[OldLady with Console, Nothing, Unit] = ??? val oldLadyLayer: ZLayer[Fly, Nothing, OldLady] = ??? val flyLayer: ZLayer[Blocking, Nothing, Fly] = ??? // The ZEnv you use later will provide both Blocking to flyLayer and Console to managed val managed2 : ZManaged[ZEnv, Nothing, Unit] = managed.injectCustom(oldLadyLayer, flyLayer)
- Definition Classes
- ZManagedVersionSpecific
- def injectSome[R0 <: Has[_]]: ProvideSomeLayerManagedPartiallyApplied[R0, R, E, A]
Splits the environment into two parts, assembling one part using the specified layers and leaving the remainder
R0.Splits the environment into two parts, assembling one part using the specified layers and leaving the remainder
R0.val clockLayer: ZLayer[Any, Nothing, Clock] = ??? val managed: ZManaged[Clock with Random, Nothing, Unit] = ??? val managed2 = managed.injectSome[Random](clockLayer)
- Definition Classes
- ZManagedVersionSpecific
- def isFailure: ZManaged[R, Nothing, Boolean]
Returns whether this managed effect is a failure.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isSuccess: ZManaged[R, Nothing, Boolean]
Returns whether this managed effect is a success.
- def map[B](f: (A) => B): ZManaged[R, E, B]
Returns an effect whose success is mapped by the specified
ffunction. - final def mapAttempt[B](f: (A) => B)(implicit ev: IsSubtypeOfError[E, Throwable]): ZManaged[R, Throwable, B]
Returns an effect whose success is mapped by the specified side effecting
ffunction, translating any thrown exceptions into typed failed effects. - def mapBoth[E1, A1](f: (E) => E1, g: (A) => A1)(implicit ev: CanFail[E]): ZManaged[R, E1, A1]
Returns an effect whose failure and success channels have been mapped by the specified pair of functions,
fandg. - def mapError[E1](f: (E) => E1)(implicit ev: CanFail[E]): ZManaged[R, E1, A]
Returns an effect whose failure is mapped by the specified
ffunction. - def mapErrorCause[E1](f: (Cause[E]) => Cause[E1]): ZManaged[R, E1, A]
Returns an effect whose full failure is mapped by the specified
ffunction. - def mapZIO[R1 <: R, E1 >: E, B](f: (A) => ZIO[R1, E1, B]): ZManaged[R1, E1, B]
Effectfully maps the resource acquired by this value.
- def memoize: ZManaged[Any, Nothing, ZManaged[R, E, A]]
- def merge[A1 >: A](implicit ev1: IsSubtypeOfError[E, A1], ev2: CanFail[E]): ZManaged[R, Nothing, A1]
Returns a new effect where the error channel has been merged into the success channel to their common combined type.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def none[B](implicit ev: IsSubtypeOfOutput[A, Option[B]]): ZManaged[R, Option[E], Unit]
Requires the option produced by this value to be
None. - final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def onExecutionContext(ec: => ExecutionContext): ZManaged[R, E, A]
Runs this managed effect, as well as any managed effects that are composed sequentially after it, using the specified
ExecutionContext. - final def onExecutor(executor: => Executor): ZManaged[R, E, A]
Locks this managed effect to the specified executor, guaranteeing that this managed effect as well as managed effects that are composed sequentially after it will be run on the specified executor.
- def onExit[R1 <: R](cleanup: (Exit[E, A]) => ZIO[R1, Nothing, Any]): ZManaged[R1, E, A]
Ensures that a cleanup function runs when this ZManaged is finalized, after the existing finalizers.
- def onExitFirst[R1 <: R](cleanup: (Exit[E, A]) => ZIO[R1, Nothing, Any]): ZManaged[R1, E, A]
Ensures that a cleanup function runs when this ZManaged is finalized, before the existing finalizers.
- def option(implicit ev: CanFail[E]): ZManaged[R, Nothing, Option[A]]
Executes this effect, skipping the error but returning optionally the success.
- def orDie(implicit ev1: IsSubtypeOfError[E, Throwable], ev2: CanFail[E]): ZManaged[R, Nothing, A]
Translates effect failure into death of the fiber, making all failures unchecked and not a part of the type of the effect.
- def orDieWith(f: (E) => Throwable)(implicit ev: CanFail[E]): ZManaged[R, Nothing, A]
Keeps none of the errors, and terminates the fiber with them, using the specified function to convert the
Einto aThrowable. - def orElse[R1 <: R, E2, A1 >: A](that: => ZManaged[R1, E2, A1])(implicit ev: CanFail[E]): ZManaged[R1, E2, A1]
Executes this effect and returns its value, if it succeeds, but otherwise executes the specified effect.
- def orElseEither[R1 <: R, E2, B](that: => ZManaged[R1, E2, B])(implicit ev: CanFail[E]): ZManaged[R1, E2, Either[A, B]]
Returns an effect that will produce the value of this effect, unless it fails, in which case, it will produce the value of the specified effect.
- final def orElseFail[E1](e1: => E1)(implicit ev: CanFail[E]): ZManaged[R, E1, A]
Executes this effect and returns its value, if it succeeds, but otherwise fails with the specified error.
- final def orElseOptional[R1 <: R, E1, A1 >: A](that: => ZManaged[R1, Option[E1], A1])(implicit ev: IsSubtypeOfError[E, Option[E1]]): ZManaged[R1, Option[E1], A1]
Returns an effect that will produce the value of this effect, unless it fails with the
Nonevalue, in which case it will produce the value of the specified effect. - final def orElseSucceed[A1 >: A](a1: => A1)(implicit ev: CanFail[E]): ZManaged[R, Nothing, A1]
Executes this effect and returns its value, if it succeeds, but otherwise succeeds with the specified value.
- def preallocate: ZIO[R, E, Managed[Nothing, A]]
Preallocates the managed resource, resulting in a ZManaged that reserves and acquires immediately and cannot fail.
Preallocates the managed resource, resulting in a ZManaged that reserves and acquires immediately and cannot fail. You should take care that you are not interrupted between running preallocate and actually acquiring the resource as you might leak otherwise.
- def preallocateManaged: ZManaged[R, E, Managed[Nothing, A]]
Preallocates the managed resource inside an outer managed, resulting in a ZManaged that reserves and acquires immediately and cannot fail.
- def provide(r: => R)(implicit ev: NeedsEnv[R]): Managed[E, A]
Provides the
ZManagedeffect with its required environment, which eliminates its dependency onR. - final def provideCustomLayer[E1 >: E, R1](layer: => ZLayer[zio.ZEnv, E1, R1])(implicit ev1: <:<[zio.ZEnv with R1, R], ev2: Union[zio.ZEnv, R1], tagged: zio.Tag[R1]): ZManaged[zio.ZEnv, E1, A]
Provides the part of the environment that is not part of the
ZEnv, leaving a managed effect that only depends on theZEnv.Provides the part of the environment that is not part of the
ZEnv, leaving a managed effect that only depends on theZEnv.val loggingLayer: ZLayer[Any, Nothing, Logging] = ??? val managed: ZManaged[ZEnv with Logging, Nothing, Unit] = ??? val managed2 = managed.provideCustomLayer(loggingLayer)
- final def provideLayer[E1 >: E, R0, R1](layer: => ZLayer[R0, E1, R1])(implicit ev: <:<[R1, R]): ZManaged[R0, E1, A]
Provides a layer to the
ZManaged, which translates it to another level. - def provideSome[R0](f: (R0) => R)(implicit ev: NeedsEnv[R]): ZManaged[R0, E, A]
Provides some of the environment required to run this effect when the environment is not a subtype of
Has[_].Provides some of the environment required to run this effect when the environment is not a subtype of
Has[_]. This is useful primarily for implementing operators that are polymorphic in the environment type. When your environment is a subtype ofHas[_]use zio.ZIO.injectSome - final def provideSomeLayer[R0]: ProvideSomeLayer[R0, R, E, A]
Splits the environment into two parts, providing one part using the specified layer and leaving the remainder
R0.Splits the environment into two parts, providing one part using the specified layer and leaving the remainder
R0.val clockLayer: ZLayer[Any, Nothing, Has[Clock]] = ??? val managed: ZManaged[Has[Clock] with Has[Random], Nothing, Unit] = ??? val managed2 = managed.provideSomeLayer[Has[Random]](clockLayer)
- def refineOrDie[E1](pf: PartialFunction[E, E1])(implicit ev1: IsSubtypeOfError[E, Throwable], ev2: CanFail[E]): ZManaged[R, E1, A]
Keeps some of the errors, and terminates the fiber with the rest.
- def refineOrDieWith[E1](pf: PartialFunction[E, E1])(f: (E) => Throwable)(implicit ev: CanFail[E]): ZManaged[R, E1, A]
Keeps some of the errors, and terminates the fiber with the rest, using the specified function to convert the
Einto aThrowable. - def reject[E1 >: E](pf: PartialFunction[A, E1]): ZManaged[R, E1, A]
Fail with the returned value if the
PartialFunctionmatches, otherwise continue with our held value. - def rejectManaged[R1 <: R, E1 >: E](pf: PartialFunction[A, ZManaged[R1, E1, E1]]): ZManaged[R1, E1, A]
Continue with the returned computation if the
PartialFunctionmatches, translating the successful match into a failure, otherwise continue with our held value. - def release: ZManaged[R, E, A]
Runs all the finalizers associated with this scope.
Runs all the finalizers associated with this scope. This is useful to conceptually "close" a scope when composing multiple managed effects. Note that this is only safe if the result of this managed effect is valid outside its scope.
- def reserve: UIO[Reservation[R, E, A]]
Returns a
Reservationthat allows separately accessing effects describing resource acquisition and release. - def retry[R1 <: R, S](policy: => Schedule[R1, E, S])(implicit ev: CanFail[E]): ZManaged[R1 with Has[Clock], E, A]
Retries with the specified retry policy.
Retries with the specified retry policy. Retries are done following the failure of the original
io(up to a fixed maximum withonceorrecursfor example), so that thatio.retry(Schedule.once)means "executeioand in case of failure, try again once". - def sandbox: ZManaged[R, Cause[E], A]
Exposes the full cause of failure of this effect.
- def sandboxWith[R1 <: R, E2, B](f: (ZManaged[R1, Cause[E], A]) => ZManaged[R1, Cause[E2], B]): ZManaged[R1, E2, B]
Companion helper to
sandbox.Companion helper to
sandbox. Allows recovery, and partial recovery, from errors and defects alike. - final def some[B](implicit ev: IsSubtypeOfOutput[A, Option[B]]): ZManaged[R, Option[E], B]
Converts an option on values into an option on errors.
- final def someOrElse[B](default: => B)(implicit ev: IsSubtypeOfOutput[A, Option[B]]): ZManaged[R, E, B]
Extracts the optional value, or returns the given 'default'.
- final def someOrElseManaged[B, R1 <: R, E1 >: E](default: => ZManaged[R1, E1, B])(implicit ev: IsSubtypeOfOutput[A, Option[B]]): ZManaged[R1, E1, B]
Extracts the optional value, or executes the effect 'default'.
- final def someOrFail[B, E1 >: E](e: => E1)(implicit ev: IsSubtypeOfOutput[A, Option[B]]): ZManaged[R, E1, B]
Extracts the optional value, or fails with the given error 'e'.
- final def someOrFailException[B, E1 >: E](implicit ev: IsSubtypeOfOutput[A, Option[B]], ev2: <:<[NoSuchElementException, E1]): ZManaged[R, E1, B]
Extracts the optional value, or fails with a java.util.NoSuchElementException
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tap[R1 <: R, E1 >: E](f: (A) => ZManaged[R1, E1, Any]): ZManaged[R1, E1, A]
Returns an effect that effectfully peeks at the acquired resource.
- def tapBoth[R1 <: R, E1 >: E](f: (E) => ZManaged[R1, E1, Any], g: (A) => ZManaged[R1, E1, Any])(implicit ev: CanFail[E]): ZManaged[R1, E1, A]
Returns an effect that effectfully peeks at the failure or success of the acquired resource.
- final def tapDefect[R1 <: R, E1 >: E](f: (Cause[Nothing]) => ZManaged[R1, E1, Any]): ZManaged[R1, E1, A]
Returns an effect that effectually "peeks" at the defect of the acquired resource.
- def tapError[R1 <: R, E1 >: E](f: (E) => ZManaged[R1, E1, Any])(implicit ev: CanFail[E]): ZManaged[R1, E1, A]
Returns an effect that effectfully peeks at the failure of the acquired resource.
- final def tapErrorCause[R1 <: R, E1 >: E](f: (Cause[E]) => ZManaged[R1, E1, Any]): ZManaged[R1, E1, A]
Returns an effect that effectually peeks at the cause of the failure of the acquired resource.
- def tapZIO[R1 <: R, E1 >: E](f: (A) => ZIO[R1, E1, Any]): ZManaged[R1, E1, A]
Like ZManaged#tap, but uses a function that returns a ZIO value rather than a ZManaged value.
- def timed: ZManaged[R with Has[Clock], E, (zio.Duration, A)]
Returns a new effect that executes this one and times the acquisition of the resource.
- def timeout(d: => zio.Duration): ZManaged[R with Has[Clock], E, Option[A]]
Returns an effect that will timeout this resource, returning
Noneif the timeout elapses before the resource was reserved and acquired.Returns an effect that will timeout this resource, returning
Noneif the timeout elapses before the resource was reserved and acquired. If the reservation completes successfully (even after the timeout) the release action will be run on a new fiber.Somewill be returned if acquisition and reservation complete in time - def toLayer[A1 >: A](implicit arg0: zio.Tag[A1]): ZLayer[R, E, Has[A1]]
Constructs a layer from this managed resource.
- final def toLayerMany[A1 >: A](implicit arg0: zio.Tag[A1]): ZLayer[R, E, A1]
Constructs a layer from this managed resource, which must return one or more services.
- def toString(): String
- Definition Classes
- AnyRef → Any
- lazy val unit: ZManaged[R, E, Unit]
Return unit while running the effect
- final def unless(b: => Boolean): ZManaged[R, E, Option[A]]
The moral equivalent of
if (!p) exp - final def unlessManaged[R1 <: R, E1 >: E](b: => ZManaged[R1, E1, Boolean]): ZManaged[R1, E1, Option[A]]
The moral equivalent of
if (!p) expwhenphas side-effects - def unsandbox[E1](implicit ev: IsSubtypeOfError[E, Cause[E1]]): ZManaged[R, E1, A]
The inverse operation
ZManaged.sandboxed - final def unsome[E1](implicit ev: IsSubtypeOfError[E, Option[E1]]): ZManaged[R, E1, Option[A]]
Converts an option on errors into an option on values.
- final def updateService[M]: UpdateService[R, E, A, M]
Updates a service in the environment of this effect.
- final def updateServiceAt[Service]: UpdateServiceAt[R, E, A, Service]
Updates a service at the specified key in the environment of this effect.
- def use[R1 <: R, E1 >: E, B](f: (A) => ZIO[R1, E1, B]): ZIO[R1, E1, B]
Run an effect while acquiring the resource before and releasing it after
- def useDiscard[R1 <: R, E1 >: E, B](f: => ZIO[R1, E1, B]): ZIO[R1, E1, B]
Run an effect while acquiring the resource before and releasing it after.
Run an effect while acquiring the resource before and releasing it after. This does not provide the resource to the function
- val useForever: ZIO[R, E, Nothing]
Use the resource until interruption.
Use the resource until interruption. Useful for resources that you want to acquire and use as long as the application is running, like a HTTP server.
- val useNow: ZIO[R, E, A]
Runs the acquire and release actions and returns the result of this managed effect.
Runs the acquire and release actions and returns the result of this managed effect. Note that this is only safe if the result of this managed effect is valid outside its scope.
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def when(b: => Boolean): ZManaged[R, E, Option[A]]
The moral equivalent of
if (p) exp - def whenManaged[R1 <: R, E1 >: E](b: => ZManaged[R1, E1, Boolean]): ZManaged[R1, E1, Option[A]]
The moral equivalent of
if (p) expwhenphas side-effects - def withEarlyRelease: ZManaged[R, E, (UIO[Any], A)]
Modifies this
ZManagedto provide a canceler that can be used to eagerly execute the finalizer of thisZManaged.Modifies this
ZManagedto provide a canceler that can be used to eagerly execute the finalizer of thisZManaged. The canceler will run uninterruptibly with an exit value indicating that the effect was interrupted, and if completed will cause the regular finalizer to not run. - def withEarlyReleaseExit(e: => Exit[Any, Any]): ZManaged[R, E, (UIO[Any], A)]
A more powerful version of withEarlyRelease that allows specifying an exit value in the event of early release.
- final def withRuntimeConfig(runtimeConfig: => RuntimeConfig): ZManaged[R, E, A]
Runs this managed effect on the specified runtime configuration, guaranteeing that this managed effect as well as managed effects that are composed sequentially after it will be run on the specified runtime configuration.
- def zip[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1])(implicit zippable: Zippable[A, A1]): ZManaged[R1, E1, Out]
Named alias for
<*>. - def zipLeft[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A]
Named alias for
<*. - def zipPar[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1])(implicit zippable: Zippable[A, A1]): ZManaged[R1, E1, Out]
Named alias for
<&>. - def zipParLeft[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A]
Named alias for
<&. - def zipParRight[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A1]
Named alias for
&>. - def zipRight[R1 <: R, E1 >: E, A1](that: => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A1]
Named alias for
*>. - def zipWith[R1 <: R, E1 >: E, A1, A2](that: => ZManaged[R1, E1, A1])(f: (A, A1) => A2): ZManaged[R1, E1, A2]
Returns an effect that executes both this effect and the specified effect, in sequence, combining their results with the specified
ffunction. - def zipWithPar[R1 <: R, E1 >: E, A1, A2](that: => ZManaged[R1, E1, A1])(f: (A, A1) => A2): ZManaged[R1, E1, A2]
Returns an effect that executes both this effect and the specified effect, in parallel, combining their results with the specified
ffunction.Returns an effect that executes both this effect and the specified effect, in parallel, combining their results with the specified
ffunction. If either side fails, then the other side will be interrupted.
Deprecated Value Members
- def &&&[R1 <: R, E1 >: E, B](that: => ZManaged[R1, E1, B])(implicit zippable: Zippable[A, B]): ZManaged[R1, E1, Out]
Symbolic alias for zip.
Symbolic alias for zip.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use zip
- def >>=[R1 <: R, E1 >: E, B](k: (A) => ZManaged[R1, E1, B]): ZManaged[R1, E1, B]
Symbolic alias for flatMap
Symbolic alias for flatMap
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use flatMap
- def asService[A1 >: A](implicit arg0: zio.Tag[A1]): ZManaged[R, E, Has[A1]]
Maps the success value of this effect to a service.
Maps the success value of this effect to a service.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use toLayer
- def bimap[E1, A1](f: (E) => E1, g: (A) => A1)(implicit ev: CanFail[E]): ZManaged[R, E1, A1]
Returns an effect whose failure and success channels have been mapped by the specified pair of functions,
fandg.Returns an effect whose failure and success channels have been mapped by the specified pair of functions,
fandg.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use mapBoth
- def collectM[R1 <: R, E1 >: E, B](e: => E1)(pf: PartialFunction[A, ZManaged[R1, E1, B]]): ZManaged[R1, E1, B]
Fail with
eif the suppliedPartialFunctiondoes not match, otherwise continue with the returned value.Fail with
eif the suppliedPartialFunctiondoes not match, otherwise continue with the returned value.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use collectManaged
- def flattenM[R1 <: R, E1 >: E, B](implicit ev: IsSubtypeOfOutput[A, ZIO[R1, E1, B]]): ZManaged[R1, E1, B]
Returns an effect that performs the outer effect first, followed by the inner effect, yielding the value of the inner effect.
Returns an effect that performs the outer effect first, followed by the inner effect, yielding the value of the inner effect.
This method can be used to "flatten" nested effects.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use flattenZIO
- def foldCauseM[R1 <: R, E1, A1](failure: (Cause[E]) => ZManaged[R1, E1, A1], success: (A) => ZManaged[R1, E1, A1]): ZManaged[R1, E1, A1]
A more powerful version of
foldMthat allows recovering from any kind of failure except interruptions.A more powerful version of
foldMthat allows recovering from any kind of failure except interruptions.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use foldCauseManaged
- def foldM[R1 <: R, E2, B](failure: (E) => ZManaged[R1, E2, B], success: (A) => ZManaged[R1, E2, B])(implicit ev: CanFail[E]): ZManaged[R1, E2, B]
Recovers from errors by accepting one effect to execute for the case of an error, and one effect to execute for the case of success.
Recovers from errors by accepting one effect to execute for the case of an error, and one effect to execute for the case of success.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use foldManaged
- def get[B](implicit ev1: IsSubtypeOfError[E, Nothing], ev2: IsSubtypeOfOutput[A, Option[B]]): ZManaged[R, Option[Nothing], B]
Unwraps the optional success of this effect, but can fail with None value.
Unwraps the optional success of this effect, but can fail with None value.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use some
- final def lock(executor: => Executor): ZManaged[R, E, A]
Locks this managed effect to the specified executor, guaranteeing that this managed effect as well as managed effects that are composed sequentially after it will be run on the specified executor.
Locks this managed effect to the specified executor, guaranteeing that this managed effect as well as managed effects that are composed sequentially after it will be run on the specified executor.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use onExecutor
- final def lockExecutionContext(ec: => ExecutionContext): ZManaged[R, E, A]
Runs this managed effect, as well as any managed effects that are composed sequentially after it, using the specified
ExecutionContext.Runs this managed effect, as well as any managed effects that are composed sequentially after it, using the specified
ExecutionContext.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use onExecutionContext
- final def mapEffect[B](f: (A) => B)(implicit ev: IsSubtypeOfError[E, Throwable]): ZManaged[R, Throwable, B]
Returns an effect whose success is mapped by the specified side effecting
ffunction, translating any thrown exceptions into typed failed effects.Returns an effect whose success is mapped by the specified side effecting
ffunction, translating any thrown exceptions into typed failed effects.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use mapAttempt
- def mapM[R1 <: R, E1 >: E, B](f: (A) => ZIO[R1, E1, B]): ZManaged[R1, E1, B]
Effectfully maps the resource acquired by this value.
Effectfully maps the resource acquired by this value.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use mapZIO
- final def on(ec: => ExecutionContext): ZManaged[R, E, A]
Runs this managed effect, as well as any managed effects that are composed sequentially after it, using the specified
ExecutionContext.Runs this managed effect, as well as any managed effects that are composed sequentially after it, using the specified
ExecutionContext.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use onExecutionContext
- final def optional[E1](implicit ev: IsSubtypeOfError[E, Option[E1]]): ZManaged[R, E1, Option[A]]
Converts an option on errors into an option on values.
Converts an option on errors into an option on values.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use unsome
- def rejectM[R1 <: R, E1 >: E](pf: PartialFunction[A, ZManaged[R1, E1, E1]]): ZManaged[R1, E1, A]
Continue with the returned computation if the
PartialFunctionmatches, translating the successful match into a failure, otherwise continue with our held value.Continue with the returned computation if the
PartialFunctionmatches, translating the successful match into a failure, otherwise continue with our held value.- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use rejectManaged
- final def someOrElseM[B, R1 <: R, E1 >: E](default: => ZManaged[R1, E1, B])(implicit ev: IsSubtypeOfOutput[A, Option[B]]): ZManaged[R1, E1, B]
Extracts the optional value, or executes the effect 'default'.
Extracts the optional value, or executes the effect 'default'.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use someOrElseManaged
- final def tapCause[R1 <: R, E1 >: E](f: (Cause[E]) => ZManaged[R1, E1, Any]): ZManaged[R1, E1, A]
Returns an effect that effectually peeks at the cause of the failure of the acquired resource.
Returns an effect that effectually peeks at the cause of the failure of the acquired resource.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use tapErrorCause
- def tapM[R1 <: R, E1 >: E](f: (A) => ZIO[R1, E1, Any]): ZManaged[R1, E1, A]
Like ZManaged#tap, but uses a function that returns a ZIO value rather than a ZManaged value.
Like ZManaged#tap, but uses a function that returns a ZIO value rather than a ZManaged value.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use tapZIO
- final def unlessM[R1 <: R, E1 >: E](b: => ZManaged[R1, E1, Boolean]): ZManaged[R1, E1, Option[A]]
The moral equivalent of
if (!p) expwhenphas side-effectsThe moral equivalent of
if (!p) expwhenphas side-effects- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use unlessManaged
- final def unoption[E1](implicit ev: IsSubtypeOfError[E, Option[E1]]): ZManaged[R, E1, Option[A]]
Converts an option on errors into an option on values.
Converts an option on errors into an option on values.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use unsome
- def use_[R1 <: R, E1 >: E, B](f: => ZIO[R1, E1, B]): ZIO[R1, E1, B]
Run an effect while acquiring the resource before and releasing it after.
Run an effect while acquiring the resource before and releasing it after. This does not provide the resource to the function
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use useDiscard
- def whenM[R1 <: R, E1 >: E](b: => ZManaged[R1, E1, Boolean]): ZManaged[R1, E1, Option[A]]
The moral equivalent of
if (p) expwhenphas side-effectsThe moral equivalent of
if (p) expwhenphas side-effects- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use whenManaged