-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add instances for Finagle services, etc.
- Loading branch information
1 parent
12a3046
commit 3404969
Showing
11 changed files
with
90 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package io.catbird | ||
|
||
package object finagle extends ServiceConversions | ||
package object finagle extends ServiceInstances with ServiceConversions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 15 additions & 4 deletions
19
...ala/io/catbird/finagle/ServiceTests.scala → ...st/scala/io/catbird/finagle/service.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
test/src/main/scala/io/catbird/test/finagle/arbitrary.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.catbird.test.finagle | ||
|
||
import com.twitter.finagle.Service | ||
import io.catbird.util.futureInstance | ||
import org.scalacheck.Arbitrary | ||
|
||
trait ArbitraryInstances { | ||
implicit def serviceArbitrary[I, O](implicit arbF: Arbitrary[I => O]): Arbitrary[Service[I, O]] = | ||
Arbitrary(arbF.arbitrary.map(f => Service.mk(i => futureInstance.pure(f(i))))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.catbird.test.finagle | ||
|
||
import cats.Eq | ||
import com.twitter.finagle.Service | ||
import com.twitter.util.{ Await, Duration } | ||
|
||
trait EqInstances { | ||
def serviceEq[I, O](atMost: Duration)(implicit eqF: Eq[I => O]): Eq[Service[I, O]] = | ||
eqF.on(_.andThen(o => Await.result(o, atMost))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.catbird.test.util | ||
|
||
import cats.Eq | ||
import cats.laws.discipline.EqK | ||
import com.twitter.util.{ Duration, Future, Var } | ||
import io.catbird.util.{ futureEq, varEq } | ||
|
||
trait EqKInstances { | ||
def futureEqK(atMost: Duration): EqK[Future] = | ||
new EqK[Future] { | ||
def synthesize[A](implicit A: Eq[A]): Eq[Future[A]] = futureEq(atMost) | ||
} | ||
|
||
implicit def varEqK: EqK[Var] = | ||
new EqK[Var] { | ||
def synthesize[A](implicit A: Eq[A]): Eq[Var[A]] = varEq | ||
} | ||
} |