在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:moleculerjs/moleculer开源软件地址:https://github.com/moleculerjs/moleculer开源编程语言:JavaScript 99.6%开源软件介绍:MoleculerMoleculer is a fast, modern and powerful microservices framework for Node.js. It helps you to build efficient, reliable & scalable services. Moleculer provides many features for building and managing your microservices. Website: https://moleculer.services Documentation: https://moleculer.services/docs Top sponsorsWhat's included
Installation
or
Create your first microserviceThis example shows you how to create a small service with an const { ServiceBroker } = require("moleculer");
// Create a broker
const broker = new ServiceBroker();
// Create a service
broker.createService({
name: "math",
actions: {
add(ctx) {
return Number(ctx.params.a) + Number(ctx.params.b);
}
}
});
// Start broker
broker.start()
// Call service
.then(() => broker.call("math.add", { a: 5, b: 3 }))
.then(res => console.log("5 + 3 =", res))
.catch(err => console.error(`Error occurred! ${err.message}`)); Create a Moleculer projectUse the Moleculer CLI tool to create a new Moleculer based microservices project.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论