https://github.com/adhdtech/drp
DRP - A websocket subprotocol for declaring and consuming resources
https://github.com/adhdtech/drp
broker datamesh drp mesh nodejs provider registry service streams websocket-subprotocol websockets
Last synced: 14 days ago
JSON representation
DRP - A websocket subprotocol for declaring and consuming resources
- Host: GitHub
- URL: https://github.com/adhdtech/drp
- Owner: adhdtech
- License: isc
- Created: 2019-01-07T05:43:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-24T23:55:07.000Z (8 months ago)
- Last Synced: 2024-10-16T05:31:33.529Z (6 months ago)
- Topics: broker, datamesh, drp, mesh, nodejs, provider, registry, service, streams, websocket-subprotocol, websockets
- Language: JavaScript
- Homepage:
- Size: 12.6 MB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 22
-
Metadata Files:
- Readme: README-MermaidCode.md
- License: LICENSE
Awesome Lists containing this project
README
## DRP
Declarative Resource Protocol - a JSON based Websocket subprotocol for declaring and consuming resources.## Overview
In legacy applications, resource dependencies are often statically defined. When a new service component is
introduced, DNS, load balancer entries, firewall rules, monitoring, etc must be provisioned. DRP can reduce
complexity by providing a mechanism for allowing service providers to self-register and dynamically routing
resource requests.## Goals
* Reduce barriers between resources and consumers
* Minimize infrastructure component requirements
* Reduce complexity involved in implementing HA
* Provide mechanism for resource discovery and structure traversal## Components
**Registries** - Track and distribute state of providers and their resources
**Providers** - Declare services, objects and streams available for consumption
**Brokers** - Process resource requests and track declarations from consumers
**Consumers** - Client facing applications, monitoring and analytics## Demo
Checkout repo, change to directory. Execute the following to start a demo service which provides the Registry, Provider and Broker routes on ws://localhost:8080
```
npm install
node server.js
```## Sample Provider
This sample will start a Provider which listens on ws://localhost:8081/provider and connects to the Registry on ws://localhost:8080/registry
```
node testProvider.js
```
## Sample Provider - No Listener
This sample will start a Provider which does not listen for connections; it connects directly to Brokers who need it
```
node testProvider-NoListener.js
```## Sample Client
This sample will start a Consumer which connects to the Broker on ws://localhost:8080/broker and subscribes to the dummy stream
```
node testClient.js
```## Web UI
Running server.js will also start the rSage web interface on http://localhost:8080 which connects to the Broker on ws://localhost:8080/broker. Click Go -> Command Testing to see the commands exposed to DRP Consumers.
* **getCmds** - List DRP Consumer commands
* **getRegistry** - Get dump of Registry
* **listServiceInstances** - List Services and which Providers offer them
* ... more ....## PowerShell PSDrive
Navigate the DRP topology via CLI using the DRPDrive.dll module. Open a PowerShell session and run the following.
```
cd PSDrive\bin\Debug
Import-Module .\DRPDrive.dll
Connect-DRP -Alias dev -URL ws://localhost:8080/broker
dir drp:\dev
dir drp:\dev\Registry
dir drp:\dev\Providers# View last 10 messages in a topic
dir drp:\dev\Providers\{providerID}\Streams\dummy\History# Execute a service command
gi drp:\dev\Services\Greeter\ClientCmds\sayHi# View list of Consumers
dir drp:\dev\Consumers# Retrieve HTML document from a consumer web session for debugging
gi drp:\dev\Consumers\{id}\HTMLDocument\children\0\outerHTML# Execute a command on the consumer web session to RickRoll the user
gi drp:\dev\Consumers\{id}\RickRoll
```## Stream Subscription
```mermaid
sequenceDiagram
participant Provider
participant Registry
participant Broker
Note left of Provider: Startup
Provider-->>Registry: ws:///registry
Broker-->>Registry: ws:///registry
Broker->>Registry: {cmd:"getDeclarations",token:1}
Note right of Registry: *Gather Declarations
Registry->>Broker: {token:1, payload: {streams:["hostReport"]}}}
Note left of Consumer: Startup
Consumer-->>Broker: ws:///broker
Consumer->>Broker: {"type":"cmd","method":"subscribe","params":{"topicName":"hostReport","streamToken":123}}
Note right of Broker: *Register subscription
*Determine list of providers
Broker-->>Provider: ws:///provider
Broker->>Provider: {"type":"cmd","method":"subscribe","params":{"topicName":"hostReport","streamToken":123}}
Note right of Provider: Stream Data
Provider->>Broker: {"type":"stream", token:123, status, payload: }
Note right of Broker: Relay to
Consumers
Broker->>Consumer: {"type":"stream", token:123, status, payload: }
```## Stream Subscription (Provider behind firewall or not listening)
```mermaid
sequenceDiagram
participant Provider
participant Registry
participant Broker
Note left of Provider: Startup
Provider-->>Registry: ws:///registry
Broker-->>Registry: ws:///registry
Broker->>Registry: {cmd:"getDeclarations",token:1}
Note right of Registry: *Gather Declarations
Registry->>Broker: {token:1, payload: {streams:["hostReport"]}}}
Note left of Consumer: Startup
Consumer-->>Broker: ws:///broker
Consumer->>Broker: {"type":"cmd","method":"subscribe","params":{"topicName":"hostReport","streamToken":123}}
Note right of Broker: *Register subscription
*Determine list of providers
Broker->>Registry: {"type":"cmd","method":"brokerToProvider","params":{"brokerID":,"brokerURL":"ws:///broker"}}
Registry->>Provider: {"type":"cmd","method":"brokerToProvider","params":{"brokerID":,"brokerURL":"ws:///broker"}}
Provider-->>Broker: ws:///broker
Broker->>Provider: {"type":"cmd","method":"subscribe","params":{"topicName":"hostReport","streamToken":123}}
Note right of Provider: Stream Data
Provider->>Broker: {"type":"stream", token:123, status, payload: }
Note right of Broker: Relay to
Consumers
Broker->>Consumer: {"type":"stream", token:123, status, payload: }
```