Liking cljdoc? Tell your friends :D

otplike

Build Status

otplike is a framework built on top of core.async. It emulates basic Erlang/OTP concepts, such as processes, process linking, monitoring, standard behaviours.

Rationale

Although core.async provides a solid foundation for asynchronous applications, our experience shows that there is a need in higher level system building blocks.

It appears that certain ideas can be taken from Erlang/OTP and implemented on top of core.async.

The gen_server equivalent is used to serialize sync/async access to state and ensure that possibly inconsistent state data will be discarded in case of a crash.

Process linking/monitoring improves crash/error propagation and supervision covers recovery. In addition process tracing facility helps a lot with application debugging and profiling.

It is obvious that due to JVM limitations otplike cannot replace Erlang/OTP and otplike will NEVER be seen as Erlang/OTP alternative.

Example

Echo Server

(require '[otplike.process :as process :refer [!]])

(process/proc-defn server []
  (println "server: waiting for messages...")
  ; wait for messages
  (process/receive!
    [from msg]
    (do
      (println "server: got" msg)
      ; send response
      (! from [(process/self) msg])
      (recur))
    :stop
    ; exit receive loop
    (println "server: stopped")))

(process/proc-defn client []
  ; spawn process
  (let [pid (process/spawn server)]
    ; send message to it
    (! pid [(process/self) :hello])

    ;wait for response
    (process/receive!
      [pid msg]
      (println "client: got" msg))

    ; ask spawned process to stop
    (! pid :stop)))

(process/spawn client)

More examples are available under the /examples directory.

Releases and Dependency Information

Clojars Project

All Released Versions

Leiningen dependency information:

[otplike "0.6.0-alpha"]

Documentation

Other materials

Known issues

  • A chain of N processes, when each next process is created by the previous one, holds amount of memory proportional to N until the last process' exit

Plans

  • ClojureScript compatibility
  • application behaviour and related features as configuration
  • "Simple" supervisor (analogous to simple_one_for_one in Erlang) as a separate module
  • Tracing and introspection
  • More advanced examples/tutorial

Contributing

Please use the project's GitHub issues page for all questions, ideas, etc. Pull requests are welcome. See the project's GitHub contributors page for a list of contributors.

License

Copyright © 2017 SUPREMATIC and contributors.

Distributed under the Eclipse Public License v1.0, the same as Clojure. License file is available under the project root.

Changelog

  • Release 0.6.0-alpha on 20.07.2019 NOTES
  • Release 0.5.0-alpha on 07.12.2018 NOTES
  • Release 0.4.0-alpha on 15.04.2018 NOTES
  • Release 0.3.0-alpha on 28.11.2017 NOTES
  • Release 0.2.1-alpha on 11.08.2017 NOTES
  • Release 0.2.0-alpha on 17.05.2017 NOTES
  • Release 0.1.0-SNAPSHOT on 15.08.2016

Can you improve this documentation? These fine people already did:
Simon Skorokhodov, Alexey Aristov, Semyon Skorokhodov & Ilya Shinkarenko
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close