Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zachallaun/async-pipeline
https://github.com/zachallaun/async-pipeline
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/zachallaun/async-pipeline
- Owner: zachallaun
- Created: 2013-08-13T21:05:48.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-08-13T21:14:28.000Z (about 11 years ago)
- Last Synced: 2024-10-11T19:20:04.547Z (27 days ago)
- Language: Clojure
- Size: 109 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# async-pipeline
A small library for creating `clojure.core.async` process pipelines.
_Inspired by [Messaging as a Programming Model](http://eventuallyconsistent.net/2013/08/12/messaging-as-a-programming-model-part-1/)._
```clj
(require '[clojure.core.async :as async :refer [>! ! out msg)
(recur))
[:error :invalid-credentials msg])))))(defn filter-api-key-enabled
[in out]
(go-try
(loop []
(when-recv [{:keys [api-key] :as msg} (! out (assoc msg :api-details details))
(recur))
[:error :invalid-api-key msg])))))(defn get-user-info
[in out]
(go-try
(loop []
(when-recv [{:keys [username api-details] :as msg} (! out (assoc msg :user-info (user-info-for username api-details)))
(recur)))))(def login-pipeline
(pipeline async/chan
filter-valid-credentials
filter-api-key-enabled
get-user-info))(let [[in out err ctrl] login-pipeline]
(forward-login-requests in)
(handle-login-errors err)
(respond-with-details out)(async/put! in {:username "zach" :password "p@$$w04d"}))
```