Easy install

Install with three docker commands (no further configuration required):

docker network create res
docker run -d --name nats -p 4222:4222 --net res nats
docker run --name resgate -p 8080:8080 --net res resgateio/resgate --nats nats://nats:4222

Serve resources

Write a service in the language of your choice:

const nats = require('nats')
nats.connect('nats://localhost:4222');

nats.subscribe('get.example.model', (req, reply) => {
	nats.publish(reply, JSON.stringify({ result: {
		model: { message: "Hello, World!" }
	}}));
});

Update the resource with an event:

nats.publish('event.example.model.change', JSON.stringify({
	values: { message: "Hello, Resgate!" }
}));

Get resources

Write a client that gets the resource and listens for updates:

let client = new ResClient('ws://localhost:8080');

client.get('example.model').then(model => {
	console.log(model.message); // Hello, World!
	model.on('change', () => {
		console.log("Updated!");
	});
});

Or access the resource using the REST API:

GET http://localhost:8080/api/example/model

Examples

Try out complete examples written in Javascript (Node.js), Go (golang), and C# (.NET Core).