avencera / moleculer-rs Goto Github PK
View Code? Open in Web Editor NEW๐ Progressive microservices framework for Rust, based on and compatible with moleculerjs/moleculer
License: Apache License 2.0
๐ Progressive microservices framework for Rust, based on and compatible with moleculerjs/moleculer
License: Apache License 2.0
//[PUB MOL.REQ.praveensmacbookpro.local-39536 311]
request = {
"action": "greeter.welcome",
"caller": nil,
"id": "f880a296-67cc-4c2d-857c-b015cf875dac",
"level": 1,
"meta": {"$repl": true},
"params": {"name": "Praveen"},
"parentID": nil,
"requestID": "f880a296-67cc-4c2d-857c-b015cf875dac",
"sender": "cli-praveensmacbookpro.local-39040",
"stream": false,
"timeout": 0,
"tracing": nil,
"ver": "4"
}
// [PUB MOL.RES.cli-praveensmacbookpro.local-39040 160]
response =
{
"data": "Welcome, Praveen",
"id": "f880a296-67cc-4c2d-857c-b015cf875dac",
"meta": {"$repl": true},
"sender": "praveensmacbookpro.local-39536",
"success": true,
"ver": "4"
}
Hey, I am just trying to port (I guess) some moleculer service from Javascript, granted I know just a basics in Rust and in general I am below the 10k lines ever written, so pardon if the question is stupid.
However in the moleculer-js, you can assing certain parameters to context
https://moleculer.services/docs/0.14/context.html
it does not appear to be the case in your Rust implementation, I know that due to borrow checker, this might not be possible, especially with tokio threading.
But I would still like to ask if I could get some assistance how to do this:
I have this piece of code:
broker.createService({
name: config.id,
mixins: [Request],
dependencies: ['blockchainRegistry', 'paymentGateway'],
events: {
ping: {
handler(ctx) {
const nowTime = new Date().getTime();
const delay = nowTime - ctx.params.datetime;
return ctx.broadcast('pong', { service_prefix: ctx.name, datetime: nowTime, delay });
},
},
"currency.created": {
async handler(ctx) {
ctx.options.coin = await ctx.call('paymentGateway.getPICoin', {paymentInterfaceId: config.id});
}
}
},
actions,
created() {
this.broker.metrics.register({
type: "info",
name: "process.converter.version",
description: "Converter version",
});
this.broker.metrics.set("process.converter.version", packageJSON.version)
},
async started() {
console.log('STARTED+++++');
const _self = this;
},
stopped() {
console.log("=>>>>>>>>>>>> BROKER STOPPED");
//broker.call('blockchainRegistry.unregister', {});
}
});
I figure out most of it, but the currency.created
event is beyond my knowledge, since global variables is tricky think to do, do you know any way, how could I store the info, which should go to ctx.options.coin?
Thanks and sorry for being newbie.
TODO:
TODO:
Other languages reference: moleculerjs/moleculer#347
Protocol reference: https://github.com/moleculer-framework/protocol/blob/master/4.0/PROTOCOL.md
docs: https://moleculer.services/docs/0.14/configuration.html
implemented in: #9
Easy:
MOL.HEARTBEAT
MOL.DISCONNECT
MOL.PING
MOL.PING.<nodeID>
MOL.PONG.<nodeID>
Medium:
MOL.DISCOVER
MOL.DISCOVER.<nodeID>
MOL.INFO
MOL.INFO.<nodeID>
Later:
Handle received messages
HEARTBEAT
DISCONNECT
INFO
INFO TARGETED
Should be a combination of all the other examples and should:
OnceCell
emit
, broadcast
and call
Use rust doc to generate from comments
Published at: https://crates.io/moleculer
TODO:
Registry
CircuitBreaker
Bulkhead
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.