Skip to content

[ETCM-454] Migrate Scala Futures to Monix Tasks #855

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

Merged
merged 13 commits into from
Dec 17, 2020

Conversation

enriquerodbe
Copy link
Contributor

Description

Changing a bunch of usages of Scala's Future to Monix Task.

Proposed Solution

Trying to keep everything in Monix Tasks and only convert to Future to execute them in the "edges" of the application.

Important Changes Introduced

Testing

@@ -110,7 +110,7 @@ class BlockImport(
block: Block,
currentBestBlock: Block,
currentWeight: ChainWeight
)(implicit blockExecutionContext: ExecutionContext): Future[BlockImportResult] = Future {
)(implicit blockExecutionContext: ExecutionContext): Task[BlockImportResult] = Task.evalOnce {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this evalOnce, or the ones above, needed? Isn't the task only evaluated once?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same. But some tests fail if I just use Task.eval, precisely because the mock expectations only expect 1 call. I would like to understand why in the tests this code is evaluated more than once, but this is the best I found for now.

@enriquerodbe enriquerodbe self-assigned this Dec 11, 2020
@enriquerodbe enriquerodbe marked this pull request as ready for review December 14, 2020 12:23
Copy link
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎆

@biandratti
Copy link
Contributor

LGTM!

@enriquerodbe enriquerodbe merged commit 3f1d4df into develop Dec 17, 2020
@enriquerodbe enriquerodbe deleted the feature/monix_tasks branch December 17, 2020 18:23
@lemastero lemastero changed the title ETCM-269 Migrate Scala Futures to Monix Tasks ETCM-454 Migrate Scala Futures to Monix Tasks Dec 18, 2020
@lemastero lemastero changed the title ETCM-454 Migrate Scala Futures to Monix Tasks [ETCM-454] Migrate Scala Futures to Monix Tasks Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants