Closed ccampanale closed 2 years ago
Hi @ccampanale
What's the REPL version that you're using?
we have the ability to connect into a pre-production running system (with all of our microservices running) to run our modified services locally.
I should be able to easily call the local node on which I am working without needing to copy and paste the node ID.
Can you please clarify how do you enter into REPL mode? Do you start (e.g., npm run dev
) a ServiceBroker instance, with the services that you're working on, with REPL mode enabled? Or do you connect to the entire system via CLI (e.g., moleculer connect
)?
Hey @AndreMaz
We are currently on moleculer-repl@0.7.0
.
We have a highly customized startup process but it works a lot like the Moleculer runner; ultimately, if the right flags are set, etc. broker.repl();
is called in much the same way.
I'm mostly just curious if this is something you would be interested in as a feature of the dcall
command and if you have any preferences on approach. I would't mind writing a PR when I get a chance.
Sorry, to better answer your questions:
moleculer connect
in both form and function (just with some extra bells and whistle for our system).npm run dev
) and is generally done to test changes locally. But often, the service instances locally, while sharing the same name as instances available on other nodes in the running system, is different do to local changes. This is where it would be convenient to be able to dcall local <action> <payload>
or dcall <action> <payload> --local
without needing to copy and paste the current Node ID (which changes with each new run).But often, the service instances locally, while sharing the same name as instances available on other nodes in the running system, is different do to local changes. This is where it would be convenient to be able to dcall local
or dcall --local without needing to copy and paste the current Node ID (which changes with each new run).
Sorry, I’m a bit tired (and slow) at the moment.
What if you set the preferLocal
to true
in registry opts of the ServiceBroker that contains local services and runs your REPL instance? With this option the call
command should call local actions (the ones that you want to trigger).
Again, sorry if I misunderstood your scenario.
No worries - this is not urgent so pleas take your time.
That's a great point and could certainly be done of the fly if needed.
I could always leverage preferLocal
with something custom too if need be. I was originally going to shoe-horn the feature in via our custom work (possibly a custom REPL command, of which we have a few already) but figured I'd touch base with the maintainers first.
That said, I do believe that flexibility in the REPL CLI commands would be a great UX. But perhaps this doesn't align well with the intentions of the maintainers.
I think in dcall
the nodeID
can't be optional because actionName
is followed which is required. So I think the --local
option can be good. Could you create a PR?
@icebob
I agree - I think the complexity in trying to support nodeID
as an optional argument is reason enough to avoid that path.
That being said, it sounds like adding --local
to call
might make more sense than adding to dcall
as --local
would be confusing while still needing to provide something for nodeID
.
I can create a PR and send it over as soon as I get a chance to write it up and we can take it from there. Thanks!
I agree, thanks!
Description: Frequently, rather than roll out entirely new service versions, I and my team tend to address bugs or certain changes in existing services which are subsequently built and deployed. When developing locally, we have the ability to connect into a pre-production running system (with all of our microservices running) to run our modified services locally. To test changes, for example to an action, we would simply perform a directed call to the local node for the service/action. I find myself needing to do a lot of repetitive copy & pasting in order to
dcall
the local node rather than the older instances of similarly named services running in the system.User story: As a developer using the Moleculer REPL console, I should be able to easily call the local node on which I am working without needing to copy and paste the node ID.
Examples: I can think of a few ways this could be done, assuming this is a feature you believe is worth implementing.
Example 1 -
<nodeId>
keywords:One or more keywords (such as
local
ormlocal
) could be provided as the<nodeId>
fordcall
and when detected, the broker instance provided to the REPL command would be used to determine the target node ID.dcall local v1.service.action --param1 value
Pros: simple Cons: potential for overlap if a node in the system is already named "local".
Example 2 -
--local
optionAn additional flag could be used which, when set, would allow for the
<nodeId>
argument to beundefined
and would instead use the broker instance provided to the REPL command to determine the target node ID.Pros: simple and avoid potential overlaps with node names in the system (from example 1) Cons: May introduce complexity with arguments and differentiating between the
<nodeID>
and<service/action>
arguments since an option flag would be set but the<nodeId>
argument not provided.There may be other options to which I have not highlighted but ultimately something which simplifies
dcall
s to local nodes would be very helpful, I think.I see pretty clearly where/how this change could be incorporated into the code, but didn't want to bother with a PR yet until I was sure this was both something you'd be willing to incorporate and got feedback on a desired approach.
Please let me know what you think.