otplike
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
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.