Skip to content

nstreamio/nstream-cflt-bike-rental

Repository files navigation

Rental Bike Demo

A tutorial application for teaching core Swim concepts. See a hosted version of this app running at https://cflt-bike-rental.nstream-demo.io.

Prerequisites

  • Install JDK 17+.

    • Ensure that your JAVA_HOME environment variable is pointed to your Java installation location.
    • Ensure that your PATH includes $JAVA_HOME.
  • Install Node.js.

    • Confirm that npm was installed during the Node.js installation.

Repository Structure

Key files

Key directories

  • src — backend source code, and configuration resources
  • ui src — frontend source code
  • gradle — support files for the gradlew build script

Run

Running on Linux or MacOS

$ ./gradlew run

Viewing the UI

Open a web browser to http://localhost:9001.

Streaming APIs

The swim-cli is the simplest way to fetch or stream data from the web agents in this application

"swim-cli" installation

swim-cli installation details available here: https://www.swimos.org/backend/cli/

Application APIs

Note:

  • Below swim-cli commands for introspection are for streaming locally running application.
  • There is a hosted version of this application running here: https://cflt-bike-rental.nstream-demo.io/
  • To stream APIs for the hosted version, replace warp://localhost:9001 in below commands with warps://cflt-bike-rental.nstream-demo.io
  1. CONSUMER:
swim-cli sync -h warp://localhost:9001 -n /consumer -l pulse
  1. STATION:

(Below, station "0efa08a3-1c38-48fe-ab37-8c9b72b20126" is used as an example)

  • Latest status metrics of the station
swim-cli sync -h warp://localhost:9001 -n /station/0efa08a3-1c38-48fe-ab37-8c9b72b20126 -l latest
  • Geographical coordinates of the station
swim-cli sync -h warp://localhost:9001 -n /station/0efa08a3-1c38-48fe-ab37-8c9b72b20126 -l geo

Introspection APIs

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#/

Node Introspection

You can stream the utilization of an individual web agent:

swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fconsumer -l pulse

swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fstation%2f0efa08a3-1c38-48fe-ab37-8c9b72b20126 -l pulse
swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fstation%2f1879828885264130640 -l pulse

And discover its lanes:

swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fconsumer -l lanes

swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fstation%2f0efa08a3-1c38-48fe-ab37-8c9b72b20126 -l lanes
swim-cli sync -h warp://localhost:9001 -n swim:meta:node/%2fstation%2f1879828885264130640 -l lanes

Mesh introspection

swim-cli sync -h warp://localhost:9001 -n swim:meta:edge -l meshes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages