A tutorial application for teaching core Swim concepts. See a hosted version of this app running at https://stocks-live.nstream-demo.io.
This example utilizes a 3rd party data service called TwelveData to provide realtime data about the stock market. In order to run this example you will need an api key for TwelveData.
Replace the following token with your token to TwelveData.
cd server
TOKEN=asdfaerraxcsasdfa mvn clean compile exec:java
We have two versions of a UI available. The first is built with React + TypeScript + Vite, and uses AG Grid for the table component.
cd ui
npm install
npm run dev
Then head to localhost:5173
to see it in action.
The other option is a UI built with NStream's own UI framework.
cd nstream-ui
npm install
TOKEN=asdfaerraxcsasdfa npm run dev
Then head to localhost:9001
to see it in action.
The swim-cli is the simplest way to fetch or stream data from the web agents in this application
swim-cli installation details available here: https://www.swimos.org/backend/cli/
Note:
- Below swim-cli commands for introspection are for streaming locally running application.
- There is a hosted version of this application running here: https://stocks-live.nstream-demo.io/
- To stream APIs for the hosted version, replace
warp://localhost:9001
in below commands withwarps://stocks-live.nstream-demo.io
(Below, Stock ticker symbol "AAPL" is used as an example)
- SYMBOLS:
- List of various stocks' current price, trading volume, bid/ask if any, and the price movement in the stock price.
swim-cli sync -h warp://localhost:9001 -n /symbols -l stocks
- STOCK:
- A particular stock's current status details (current price, trading volume, bid/ask if any, and the price movement in the stock price)
swim-cli sync -h warp://localhost:9001 -n /stock/AAPL -l status
- A particular stock's previous close price details
swim-cli sync -h warp://localhost:9001 -n /stock/AAPL -l previousClose
The Swim runtime exposes its internal subsystems as a set of meta web agents.
Use the swim:meta:host
agent to introspect a running host. Use the pulse
lane to stream high level stats:
swim-cli sync -h warp://localhost:9001 -n swim:meta:host -l pulse
The nodes
lane enumerates all agents running on a host:
swim-cli sync -h warp://localhost:9001 -n swim:meta:host -l nodes
The fragment part of the nodes
lane URI can contain a URI subpath filter:
swim-cli sync -h warp://localhost:9001 -n swim:meta:host -l nodes#/
You can stream the utilization of an individual web agent:
swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fadapter%2ftwelvedata -l pulse
swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fsymbols -l pulse
swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fstock%2fAAPL -l pulse
And discover its lanes:
swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fadapter%2ftwelvedata -l lanes
swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fsymbols -l lanes
swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fstock%2fAAPL -l lanes
swim-cli sync -h warp://localhost:9001 -n swim:meta:edge -l meshes