Skip to content

Commit

Permalink
Add scaladoc for CloseOnError (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtar authored and t3hnar committed Oct 5, 2023
1 parent a474edb commit a4a52ea
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@ import cats.effect.concurrent.Ref
import cats.syntax.all._


/** Execute underlying effect as is, but memoize a potential error.
*
* In other words, as soon as the error happens, the effects will not be
* executed anymore, but the previous error will be returned instead.
*/
trait CloseOnError[F[_]] {

/** Wrap an effectful value.
*
* This method is fine to be called serveral times, but all of the wrapped
* values will use a single latch, so if one of them fails, all others will
* return the same error.
*/
def apply[A](fa: F[A]): F[A]

/** Memoized error, or `None` if an error did not happen yet */
def error: F[Option[Throwable]]
}

Expand Down Expand Up @@ -49,4 +61,4 @@ object CloseOnError {
def apply[A](fa: F[A]): F[A] = self(fa)
}
}
}
}

0 comments on commit a4a52ea

Please sign in to comment.