GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - github1/meshage: A simple service mesh. Messages sent within the service mesh can be consistently partitioned across members of the cluster.

BranchesTags
Open more actions menu

Latest commit

 

History

59 Commits
59 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.dockerignore
.dockerignore
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.tool-versions
.tool-versions
 
 
.travis.yml
.travis.yml
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
index.ts
index.ts
 
 
jest.config.js
jest.config.js
 
 
jestGlobalSetup.js
jestGlobalSetup.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
prepare.sh
prepare.sh
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.release.json
tsconfig.release.json
 
 
tslint.json
tslint.json
 
 

Repository files navigation

meshage

A simple service mesh. Messages sent within the service mesh can be consistently partitioned across members of the cluster.

build status npm version npm downloads

Install

npm install meshage --save

Usage

Initialize some nodes and define a handler for a subject & message:

const {mesh, nats} from 'meshage';
const n1 = mesh(nats('nats://localhost:4222'));

await n1.subject('something')
    .on(SomeMessage, (message: SomeMessage) => {
        return 'reply';
    })
    .awaitRegistration();

const reply = await mesh(nats('nats://localhost:4222'))
    .subject('something')
    .send(new SomeMessage(), {
        wait: true | false, // Whether to wait for a reply or just fire the message.
        timeout: 1000 // Time in milliseconds to wait for a reply.
    });

Nats Support

To enable consistent hashing / partitioned message support one node in the "cluster" should be configured with the monitorUrl for the nats servers where subscription information can be obtained from. This will cause the node to periodically broadcast subscription data used to consistently hash & partition requests:

const n1 = mesh(nats({
    server: 'nats://localhost:4222',
    monitorUrl: 'http://localhost:8222'
}));

HTTP Support

Messages may also optionally be sent & received with an HTTP listener by wrapping the supplied backend:

const {mesh, nats, http} from 'meshage';
const n1 = mesh(http(nats('nats://localhost:4222'), 8080));
n1.subject('something')
    .on(SomeMessage, (message: SomeMessage) => {
        return 'reply';
    });

HTTP API

Send

Sends a message to be handled by a registered handler for the specified subject/message.

Path : /api/:subject/:partitionKey?

Path params :

  • subject - The logical name for the message handler subject.
  • partitionKey - (Optional) Identifier used to consistently partition the request to known handlers.

Query params:

  • messageName - (Dependant) The name of message. If the messageName is not supplied via this param, then it must be provided in the message body as a top-level key called name - e.g. {"name": "SomeMessage", ...}
  • wait - (Optional) Whether to wait for a reply or just fire the message.
  • timeout - (Optional) Time in milliseconds to wait for a reply.

Example:

Request:

curl -sX POST http://localhost:8080/api/some-subject/$RANDOM?messageName=echo \
     -H 'Content-Type: application/json' \
     -d '{"hello":"world"}'

Response:

{
  "echoed": {
    "hello": "world"
  }
}

Broadcast

Sends a message to all registered handlers for the specified subject/name pair.

URL : /api/broadcast/:subject

Path params :

  • subject - The logical name for the message handler subject.

Query params:

  • messageName - (Dependant) The name of message. If the messageName is not supplied via this param, then it must be provided in the message body as a top-level key called name - e.g. {"name": "SomeMessage", ...}
  • wait - (Optional) Whether to wait for a reply or just fire the message.
  • timeout - (Optional) Time in milliseconds to wait for replies. Replies not received before the timeout of omitted.

Example :

Request:

curl -sX POST http://localhost:8080/api/broadcast/some-subject?messageName=echo \
     -H 'Content-Type: application/json' \
     -d '{"hello":"world"}'

Response:

[
 {
   "echoed": {
     "hello": "world"
   }
 }, 
 {
   "echoed": {
     "hello": "world"
   }
 }
]

License

MIT

About

A simple service mesh. Messages sent within the service mesh can be consistently partitioned across members of the cluster.

Topics

clustermessage-handler

Resources

Readme
MIT license
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.