Skip to content

~crosstalk.api.worker.create

tristanls edited this page Dec 2, 2012 · 1 revision

Create new worker.

Since Version 0.1.0
Scope
accepts: public responds as: ~crosstalk

Parameters

All parameters are optional, unless otherwise indicated.

crosstalkToken 5uua22922ausllwibb1amms7a761n23n4nasAJFDUA17711 required Crosstalk authorization token
owner ~myOrganization If provided (and authorized to do so), will assign ownership of the created worker to the owner. This supports the use case of setting the owner to the authorized ~organization instead of the @account initiating the request. This does not support assigning ownership to another @account
package "{\"name\":\"myWorker\",\"version\":\"0.1.1\",...}" required The worker package.json file contents
worker "crosstalk.assert( true );..." required The crosstalk worker javascript file contents

Response fields

Response

created myWorker@0.1.1 The name plus version of the worker that was created
workerName myWorker The name of the worker that was created
workerVersion 0.1.1 The version of the created worker

Error

errorCode 400 Error code compatible with HTTP status codes
message Missing 'package' Error message

Example

Request:

crosstalk.emit( 
  '~crosstalk.api.worker.create',
  {
    crosstalkToken : "5uua22922ausllwibb1amms7a761n23n4nasAJFDUA17711",
    package : '{"name":"myWorker","version":"0.1.1",...}',
    worker : "var config = require( 'config' ); ..."
  },
  '~crosstalk', 
  function ( error, response ) { /* ... */ } 
);

Response:

{ 
  created : 'myWorker@0.1.1',
  workerName : 'myWorker',
  workerVersion : '0.1.1'
}

Error:

{ 
  errorCode : 400, 
  message : "Missing 'package'" 
}