-
Notifications
You must be signed in to change notification settings - Fork 34
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
frees-rpc Tagless-final Migration - Release 0.8.0 #117
Conversation
Codecov Report
@@ Coverage Diff @@
## master #117 +/- ##
==========================================
- Coverage 82% 77.57% -4.43%
==========================================
Files 12 12
Lines 100 107 +7
==========================================
+ Hits 82 83 +1
- Misses 18 24 +6
Continue to review full report at Codecov.
|
@free | ||
trait GrpcServer { | ||
@tagless | ||
trait GrpcServer[F[_]] { |
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.
You can still use the FS
, and avoid adding the F[_]
.
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.
Yes, I know. IntelliJ shows less red code in this way.
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.
Left minor comments, amazing job
@@ -19,7 +19,7 @@ package internal | |||
package client | |||
|
|||
import freestyle.async.AsyncContext | |||
import freestyle.free._ | |||
import freestyle.free.FSHandler |
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.
Can we use ~>
instead?
|
||
@module | ||
trait ChannelConfig { | ||
|
||
val configM: ConfigM | ||
implicit val functor: Functor |
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.
Minor comment, what about putting this at the beginning?
implicit val functor: Functor
val configM: ConfigM
val defaultHost: String = "localhost"
val defaultPort: Int = freestyle.rpc.server.defaultPort
trait Helpers { | ||
|
||
def server[M[_]](implicit S: GrpcServer[M]): FreeS[M, Unit] = { | ||
def server[F[_]: Monad](implicit S: GrpcServer[F]): F[Unit] = { |
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.
Can Monad
be replaced by Functor
?
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.
For the moment we need Monad
for the for comprehension below.
We could require Apply
and write S.start() *> S.getPort.void
I think.
We could write something similar in the other places where Fede left this comment.
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.
You also need flatMap
} yield () | ||
} | ||
|
||
def serverStop[M[_]](implicit S: GrpcServer[M]): FreeS[M, Unit] = { | ||
def serverStop[F[_]: Monad](implicit S: GrpcServer[F]): F[Unit] = { |
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.
Same as above
@@ -52,17 +47,17 @@ trait CommonUtils { | |||
|
|||
def createServerConf(grpcConfigs: List[GrpcConfig]): ServerW = ServerW(SC.port, grpcConfigs) | |||
|
|||
def serverStart[M[_]](implicit S: GrpcServer[M]): FreeS[M, Unit] = { | |||
def serverStart[F[_]: Monad](implicit S: GrpcServer[F]): F[Unit] = { |
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.
Same as above
@@ -75,29 +95,30 @@ object Utils extends CommonUtils { | |||
import service._ | |||
import freestyle.rpc.protocol._ | |||
|
|||
class ServerRPCService[F[_]](implicit C: Capture[F], T2F: Task ~> F) extends RPCService[F] { | |||
class ServerRPCService[F[_]](implicit F: Applicative[F], T2F: Task ~> F) |
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.
F[_]: Applicative
?
@@ -214,8 +215,10 @@ object TaglessUtils extends CommonUtils { | |||
// Server Runtime Configuration // | |||
////////////////////////////////// | |||
|
|||
implicit val taglessRPCHandler: TaglessRPCService.Handler[ConcurrentMonad] = | |||
new TaglessRPCServiceServerHandler[ConcurrentMonad] | |||
implicit def taglessRPCHandler[F[_]]( |
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.
F[_]: Applicative
?
@@ -47,7 +46,7 @@ class GrpcServerTests extends RpcServerTestSuite { | |||
|
|||
"behaves as expected" in { | |||
|
|||
def program[F[_]](implicit APP: GrpcServer[F]): FreeS[F, Result] = { | |||
def program[F[_]: Monad](APP: GrpcServer[F]): F[Result] = { |
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.
Same as above
case AwaitTerminationOp() => serverMock.awaitTermination() | ||
} | ||
} | ||
def grpcServerHandlerTests[F[_]](implicit F: Applicative[F]): GrpcServer[F] = { |
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.
F[_]: Applicative
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.
I preferred this way in order to use F
as F.pure
, rather than Applicative[F].pure
.
This PR migrates
frees-rpc
entirely to tagless-final using Freestyle@tagless
.Considering all these changes as API breaking, it also releases a new minor version: 0.8.0.