Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Discourje: Automatically validated message exch...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

Discourje: Automatically validated message exchange patterns in Clojure

The core.async library provides many high-level features for async programming, but does not protect against classical concurrency problems. Discourje extends core.async and offers high-level abstractions to define message exchange patterns that are run-time validated and enforced between threads.

Avatar for RubenHamers

RubenHamers

April 06, 2019
Tweet

Other Decks in Technology

Transcript

  1. Context  Interested in concurrent programming  Clojure  Implement

    Message Exchange Pattern (MEP) framework in Clojure
  2. Example: MEP global protocol BuyGoods (role Buyer, role Seller) {

    QuoteRequest from Buyer to Seller; choice at Seller { Quote from Seller to Buyer; Order from Buyer to Seller; OrderAcknowledgement from Seller to Buyer; } or { OutOfStock from Seller to Buyer; } } * https://github.com/scribble/scribble-language-guide/tree/master/defineprotocol
  3. Clojure  Advantages of Clojure  No research done towards

    embedded (DSL) MEP languages.  Core.async
  4. Core.async  Do not reinvent the wheel.  Provide facilities

    for independent threads of activity, communicating via queue-like channels.*  Note that, unlike other Clojure concurrency constructs, channels, like all communications, are subject to deadlocks.*  Validation? *https://clojure.org/news/2013/06/28/clojure-clore-async-channels
  5. Supported features:  Atomic send & receive operations  Sequencing

     Parallelism  Branching  Recursion  Nesting (branching & recursion)
  6. Discourje: Step 2 Add infrastructure to MEP Generate default channels

    (buffer size 1) or create your own channels.
  7. Conclusion  Separation of concerns  Build as DSL, no

    special compiler or syntax  Protection against communication mismatches and deadlocks
  8. Questions? (def Q&A (mep (rec :questions? (-->> "Questions?" "Ruben" "Audience")

    (choice [(-->> "Yes" "Audience" "Ruben") (-->> "Answer" "Ruben" "Audience") (continue :questions?)] [(-->> "No" "Audience" "Ruben")]) (-->> "Thank you for your attention!" "Ruben" "Audience")))) https://gitlab.com/ruben.hamers/Discourje