Kitoo-Core
What Is Kitoo-Core
kitoo-core is service based on zeronode, for creating server to server communication.
How To Install
For library usage.
npm install kitoo-core
And For kitooc-core cli usage.
npm install -g kitoo-core
API
Basic Concepts
There is two basic concepts in kitoo-core, Network
and Router
. Network
service connects to Routers and communicates to other
Network
services through Routers
. In other end Routers
are just connecting together Ntworks
.
We will call Existing Network
to already connected Routers
an Networks
. So all Routers
in Existing Network
mus be connected to
All Networks
.
Router
new Router()
router.start()
router.stop()
router.connectExistingNetwork()
router.defineLoadBalancingStrategy()
router.tickToService()
router.tickAnyService()
router.tickAllServices()
router.requestToService()
router.requestAnyService()
router.onTick()
router.offTick()
router.onRequest()
router.offRequest()
Network
new Network()
router.start()
router.stop()
router.connectRouter()
router.disconnectRouter()
router.addRouter()
router.removeRouter()
router.proxyTick()
router.proxyTickAny()
router.proxyTickAll()
router.proxyRequestAny()
router.proxyRequest()
router.tickToRouter()
router.tickAnyRouter()
router.tickAllRouters()
router.requestToRouter()
router.requestAnyRouter()
router.onTick()
router.offTick()
router.onRequest()
router.offRequest()
router.subscribe()
router.publish()
router.getRoutingInterface()
router.getService()
Router Service
Router Service connects all network services to each other.
Network Service
Network Service can send and get messages from other services. Network Services can send messages to other Network Services via Router Service.
All network Services must be connected to All Router Services.
Usage Example
router.js
{ try let router = bind: 'tcp:://127.0.0.1:3000' ; await routerstart; console catch err console };
service1.js
{ try let network = name: 'foo' routers: 'tcp://127.0.0.1:3000' await networkstart; console; network catch err console }
service2.js
{ try let network = name: 'bar' routers: 'tcp://127.0.0.1:3000' await networkstart; console; let service1 = network; service1 catch err console }
#terminal 1 $ babel-node router.jsrouter started #terminal 2 $ babel-node service1.jsservice1 startedgot message on baz event: Hi service1, I am service2. #terminal 3 $ babel-node service2.jsservice2 started