-
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
Provides grpc configuration DSL and GrpcServer algebras #13
Conversation
Server Demo has been also adapated to the new introduced changes, where the rpc core provides helpers in order to bootstrap the server in the runtime monad, according to the server configuration.
c697e24
to
62126cd
Compare
Codecov Report
@@ Coverage Diff @@
## master #13 +/- ##
====================================
Coverage 0% 0%
====================================
Files 6 9 +3
Lines 103 122 +19
Branches 2 2
====================================
- Misses 103 122 +19
Continue to review full report at Codecov.
|
ee2fa00
to
4a8f0bf
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.
Left a few comments, but looks good in general (for someone with no grpc experience 😃).
import scala.concurrent.Future | ||
|
||
trait FutureCaptureInstance { | ||
implicit val `scala.concurrent.FutureCaptureInstance`: Capture[Future] = new Capture[Future] { |
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.
It looks like there is a Capture[Future]
instance in the Capture
companion object.
Kleisli(s => C.capture(s.start())) | ||
} | ||
|
||
def getPort: GrpcServerOps[F, Int] = Kleisli(s => C.capture(s.getPort)) |
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.
Maybe we can create a small helper method for this Kleisli(s => C.capture(s.foo))
pattern?
Something like
private def captureWithServer[A](f: Server => A] : GrpcServerOps[F, A] = Kleisli(s => C.capture(f(s))`
def getPort: GrpcServerOps[F, Int] = captureWithServer(_.getPort)
|
||
sealed trait GrpcConfig | ||
|
||
case object GetDirectExecutor extends GrpcConfig |
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 haven't look too closely at the grpc
api, but GetDirectExecutor
seems a bit strange for something which will never return something?
|
||
case class Config(port: Int) | ||
|
||
sealed trait GrpcConfig |
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.
We should probably add extends Product with Serializable
, otherwise the type of something like List(GetDirectExecutor)
would be inferred as List[GrpcConfig with Product with Serializable]
.
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.
Awesome stuff!
Server Demo has been also adapted to the newly introduced changes, where the RPC core provides helpers in order to bootstrap the server in the runtime monad, according to the server configuration.
This is a preliminary version towards to fulfill #10. We still need to find the way to aggregate all the services which would run in such a server.
For now, the user has to provide an implicit list with all the services the server will register:
https://github.com/frees-io/freestyle-rpc/compare/feature/server-definitions#diff-09bc282791d5598d8a70f248fbb125b0R33
Thanks @peterneyens for your suggestions related to the
GrpcConfigInterpreter
:)Server bootstrap:
(
bootstrapFuture
would be equivalent tobootstrap[Future]
)Runtime dependencies: