0.1.19 • Published 5 years ago

worker-boss v0.1.19

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

worker-boss

a lib for nodejs to create multy process and still have a good feeling

how to install

npm install worker-boss

why we use this

  • convenien way to create multy process
  • less cost to send message to another process

boss.init(cluster_id)

the first process must use this method to tell what the cluster id is

const boss = require("worker-boss")

await boss.init(1)

boss.new_worker(file,...args)

creat a new worker that is running in another process

let id = await boss.new_worker("./example/test_service_step.js",1,2,3)

boss.invoke_worker(target_worker,func_name,...args)

do a remote invoke to the target_worker,and the target worker must regist a callback

boss.invoke_worker(id, "test_123")

boss.call_worker(target_worker,func_name,...args)

do a rpc to the target_worker,and the target worker must regist a callback

let ret = await boss.call_worker(id, "test_123", false)
console.log(`get result:${ret}`)

boss.on_invoke(function (func_name, ...args){...})

regist invoke callback

boss.on_invoke(function (func_name, ...args)
{
    console.log(`get call:${func_name}(${args})`)
    return args
})

boss.on_call(function (func_name, ...args){})

regist a rpc callback

boss.on_call(function (func_name, ...args)
{
    console.log(`get call:${func_name}(${args})`)
    return args
})

full example

github

0.1.19

5 years ago

0.1.18

5 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago