Otplike
Erlang/OTP like processes and behaviours for Clojure on top of core.async
Install / Use
/learn @suprematic/OtplikeREADME
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
applicationbehaviour and related features as configuration- "Simple" supervisor (analogous to
simple_one_for_onein 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
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
