https://github.com/druids/xpusher
A Pusher client for coin exchanges based on core.async
https://github.com/druids/xpusher
Last synced: over 1 year ago
JSON representation
A Pusher client for coin exchanges based on core.async
- Host: GitHub
- URL: https://github.com/druids/xpusher
- Owner: druids
- License: mit
- Created: 2018-06-08T11:58:14.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-10T10:25:44.000Z (over 7 years ago)
- Last Synced: 2025-01-30T02:14:12.302Z (over 1 year ago)
- Language: Clojure
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
xpusher
=======
A Pusher client for coin exchanges based on [core.async](https://github.com/clojure/core.async).
[](https://circleci.com/gh/druids/xpusher)
[](https://jarkeeper.com/druids/xpusher)
[](https://opensource.org/licenses/MIT)
Leiningen/Boot
--------------
```clojure
[xpusher "0.2.0"]
```
Documentation
-------------
This library is a thin wrapper around `com.pusher/pusher-java-client` within a simple usage. A function `new-pusher`
opens a new connection with the Pusher server, subscribes a requested channel and returns a following tuple
`[pusher pusher-channel status-ch data-ch]` where
- `pusher` a Pusher instance
- `pusher` a subscribed Channel instance
- `status-ch` an async channel containing a pusher and channel messages as a tuple `[action data]`
- `data-ch` an async channel containing data for the subscribed channel as a tuple `[channel-name event-name data]`
The function takes an option object:
- `channel-name` a channel name to subscribe, required
- `pusher-key` a Pusher key, default de504dc5763aeef9ff52, optional
- `event-name` an event name to bind on the subscribed channel, optional
- `status-buffer-or-n` a buffer-or-n for the status channel, optional
- `data-buffer-or-n` a buffer-or-n for the data channel, optional
- `str-big-decimals?` when `true` coerce a volume and price (in strings) as `BigDecimal`, default `true`
Data channel returns a tuple of channel-name, event-name (as `keyword`), and data.
Status channel returns a tuple of event-name (as `keyword`), and data. Expected events:
- `:change`
- `:connecting`
- `:connected`
- `:disconnecting`
- `:disconnected`
### Bitstamp
```clojure
(require '[clojure.core.async :as async])
(require '[xpusher.async :as xpusher])
(let [[pusher pusher-channel status-ch data-ch]
(xpusher/new-bitstamp-pusher {:channel-name "order_book_btceur" ;; required
:event-name "data" ;; required
:data-buffer-or-n (async/sliding-buffer 16) ;; optinal
:status-buffer-or-n 16})] ;; optional
(async/go-loop []
(let [[channel-name event-name data] (async/