Skip to content

Commit

Permalink
Implemented collectHExit using FromFunctionHExit
Browse files Browse the repository at this point in the history
  • Loading branch information
dinobabujohn committed Feb 9, 2022
1 parent 19f6069 commit ba5e5af
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions zio-http/src/main/scala/zhttp/http/Http.scala
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ sealed trait Http[-R, +E, -A, +B] extends (A => ZIO[R, Option[E], B]) { self =>
case FromFunctionZIO(f) => HExit.fromZIO(f(a))
case FromFunctionHExit(f) => f(a)
case Collect(pf) => if (pf.isDefinedAt(a)) HExit.succeed(pf(a)) else HExit.empty
case CollectHExit(pf) => if (pf.isDefinedAt(a)) pf(a) else HExit.empty
case Chain(self, other) => self.execute(a).flatMap(b => other.execute(b))
case Race(self, other) =>
(self.execute(a), other.execute(a)) match {
Expand Down Expand Up @@ -665,7 +664,8 @@ object Http {
}

final case class PartialCollectHExit[A](unit: Unit) extends AnyVal {
def apply[R, E, B](pf: PartialFunction[A, HExit[R, E, B]]): Http[R, E, A, B] = CollectHExit(pf)
def apply[R, E, B](pf: PartialFunction[A, HExit[R, E, B]]): Http[R, E, A, B] =
FromFunctionHExit(a => if (pf.isDefinedAt(a)) pf(a) else HExit.empty)
}

final case class PartialRoute[A](unit: Unit) extends AnyVal {
Expand Down Expand Up @@ -713,8 +713,6 @@ object Http {

private final case class Collect[R, E, A, B](ab: PartialFunction[A, B]) extends Http[R, E, A, B]

private final case class CollectHExit[R, E, A, B](ah: PartialFunction[A, HExit[R, E, B]]) extends Http[R, E, A, B]

private final case class Chain[R, E, A, B, C](self: Http[R, E, A, B], other: Http[R, E, B, C])
extends Http[R, E, A, C]

Expand Down

1 comment on commit ba5e5af

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance Benchmark:

Concurrency: 256
Requests/sec: 926550.34

Please sign in to comment.