Giter Club home page Giter Club logo

drp's Introduction

DRP

Declarative Resource Protocol - a JSON based Websocket subprotocol for declaring and consuming resources.

Overview

TLDR - It provides a relatively easy way to create a service mesh. It is intended to be used with infrastructure services.

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 which allows services to self-register and dynamically routes resource requests.

Mesh solutions such as Istio are very powerful, but tend to have a steep learning curve and can be tricky to set up. DRP can be thought of as a way to create a "beginner's" mesh. With the provided samples, anyone with some Node.js experience should be able to set up a mesh and create a service in a short amount of time.

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

Mesh Components

Name Description
Node Process which communicates using the DRP protocol; has one or more roles
Service Logical unit consisting of RPC methods, streams, object class definitions & object instances
Consumer Web page, script, PowerShell client, etc which makes calls to Broker Nodes

Node Roles

Name Description
Registry Node which tracks and distributes state of other nodes and services
Provider Node which offers services for consumption
Broker Node which processes resource requests and tracks declarations from consumers
Logger Node which subscribes to streams (RESTLogs, etc) and writes them to a database

Demo

The public demo is hosted at https://rsage.io. To run it on your own system, either grab the Docker container or clone this repo.

Option 1: Docker Container

docker pull adhdtech/drp-nodejs
docker create --name drp-demo -p 8080:8080 -e "PORT=8080" -e "HOSTNAME=localhost" adhdtech/drp-nodejs
docker start drp-demo

Option 2: Git Clone

git clone https://github.com/adhdtech/DRP.git DRP

Checkout repo, change to directory. Execute the following to start a demo node with the Registry and Broker roles on ws://localhost:8080

cd DRP-nodejs
npm install
node server.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.

DRP Topology Viewer

In the rSage web interface on http://localhost:8080, Click Go -> DRP Topology to see a map of all nodes currently connected to the mesh. The direction as well as current latency and uptime for each connection is displayed.

Here is an example from the public demo site.

Topology

Command Testing

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 ....

CommandTesting

PowerShell PSDrive

You can navigate the DRP topology via CLI using the DRPDrive.dll module. After cloning the repo, execute the following to connect to the local DRP Broker.

# Load PowerShell Provider
cd DRP-dotnet\bin\Debug
Import-Module .\DRPDrive.dll

# Connect to local DRP Broker
Connect-DRP -Alias local -URL ws://localhost:8080

# Connect to public DRP Broker (optional)
Connect-DRP -Alias public -URL wss://rsage.io:8443

Now we can poke around and see some of the information available in the mesh.

# Dump the Mesh registry
gi drp:\local\Mesh\Registry

# List Services available in Mesh
dir drp:\local\Mesh\Services

# Execute a service command
gi drp:\local\Mesh\Services\JSONDocMgr\ClientCmds\listFiles

# List Streams available in Mesh
dir drp:\local\Mesh\Streams

# Retrieve last 10 messages sent to a stream
gi drp:\local\Mesh\Streams\RESTLogs\{nodeID}\History

# View list of attached Nodes & Consumers
dir drp:\local\Endpoints\Nodes
dir drp:\local\Endpoints\Consumers

# Dump the Mesh Topology
gi drp:\local\NodeObj\RouteHandler\EndpointCmds\getTopology

# Retrieve HTML document from a consumer web session for debugging
gi drp:\local\Endpoints\Consumers\{consumerID}\HTMLDocument\children\0\outerHTML

# Execute a command on the consumer web session to RickRoll the user
gi drp:\local\Endpoints\Consumers\{consumerID}\RickRoll

Sample Provider

This starts a non-listening sample Provider which connects to Brokers who need to communicate with it

node drpProvider-Test-NoListener.js

Let's take a look at the relevant code. In these samples we're creating a simple test service and advertising it to the mesh.

TestServiceCode

Now let's test the new service

Client Output
Web UI GreeterTest
REST GreeterTestPS
PowerShell GreeterTestPS

Sample Consumer

This sample will start a Consumer which connects to the Broker on ws://localhost:8080 and subscribes to the dummy stream

node drpConsumer.js

Stream Subscription

StreamSub1

Stream Subscription (Provider behind firewall or not listening)

StreamSub2

drp's People

Contributors

adhdtech avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

drp's Issues

Add Registry Cluster Support

Currently the mesh only supports a single registry instance and each node must supply that registry's full URL to connect to it. An option needs to be added so that nodes can be given a domain name and do a DNS SRV lookup (similar to Active Directory domain controllers). Registry nodes will use this to form a full mesh; all other nodes should connect to the nearest registry node.

Initially, the nearest registry node will be found by pinging all registry nodes. Whichever one yields the lowest average response time after a few pings will be selected. Maybe apply the same logic to service selection. Will come up with something more elegant later.

pathCmd not working

When a consumer sends a pathCmd to a Broker that requires a call to a Provider, the call to the Provider is failing. Due to recent class merge.

Append AuthInfo to Consumer Service Requests

When a Consumer makes a service request, the ConsumerEndpoint's AuthInfo object should be attached to the request by default. The target service can perform authorization based on this.

Make DRP Service available via PSDrive

Need to make the DRP Service visible via PSDrive on each Node. The DRP service should never be advertised by any Node since it's present by default on all Nodes.

Example:
PS C:\Temp> gi drp:\local\Services\DRP\ClientCmds\getTopology > drpTopology.json

This should NOT work:
PS C:\Temp> gi drp:\local\Mesh\Services\DRP\ClientCmds\getTopology > drpTopology.json

DRP_Endpoint to wsConn should be 1 to 1

Adjust the DRP_RouteHandler so that instead of being a DRP_Endpoint itself, it creates a DRP_Endpoint for each wsConn and attaches the drpEndpoint attribute to each wsConn.

This way the drpEndpoint can be updated to expose different sets of commands to different endpoints.

Basic Security

Add commands to allow agents to authenticate via DRP. Developers should be able to route requests to their preferred authentication/authorization mechanism on the backend. LDAP, SQL, REST, etc.

PS Drive Broken

Last update caused PS Drive to stop working. Calls return immediate response without data.

Topology Viewer - services not showing

Need to update the TopologyTracker's GetRegistry function to allow the retrieval of all services records for a given host. This is needed to display each Node's services in the Topology Viewer, including those scoped "local".

Add function to Topology Tracker locate Service by Type

Nodes should have the option to either specify an Authentication source (as it is currently) or leave it empty and allow any Authentication source in the mesh to be used. There will be other use cases for this as well (logging).

VDM Command Testing broken

The VDM command testing was doing a pathCmd listing on \Services to get the service names and command list. This was broken due to a pair of changes:

  • Moving global service list from "Services" to "Mesh\Services"
  • The "Mesh\Services\{svcName}" path now list node names

Need to either:

  • Have the Command Testing app pull from the Registry OR
  • Drill down on "Mesh\Services\{svcName}\any\ClientCmds" for each service

Authenticate REST requests

Need to require user/pass or token for REST requests. Like the VDM, these should be authenticated using the Broker Node's Authenticate function.

Nodes registering to Brokers

If a node connects to a Broker without the Registry role, it's effectively a dead node. The Broker accepts the registration but it doesn't get relayed to the registry.

Options:

  1. Redirect - Brokers reply back to the client with the URL of the Registry
  2. Routing - Brokers can advertise routes to nodes behind them
  3. Proxy - Services registered through the Broker get added to the Broker's declaration

SentMessages counter on Topics not incrementing

First observed on a non-listening provider. A consumer with a global sub through a broker is receiving messages, but the SentMessages value on the topic remains at 0. Also checked topics on the broker and registry node. None seem to incrementing.

Add debug flag

Add debug flag to DRP_Node class to enable output for topology updates, etc

Fix TestClient.js

The test client hasn't been updated since the node class merge. Need to update.

Provider Removal Bug

When a remote provider disconnects from the public test site, it's not removed from the broker

Grace period after Registry disconnect

When a Node becomes disconnected from a Registry host, it should not automatically purge the records learned from that host. Instead it should do the following.

  • Mark records from old Registry as stale
  • Attempt to connect to another Registry
  • On success, the stale records should be overwritten
  • Delete any remaining stale records

Command relay

Add command relay support using new base parameter in cmd object

Stream unsubscribe not working

Stream unsubscribe function not working for Consumer clients. First noticed after the most recent restructuring.

Need to see if this affects Node clients as well.

VDM Client - Resubscribe on reconnect

When a VDM client is disconnected from a broker, it will automatically reconnect but not automatically subscribe to the streams it had on disconnect. This should be corrected.

Stream subscription dedupe

When multiple Consumers subscribe to a topic through a Broker, multiple streams are established from the Broker to the Provider. This should be updated so that the Broker only subscribes to the Provider once.

Implement zoning

Allow nodes to be grouped by zones. Advertisements and calls should be able to be prioritized or restricted by zones.

Double subscription bug

If a broker is cycled, consumers seem to be getting an extra copy of streaming data they've subscribed to.

Duplicate back requests on Providers

If a Provider receives multiple back requests before the first one is complete, it will attempt multiple. Need to update so that if a Provider is currently attempting a back request to a Broker, it will not attempt another.

Add Service status and dependency fields

Currently, if service A relies on service B and the latter isn't available, service A will simply terminate.

Need to add functionality so services can declare their dependencies and, in the absence or loss of dependencies, will enter a pending state. Once the requirements are fulfilled, the service will go ready.

Stale Node & Service cleanup

Need to implement a function that will periodically crawl the mesh and check for stale Node & Service entries.

Non-Listening Node Reconnect Problem

Found that if a non-listening node connects to listening node and has to re-connect, it will not do so because the listening node is still present in the non-listening node's NodeEndpoints hash.

The listening node will send a callback request via the registry, but the non-listening node will decline to make the attempt because it think's it's already connected.

FIX 1 - Update the DRP_NodeClient.CloseHandler function to remove the stale entry from the NodeObj.NodeEndpoints hash.

FIX 2- Update the DRP_Node.ConnectToNode function so that when it receives what it thinks is a duplicate back request, it checks to see if it is indeed has or is in the process of making a connection.

User Authentication via WebSockets

User authentication is currently supported by the VDM module (Basic Auth), but not directly in WebSockets Consumer connections. Need to add support for this.

Add Option for Mesh Security Token

Add option for a mesh security token to be provided when nodes connect to the mesh. Roughly analogous to an SNMP community string. Hate to even call this security, but it's better than nothing for now. Will add a more secure option later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.