moleculer-go / moleculer

๐Ÿš€ Progressive microservices framework for Go - based and compatible with https://github.com/moleculerjs/moleculer
MIT License
144 stars 27 forks source link

Moleculer JS compatibility #55

Closed pentateu closed 5 years ago

pentateu commented 5 years ago

@dehypnosis had the following issues while trying to integrate with Moleculer JS.

Current moleculer-go seems that has not exactly same protocol with moelculer-js. For example, moelculer-go discovers remote actions as []interfaces{} type assertion, but moleculer-js services reply as map[string]interfaces{}. And there are some issues while discovering, and call each others between different moleculer client library.

pentateu commented 5 years ago

@dehypnosis do you have a sample project that I can use to test and fix the issues between JS and Go services ? if not is fine, I just want to check before I start to avoid duplication of work.. in case u had one.

dehypnosis commented 5 years ago

@pentateu i made a PR!

dehypnosis commented 5 years ago

im sorry for i cannot provide moleculerjs thing for you. all of them are properties of the company and i quit the job few days ago. but here is a molecuker-go project which has been made after i quit the job and includes no credential information.

https://github.com/strix-kr/mol-weather

but will be turned to private soon.

pentateu commented 5 years ago

merged on version v0.1.1

dehypnosis commented 5 years ago

Hey @pentateu, thanks for your hard works.

I found ./version/version.go has not been updated for new release. And HeartbeatFrequency user option seems not overriding default configuration.

I have applied your new release, but found some networking problem. With default configuration and NATS transporter, moleculer-go marks remote moleculer-js nodes as disconnected right after discovery.

disconnection from moleculer-go

INFO[0000] Moleculer is starting...                      broker=imac.local-jrSGs
INFO[0000] Node ID: imac.local-jrSGs                     broker=imac.local-jrSGs
INFO[0000] Transporter: NatsTransporter                  Transit= broker=imac.local-jrSGs
INFO[0000] Connected to nats://dev.nats.svc.cluster.local:4222  Transit= broker=imac.local-jrSGs transport=nats
INFO[0000] Registry - remote $node service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0000] Registry - remote pm service is registered.   broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0000] Registry - remote pm.auth service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0000] Registry - remote pm.user service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0000] Registry - remote pm.kepco service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - $node service is registered.       broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - weather service is registered.     broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Service Broker with 2 service(s) started successfully.  broker=imac.local-jrSGs
INFO[0001] weather service has been stared               action=service.start broker=imac.local-jrSGs
INFO[0001] Registry - remote $node service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote iam.admin service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote iam service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote iam.user service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote $node service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote weather service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote $node service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote hello service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote $node service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.agencies service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.alarms service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.bids service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.brokers service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.efficiencies service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.forecasts service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.generations service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.generators service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.groups service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade.plants service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0001] Registry - remote trade service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote $node service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote api.graphql service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote api.guard service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote api.catalog service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote api.document service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote api.i18n service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote api service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote file service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote $node service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote $node service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs

(omitted...)

INFO[0002] Registry - remote trade.groups service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote trade.plants service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
INFO[0002] Registry - remote trade service is registered.  broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node mol-weather-869cddb868-wrcbt-82677 disconnected   broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node mol-template-ts-5f845f87b6-tnrf2-15 disconnected   broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node peak-manager-api-56c6796f5c-89456-1 disconnected   broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node cli-imac.local-90559 disconnected        broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node eunjus-imac.local-46756 disconnected     broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node eunjus-imac.local-46968 disconnected     broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node mol-iam-75dffc6c45-876v6-21 disconnected   broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node trade-sc-server-6b86d8ff-cf24d-21 disconnected   broker=imac.local-jrSGs registry=imac.local-jrSGs
WARN[0031] Node mol-api-5f885d4bc8-9zqph-21 disconnected   broker=imac.local-jrSGs registry=imac.local-jrSGs

Also I tried to call moleculer-go from moleculer-js (moleculer-cli REPL), but moleculer-go continues to be connected and disconnected repeatedly. I guess heartbeat is not working correctly.

moleculer-cli displays reconnecting moleculer-go logs

mol $ nodes
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ Node ID                             โ”‚ Services โ”‚ Version โ”‚ Client       โ”‚ IP                   โ”‚    State โ”‚ CPU                        โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ cli-imac.local-90559 (*)            โ”‚ 1        โ”‚  0.13.8 โ”‚ nodejs       โ”‚ 222.107.184.34  (+1) โ”‚  ONLINE  โ”‚ [....................] 2%  โ•‘
โ•‘ eunjus-imac.local-46756             โ”‚ 8        โ”‚  0.13.7 โ”‚ nodejs       โ”‚ 192.168.2.214        โ”‚  ONLINE  โ”‚ [โ– โ– ..................] 9%  โ•‘
โ•‘ eunjus-imac.local-46968             โ”‚ 12       โ”‚  0.13.8 โ”‚ nodejs       โ”‚ 192.168.2.214        โ”‚  ONLINE  โ”‚ [โ– โ– ..................] 11% โ•‘
โ•‘ imac.local-jrSGs                    โ”‚ 2        โ”‚   0.1.0 โ”‚ moleculer-go โ”‚ 222.107.184.34  (+1) โ”‚  ONLINE  โ”‚ ?                          โ•‘
โ•‘ mol-api-5f885d4bc8-9zqph-21         โ”‚ 8        โ”‚  0.13.7 โ”‚ nodejs       โ”‚ 10.20.7.99           โ”‚  ONLINE  โ”‚ [โ– ...................] 5%  โ•‘
โ•‘ mol-iam-75dffc6c45-876v6-21         โ”‚ 4        โ”‚  0.13.7 โ”‚ nodejs       โ”‚ 10.20.6.148          โ”‚  ONLINE  โ”‚ [โ– ...................] 6%  โ•‘
โ•‘ mol-template-ts-5f845f87b6-tnrf2-15 โ”‚ 2        โ”‚  0.13.8 โ”‚ nodejs       โ”‚ 10.20.2.92           โ”‚  ONLINE  โ”‚ [โ– โ– ..................] 10% โ•‘
โ•‘ mol-weather-869cddb868-wrcbt-82677  โ”‚ 2        โ”‚   0.1.0 โ”‚ moleculer-go โ”‚ 10.20.6.190          โ”‚  ONLINE  โ”‚ [....................] 0%  โ•‘
โ•‘ peak-manager-api-56c6796f5c-89456-1 โ”‚ 5        โ”‚  0.13.8 โ”‚ nodejs       โ”‚ 10.20.0.2            โ”‚  ONLINE  โ”‚ [โ– โ– โ– .................] 14% โ•‘
โ•‘ trade-sc-server-6b86d8ff-cf24d-21   โ”‚ 12       โ”‚  0.13.8 โ”‚ nodejs       โ”‚ 10.20.2.167          โ”‚  ONLINE  โ”‚ [โ– โ– โ– .................] 15% โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

mol $ dcall imac.local-jrSGs $node.health
{ options: {},
  nodeID: 'imac.local-jrSGs',
  actionName: '$node.health' }
>> Call '$node.health' on imac.local-jrSGs with params: {}
[2019-05-07T11:33:47.202Z] WARN  cli-imac.local-90559/BROKER: Service '$node.health' is not found on 'imac.local-jrSGs' node.
>> ERROR: Service '$node.health' is not found on 'imac.local-jrSGs' node.
ServiceNotFoundError: Service '$node.health' is not found on 'imac.local-jrSGs' node.
    at ServiceBroker.findNextActionEndpoint (/usr/local/lib/node_modules/moleculer-cli/node_modules/moleculer/src/service-broker.js:840:13)
    at ServiceBroker.call (/usr/local/lib/node_modules/moleculer-cli/node_modules/moleculer/src/service-broker.js:876:25)
    at call (/usr/local/lib/node_modules/moleculer-cli/node_modules/moleculer-repl/src/commands/call.js:74:9)
    at CommandInstance.vorpal.command.option.option.option.allowUnknownOptions.action (/usr/local/lib/node_modules/moleculer-cli/node_modules/moleculer-repl/src/commands/call.js:138:27)
    at Session.session.execCommandSet (/usr/local/lib/node_modules/moleculer-cli/node_modules/vorpal/dist/session.js:470:20)
    at Vorpal.vorpal._exec (/usr/local/lib/node_modules/moleculer-cli/node_modules/vorpal/dist/vorpal.js:960:18)
    at Vorpal.vorpal._execQueueItem (/usr/local/lib/node_modules/moleculer-cli/node_modules/vorpal/dist/vorpal.js:751:17)
    at Vorpal.vorpal._queueHandler (/usr/local/lib/node_modules/moleculer-cli/node_modules/vorpal/dist/vorpal.js:735:10)
    at Vorpal.vorpal.exec (/usr/local/lib/node_modules/moleculer-cli/node_modules/vorpal/dist/vorpal.js:682:10)
    at /usr/local/lib/node_modules/moleculer-cli/node_modules/vorpal/dist/vorpal.js:625:10
    at module.exports.completed (/usr/local/lib/node_modules/moleculer-cli/node_modules/vorpal/dist/ui.js:220:13)
    at module.exports.PromptUI.onCompletion (/usr/local/lib/node_modules/moleculer-cli/node_modules/vorpal/node_modules/inquirer/lib/ui/prompt.js:57:10)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (/usr/local/lib/node_modules/moleculer-cli/node_modules/rx-lite/rx.lite.js:1550:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/usr/local/lib/node_modules/moleculer-cli/node_modules/rx-lite/rx.lite.js:1489:14)
    at Subject.onCompleted (/usr/local/lib/node_modules/moleculer-cli/node_modules/rx-lite/rx.lite.js:5871:19)
    at Subject.tryCatcher (/usr/local/lib/node_modules/moleculer-cli/node_modules/rx-lite/rx.lite.js:63:31)
Data:  { action: '$node.health', nodeID: 'imac.local-jrSGs' }
mol $ [2019-05-07T11:33:51.146Z] WARN  cli-imac.local-90559/REGISTRY: Heartbeat is not received from 'imac.local-jrSGs' node.
[2019-05-07T11:33:51.147Z] WARN  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' disconnected unexpectedly.
[2019-05-07T11:33:56.930Z] INFO  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' reconnected.
[2019-05-07T11:34:21.151Z] WARN  cli-imac.local-90559/REGISTRY: Heartbeat is not received from 'imac.local-jrSGs' node.
[2019-05-07T11:34:21.151Z] WARN  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' disconnected unexpectedly.
[2019-05-07T11:34:21.832Z] INFO  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' reconnected.
[2019-05-07T11:34:51.153Z] WARN  cli-imac.local-90559/REGISTRY: Heartbeat is not received from 'imac.local-jrSGs' node.
[2019-05-07T11:34:51.154Z] WARN  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' disconnected unexpectedly.
[2019-05-07T11:34:51.499Z] INFO  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' reconnected.
[2019-05-07T11:35:21.157Z] WARN  cli-imac.local-90559/REGISTRY: Heartbeat is not received from 'imac.local-jrSGs' node.
[2019-05-07T11:35:21.157Z] WARN  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' disconnected unexpectedly.
[2019-05-07T11:36:00.102Z] INFO  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' reconnected.
[2019-05-07T11:36:36.165Z] WARN  cli-imac.local-90559/REGISTRY: Heartbeat is not received from 'imac.local-jrSGs' node.
[2019-05-07T11:36:36.165Z] WARN  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' disconnected unexpectedly.
[2019-05-07T11:36:40.904Z] INFO  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' reconnected.
[2019-05-07T11:37:06.171Z] WARN  cli-imac.local-90559/REGISTRY: Heartbeat is not received from 'imac.local-jrSGs' node.
[2019-05-07T11:37:06.172Z] WARN  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' disconnected unexpectedly.
[2019-05-07T11:37:07.202Z] INFO  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' reconnected.
[2019-05-07T11:37:36.175Z] WARN  cli-imac.local-90559/REGISTRY: Heartbeat is not received from 'imac.local-jrSGs' node.
[2019-05-07T11:37:36.175Z] WARN  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' disconnected unexpectedly.
[2019-05-07T11:37:36.507Z] INFO  cli-imac.local-90559/REGISTRY: Node 'imac.local-jrSGs' reconnected.
...

I will drill down further into detail soon for more helpful report for you.

pentateu commented 5 years ago

Hi @dehypnosis good to hear that you started testing on it.

Did you find any more about this issue that helps us understand what is happening? Have you played with the heartbeat parameters to see if you can adjust by configuration only? I'll create a test that leaves for a couple of hours to monitor stability it is.