- Haskell Server tails Mongo oplog and broadcast changes to the collection
quotes.quote
and broadcast them to all subscribed clients. Quotes are dead trivial and contain just a symbol and a price. - An Elm SPA client as well as a Haskell CLI client.
- A haskell script to repeatedly update a handful of fake securities with fake prices.
If you don't have these already, install:
- Stack:
curl -sSL https://get.haskellstack.org/ | sh
- Elm:
- create-elm-app:
npm install create-elm-app -g
- MongoDB (version 4.4 known to work). Enable Replicas, because this app reads the Oplog. A single Mongo instance is enough. Don't need to actually replicate
Using the mongo
CLI tool, run the commands in the file app/create_quote_coll.mongodb
Edit src/Config.hs
Edit the websocket url in elm-client/src/index.js
Clone this repo, and from the top level directory of this repo, run:
stack build
cd elm-client; elm-app build
In the root folder of the repository, run
stack run ws-server
stack run ws-client
stack run update-quotes-mongo
stack run tail-oplog
You should see the quotes ticking in the Elm client and the CLI client writing them to the console
- Assumes default Mongo port, hardcodes HTTP port 8080
- Hardcodes db/collection names
- don't hardcode ports, db collections
- More realistic quote objects with
- Subscriptions
- throttling. May want different rates for different subscriptions