-
Notifications
You must be signed in to change notification settings - Fork 75
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
[ETCM-269] future task #756
Conversation
When done, could you please provide a brief argument for the choice of Monix rather than cats-effect or ZIO? |
… used, to keep tests pass
… used, to keep tests pass 2
One more thing, that might be useful - in service specs you might use |
I am strongly convinced ZIO is better.
monix.Task because:
Why monix.Task not cas-effect - I think abstracting over effect type sounds good in theory but:
I am willing to try to port code to ZIO and see by myself what would be practical benefits for mantis and come back to this discussion. Yet for now, Task seems like a good choice (stepping stone) :) |
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.
Looks good to me!
While I do think tests could be improved a bit, I think that they can be improved separately from this PR, even if organically when working on RPC
message: Any | ||
)(implicit timeout: Timeout, classTag: ClassTag[A], sender: ActorRef = Actor.noSender): Task[A] = | ||
Task | ||
.fromFuture((to ? message).mapTo[A]) |
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.
Do we want to use strict evaluation here? Shouldn't be Task.deferFuture
?
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.
Very good question 🤔
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.
This breaks the tests, I will explore what is needed to fix that.
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.
Changed to Task.deferFuture
: 7494676
val result: ServiceResponse[ListPeersInfoResponse] = | ||
debugService.listPeersInfo(ListPeersInfoRequest()) | ||
val result = | ||
debugService.listPeersInfo(ListPeersInfoRequest()).runToFuture |
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.
Why runToFuture
? To be consistent we should use runSyncUnsafe
everywhere (and avoid futureValue
)
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.
runSyncUnsafe was implemented at the beginning. But this break the tests:
[info] DebugServiceSpec:
[info] DebugService
[info] - should return list of peers info *** FAILED *** (8 seconds, 376 milliseconds)
[info] java.lang.AssertionError: assertion failed: timeout (3 seconds) during expectMsg while waiting for PeerInfoRequest(PeerId(testProbe-4))
[info] at scala.Predef$.assert(Predef.scala:223)
[info] at akka.testkit.TestKitBase.expectMsg_internal(TestKit.scala:459)
[info] at akka.testkit.TestKitBase.expectMsg(TestKit.scala:436)
[info] at akka.testkit.TestKitBase.expectMsg$(TestKit.scala:436)
[info] at akka.testkit.TestKit.expectMsg(TestKit.scala:969)
[info] at io.iohk.ethereum.jsonrpc.DebugServiceSpec$$anon$1.<init>(DebugServiceSpec.scala:35)
[info] at io.iohk.ethereum.jsonrpc.DebugServiceSpec.$anonfun$new$1(DebugServiceSpec.scala:28)
[info] at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
[info] at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
[info] at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info] ...
Some tests contain a mix of:
- expectations on Akka TestProbe
- sending messages to actors
- assertions at the end.
In some cases, I moved expectations and assertions at the end. But in some cases, I was not able to do it so I used conversion to Future to get async behavior.
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!
Description
Replace Future with Task in JSON RPC.
Proposed Solution
Important Changes Introduced
Testing