Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
nats-micro
Advanced tools
A convenient microservice library based on NATS and compatible with nats-go microservices
This is a typescript-first library that provides a convinient (in 10 lines of code or less!) way to write microservises with out of the box auto discovery, observability and load balancing.
Full interoperability with to-be-released nastcli v0.0.36
that adds nats micro info
, nats micro stats
and nats micro ping
commands
It also supports service schema discovery which is not (yet?) supported by nats micro
When you send a message you will be getting exactly one response (or a timeout error)
It is extremely simple:
const broker = await new Broker('echo' + process.pid).connect();
await Microservice.create(
broker,
{
name: 'echo',
description: 'Simple echo microservice',
version: '0.0.1',
methods: {
say: {
handler: (text) => text,
// subject is autogenerated according to nats micro protocol
},
'config-change-event': {
handler: console.log,
// subject is manually specified which allows for broadcast
// event bus
subject: '$EVT.config.change',
},
},
}
);
class EchoMicroservice {
public get config(): MicroserviceConfig {
return {
name: 'echo',
description: 'Simple echo microservice',
version: '0.0.1',
methods: {
say: { handler: this.say },
'config-change-event': { handler: this.onConfigChange },
},
};
}
private say(text: string): string {
return text;
}
private onConfigChange(change: unknown): void {
console.log(change);
}
}
const echoMicroservice = new EchoMicroservice();
const broker = await new Broker('echo' + process.pid).connect();
await Microservice.create(broker, echoMicroservice.config);
@microservice({ name: 'echo', description: 'Decorated service' })
// @microservice() // as simple as this
export default class EchoMicroservice {
// name is manual, subject is autodetected
@method({name: 'say'})
private reply(text: string): string {
return text;
}
// name is autodetected as 'config-change-event', subject is manual
@method({ subject: '$EVT.config.change' })
private configChangeEvent(change: unknown): void {
console.log(change);
}
}
const echoMicroservice = new EchoMicroservice();
const broker = await new Broker('echo' + process.pid).connect();
await Microservice.createFromClass(broker, echoMicroservice);
FAQs
NATS micro compatible extra-lightweight microservice library
The npm package nats-micro receives a total of 432 weekly downloads. As such, nats-micro popularity was classified as not popular.
We found that nats-micro demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.