Skip to content

Demo for the Piral Cloud micro frontend discovery service showing how a Fastify server could be made dynamic (esssentially your own FaaS).

Notifications You must be signed in to change notification settings

piral-samples/piral-cloud-ws-server-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Piral Logo

Sample project to illustrate a plugin discovery with a custom WebSocket server.

⚡ Use the Piral Feed Service for plugin discovery - creating an extensible reactive WebSocket server.

Feel free to play around with the code using StackBlitz.

Open in StackBlitz

Example Flow

Let's say you start a quick session:

const ws = new WebSocket('ws://localhost:3000');
ws.onmessage = (e) => {
  console.log(JSON.parse(e.data));
};
ws.send(JSON.stringify({ type: 'foo' })); // response will be from app1: "Hello from app1 v2: foo"
ws.send(JSON.stringify({ type: 'compute', a: 5, b: 8, correlationId: 'abcdef' })); ; // response will be from app2: -39 (incl. the correlationId)
ws.send(JSON.stringify({ type: 'list-documents' })); // also check out create-document and delete-document; they all come from app3

Only the type and correlationId fields are given. All others are dynamically passed to the command handlers.

License

Piral and this sample code is released using the MIT license. For more information see the license file.

About

Demo for the Piral Cloud micro frontend discovery service showing how a Fastify server could be made dynamic (esssentially your own FaaS).

Topics

Resources

Stars

Watchers

Forks