TIL: Molecular JS
What is molecular
- Service: Simple JS module that contains a set of functions
- Node: An OS process that hosts one or many services
- ServiceBroker: Manages services & communication between them. One Service broker per node
- Molecular is transport independent, can be used with MQTT, TCP, Redis, NATS (Streaming too), Kafka
- Built in load balancing, fault tolerance mechanisms, validators, cache, health monitoring & metrics, dynamic service discovery & registry.
- every action receives
- actions are public functions that other services can call
- methods are private functions that are only available within the scope of said service
- services also have lifecycle handlers, ie
- molecular’s REPL can be pretty handy. used it to load a service, & testing it out too.
const ApiGateway = require("moleculer-web");
molecular-webis an http server, and it is then declared as a
mixinin this file.
- url pattern:
a class that contains methods for use by other classes without having to be the parent class of those other classes. How those other classes gain access to the mixin’s methods depends on the language. Mixins are sometimes described as being “included” rather than “inherited”.