## Modules
supertask-cluster
## Classes
supertask-cluster
## supertask-cluster - ### supertask-cluster~AddCallback : function **Kind**: inner typedef of [supertask-cluster](#module_supertask-cluster) | Param | Type | | --- | --- | | task | Object | - ## supertask-cluster **Kind**: global class * [supertask-cluster](#supertask-cluster) * [new SuperTaskCluster()](#new_supertask-cluster_new) * [.deploy(maxTotalWorkers)](#supertask-cluster+deploy) * [.addShared(name, source, callback)](#supertask-cluster+addShared) * [.getWorkers()](#supertask-cluster+getWorkers) ⇒ Object * [.totalWorkers()](#supertask-cluster+totalWorkers) ⇒ Number * [.setMaxWorkers(maxTotalWorkers)](#supertask-cluster+setMaxWorkers) * [.addWorkers(n)](#supertask-cluster+addWorkers) * [.killWorker(workerID, graceful, [callback])](#supertask-cluster+killWorker) * [.createBufferOnWorker(workerID, name, buffer, encoding, mutable, [chunky], [callback])](#supertask-cluster+createBufferOnWorker) * [.workerBufferReference(name)](#supertask-cluster+workerBufferReference) ⇒ Object * [.setClusterDebug(toggle)](#supertask-cluster+setClusterDebug) * [.clusterResponseTimeout([time])](#supertask-cluster+clusterResponseTimeout) ⇒ Number - ### new SuperTaskCluster() Creates new instance. **Returns**: Instance - Returns a new instance of the module. **Example** ```js Creating a new instance. var SuperTaskCluster = require('supertask-cluster'); var TaskCluster = new SuperTaskCluster(); ``` - ### supertask-cluster.deploy(maxTotalWorkers) Deploy/Redeploy workers based on the maximum number of workers. Use [SuperTaskCluster#setMaxWorkers](SuperTaskCluster#setMaxWorkers) to set total workers. **Kind**: instance method of [supertask-cluster](#supertask-cluster) | Param | Type | Description | | --- | --- | --- | | maxTotalWorkers | Number | The maximum number of workers that should be deployed at any given time. | - ### supertask-cluster.addShared(name, source, callback) Add a new task to SuperTask. **Kind**: instance method of [supertask-cluster](#supertask-cluster) | Param | Type | Description | | --- | --- | --- | | name | String | Unique name of the task. | | source | String | function | Source/Function of the task. | | callback | AddCallback | The callback that handles the response. | - ### supertask-cluster.getWorkers() ⇒ Object Get all alive Workers. **Kind**: instance method of [supertask-cluster](#supertask-cluster) **Returns**: Object - an Object including Worker objects indexed (keyed) by Worker ID. - ### supertask-cluster.totalWorkers() ⇒ Number Get total number of alive Workers. **Kind**: instance method of [supertask-cluster](#supertask-cluster) - ### supertask-cluster.setMaxWorkers(maxTotalWorkers) Set total number of Workers and deploy new Workers if higher than before. Note that this does not reduce the number of workers (kill/terminate) but will add new workers to the cluster if the given argument exceeds previous maximum. **Kind**: instance method of [supertask-cluster](#supertask-cluster) | Param | Type | Description | | --- | --- | --- | | maxTotalWorkers | Number | The maximum number of workers that should be deployed at any given time. | - ### supertask-cluster.addWorkers(n) Add and deploy new Workers to the Cluster. **Kind**: instance method of [supertask-cluster](#supertask-cluster) | Param | Type | Description | | --- | --- | --- | | n | Number | Adds n number of workers to the cluster. | - ### supertask-cluster.killWorker(workerID, graceful, [callback]) Forcefully/Gracefully kills a Worker. Note that another worker is immediately forked to replace the killed Worker. In order to reduce the number of workers set setMaxWorkers before calling this function. **Kind**: instance method of [supertask-cluster](#supertask-cluster) | Param | Type | Default | Description | | --- | --- | --- | --- | | workerID | Number | | ID of the Worker | | graceful | Boolean | false | Determine if the Worker should be give the chance to finish tasks before killing itself. | | [callback] | function | | An optional callback to determine when the worker was actually killed. Calls with error, exitCode, signal arguments. | - ### supertask-cluster.createBufferOnWorker(workerID, name, buffer, encoding, mutable, [chunky], [callback]) Send/Upload a local Buffer object to a worker with the given ID. Note that although performance is relative to the hardware on average it takes about 20 seconds to upload a 1GB Buffer with nearly relative speeds for smaller sizes (e.g. 200ms for 10MB). **Kind**: instance method of [supertask-cluster](#supertask-cluster) | Param | Type | Default | Description | | --- | --- | --- | --- | | workerID | Number | | ID of the Worker | | name | String | | Unique Buffer name | | buffer | Buffer | | A NodeJS Buffer object | | encoding | String | | Encoding type of Buffer e.g. 'utf8' | | mutable | Boolean | true | Indicates whether Buffer will be mutable/editable in the Worker or copies of the buffer will be passed. | | [chunky] | Boolean | | Indicates whether the Buffer should be sent in chunks or whole. Anything above 64kb will be sent in chunks by default which is a good idea. | | [callback] | function | | Called after Buffer and its chunks have been fully uploaded to the Worker. | - ### supertask-cluster.workerBufferReference(name) ⇒ Object Creates a Buffer reference on a Worker as a passable argument **Kind**: instance method of [supertask-cluster](#supertask-cluster) **Returns**: Object - reference - A reference that can be passed as an argument to do function. | Param | Type | Description | | --- | --- | --- | | name | String | Name of the Buffer uploaded to the Worker using [SuperTaskCluster#createBufferOnWorker](SuperTaskCluster#createBufferOnWorker) | - ### supertask-cluster.setClusterDebug(toggle) Set the cluster to debug. Note that this uses a separate Worker code therefore currently online Workers will not log debug information. **Kind**: instance method of [supertask-cluster](#supertask-cluster) | Param | Type | Description | | --- | --- | --- | | toggle | Boolean | Toggles debug. | - ### supertask-cluster.clusterResponseTimeout([time]) ⇒ Number Gets/Sets the cluster response timeout. Callbacks will be called if the response has taken more than this set amount of time with a timeout error. Defaults to 30,000 ms or 30 seconds. **Kind**: instance method of [supertask-cluster](#supertask-cluster) **Returns**: Number - time | Param | Type | Description | | --- | --- | --- | | [time] | Number | time in milliseconds (ms) | -