Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Introduction to monix coeval

22 visualizaciones

Publicado el

Asynchroneous programming and is well known term these days. Most of the applications are using this concept. In the world of big data there are many frameworks and libraries that allows us to write asynchroneous applications. Monix is one of the very famous and widely used library that provide asynchronous programing for Scala and Scala.js. In this blog we would be talking about how the monix allows to write functioanl lazy code with more controled execution.

According to typelevel monix is a “High-performance library for composing asynchronous, event-based programs, exposing a Reactive Streams implementation along with primitives for dealing with concurrency and side-effects.”

Publicado en: Tecnología
  • Inicia sesión para ver los comentarios

  • Sé el primero en recomendar esto

Introduction to monix coeval

  1. 1. Presented By: Girish Chandra Bharti (Module Lead Software Consultant @ Knoldus)
  2. 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Respect Knolx session timings, you are requested not to join sessions after a 5 minutes threshold post the session start time. Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Silent Mode Keep yourself on mute, if you are not talking. Avoid Disturbance Put yourself on mute again after asking questions.
  3. 3. Agenda
  4. 4. Introduction to monix ● Monix is a high-performance Scala / Scala.js library for composing asynchronous, event-based programs. ● A Typelevel project, Monix exemplifies pure, typeful, functional programming in Scala, while making no compromise on performance.
  5. 5. Major highlights in Monix ● Exposes the kick-ass Observable, Iterant, Task and Coeval data types, along with all the support they need ● Modular, only use what you need ● Designed for true asynchronicity, running on both the JVM and Scala.js ● Excellent test coverage, code quality and API documentation as a primary project policy
  6. 6. Major highlights in Monix ● The project started as a proper implementation of ReactiveX, with stronger functional programming influences and designed from the ground up for back-pressure. ● Made to cleanly interact with Scala’s standard library compatible and out-of-the-box with the Reactive Streams protocol. ● It then expanded to include abstractions for suspending side effects and for resource handling.
  7. 7. Monix Sub-projects Sub-projects: ● monix-eval ● monix-execution ● monix-catnap ● monix-reactive ● monix-tail
  8. 8. Monix Sub-projects monix-eval: Exposes the Task and Coeval data types, for dealing with purely functional effects in a principled way: ● Coeval ● Task
  9. 9. Monix Sub-projects monix-execution: Provides low level utilities for dealing with concurrency, exposing the JVM’s primitives and building on top of the scala.concurrent package. ● Scheduler ● Cancelable ● Callback ● Future Utils ● Atomic ● Local
  10. 10. Monix Sub-projects monix-catnap: Provide generic, purely functional utilities for managing concurrency, building on top of the Cats-Effect type classes: ● Circuit Breaker ● MVar
  11. 11. Monix Sub-projects monix-reactive: Exposes the Observable data type, along with adjacent utilities, a high performance streaming abstraction that’s an idiomatic implementation of ReactiveX for Scala: ● Observable ● Observers and Subscribers ● Consumer
  12. 12. Monix Sub-projects monix-tail: The monix-tail sub-projects exposes Iterant, a generic, purely functional, principled, pull-based streaming data type:
  13. 13. Companies that use Monix in production ● Abacus ● Agoda ● commercetools ● Coya ● E.ON Connecting Energies ● eBay Inc. ● Eloquentix ● Hypefactors ● Iterators ● Sony Electronics ● Zalando
  14. 14. What is monix Coeval? Coeval is a data type for controlling synchronous, possibly lazy evaluation, useful for describing lazy expressions and for controlling side-effects.
  15. 15. What is monix Coeval? A visual representation of where Coeval sits in the design space:
  16. 16. What is monix Coeval? In summary the Monix Coeval: ● Works only for immediate, synchronous evaluation ● Can be a replacement for lazy val and by-name parameters ● Doesn’t trigger the execution, or any effects until value or run ● Allows for controlling of side-effects handles errors
  17. 17. So what problems are we solving? ● lazy val cannot be expressed by developers as a type, you cannot take a lazy val parameter or return a lazy val from a function. def fun(lazy number): lazy [Int] = lazy val a = 10 (?????) ● by-name parameters, being just syntactic sugar that the compiler understand, but a proper type isn’t properly exposed by Scala.
  18. 18. So what problems are we solving? ● Scala has @tailrec as a compiler workaround to the JVM not supporting tail-calls elimination, but it does not work for mutually tail recursive calls and thus limited. ● The scala.util.Try type is overlapping in scope, given the Coeval focus on error handling, but doesn’t have lazy behavior.
  19. 19. Monix Coeval evaluation To evaluate a Coeval instance you can invoke its value command:
  20. 20. Monix Coeval As Try Implementation:
  21. 21. Monix Coeval Coeval to Task:
  22. 22. Monix Coeval Tail Recursion:
  23. 23. Monix Coeval Builders ● now ● eval ● evalOnce ● defer ● raiseError ● unit
  24. 24. Monix Coeval Memoization:
  25. 25. Monix Coeval FlatMap:
  26. 26. Monix Coeval Restart:
  27. 27. Monix Coeval Resource Clean up:
  28. 28. Monix Coeval Error Handling:
  29. 29. Q & A
  30. 30. References ● https://monix.io/docs/current/eval/coeval.html ● https://monix.io/ ● https://monix.io/docs/current/

×