1.0.4 • Published 10 years ago

node-dispatcher v1.0.4

Weekly downloads
24
License
-
Repository
github
Last release
10 years ago

Dispatcher for Node.js

Author: Rudolph-Miller


  1. How to use

    Dispatcher = 'node-dispatcher'
    dispatcher = new Dispatcher
    dispatcher.use *id*, *function*
    
    if dispatcher.isMaster
    	dispatcher.fork()
    	dispatcher.pushQ *id*, *target*
    	dispatcher.on 'result', (message) -> message.result = *function*( *target* )
  2. Master

    1. Properties
      • isMaster -> if dispathcer is master return true else false.
      • isWorker -> if dispathcer is worker return true else false.
      • pid -> return pid of instance.
    2. Methods
      • fork() -> make instance of worker.
      • forks(n) -> make n instances of worker.
      • use(id, function) -> register id and function (typeof id is 'string').
      • pushQ(id, target) -> push id and target on Queue.
      • remove() -> exit all workers which is working.
    3. Events
      • on 'pullTask',(message) -> message.pid is the pid of worker which pull task.
      • on 'result', (message) -> message.result is result of task, message.task is task.
      • on 'workerStart', (message) -> message.pid is the pid of starting worker.
  3. Worker You can not customize Worker or touch on them, because Workers are precious for them and do not push everythig against them.

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago