-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine Endpoint Module #988
Conversation
Codecov Report
@@ Coverage Diff @@
## cats-effect #988 +/- ##
===============================================
+ Coverage 84.84% 85.26% +0.41%
===============================================
Files 49 47 -2
Lines 884 882 -2
Branches 53 50 -3
===============================================
+ Hits 750 752 +2
+ Misses 134 130 -4
Continue to review full report at Codecov.
|
6bc8cc5
to
5ecb0d5
Compare
What is a benifit of having two almost equivalent method definitions like |
I feel like this structure promote consistency. The very same approach is used in several places where I looked-up. Notably, Monix's UPDATE: |
5ecb0d5
to
337a125
Compare
337a125
to
fee0844
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Few nitpicks of future leftovers
val i = Input(emptyRequest, Seq.empty) | ||
var c = 0 | ||
val e = get(*) { c = c + 1; Ok(c) } | ||
val e = get(pathAny) { c = c + 1; Ok(c) } | ||
|
||
e(i).awaitValueUnsafe() shouldBe Some(1) | ||
e(i).awaitValueUnsafe() shouldBe Some(2) | ||
} | ||
|
||
it should "not evaluate Futures until matched" in { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evaluate Effect
|
||
e(i).awaitValueUnsafe() shouldBe Some(1) | ||
e(i).awaitValueUnsafe() shouldBe Some(2) | ||
} | ||
|
||
it should "not evaluate Futures until matched" in { | ||
import io.finch.catsEffect._ | ||
|
||
val i = Input(emptyRequest, Seq("a", "10")) | ||
var flag = false | ||
|
||
val endpointWithFailedFuture = "a".mapAsync { nil => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FailedIO
here
fee0844
to
229d2da
Compare
This PR refines what
EndpointModule
is and whereEndpoint
instances are constructed. It doesn't invent anything new but reuses ideas from other libraries solving similar problems.The following ways of constructing endpoints are now supported.
What's changed
Endpoint.*
(thinkEndpoint.param
,Endpoint.body
) andEndpointModule.*
just redirects its calls there similar to how iteratee and Monix do that.Module[F[_]]
no longer embedsOutputs
andValidationRules
are they are not depending on the effect type (io.finch._
imports them as it does today).tried
module implementation,IO
is used in tests.Endpoint.Mappable
).Endpoint
type alias from withinEndpointModule
./
is renamed tozero
and*
is renamed topathAny
(the fewer symbolic APIs we have the better).Int
andBoolean
to path-endpoints were removed. OnlyString
is supported now (the less we implicitly convert the better).