Differential / meteor-workers

Spawn headless worker meteor processes to work on async jobs.
80 stars 9 forks source link

How to get output back? #20

Open heaven7 opened 8 years ago

heaven7 commented 8 years ago

Hi, i made a job which reads the content of a directory

class @readDirJob extends Job
    handleJob: ->
      root = @params.options.root
      entryType = @params.options.entryType
      Readdirp = Meteor.npmRequire('readdirp')
      return Readdirp { root: root, entryType: entryType }

and i'm calling this job with a Meteor.method

Meteor.methods readDirp: (options) ->
  job = new readDirJob(options: options)
  Job.push job, (err, res) ->
    console.log err, res

Instead of getting the content of the directory, i'm getting back the job collection object

I20160120-14:04:31.572(1)? { collection: 
I20160120-14:04:31.573(1)?    { _construct_args: [],
I20160120-14:04:31.573(1)?      _native: 
I20160120-14:04:31.574(1)?       { db: [Object],
I20160120-14:04:31.574(1)?         collectionName: 'jobs',
I20160120-14:04:31.574(1)?         internalHint: null,
I20160120-14:04:31.575(1)?         opts: {},
I20160120-14:04:31.575(1)?         slaveOk: false,
I20160120-14:04:31.576(1)?         serializeFunctions: false,
I20160120-14:04:31.576(1)?         raw: false,
I20160120-14:04:31.576(1)?         readPreference: [Object],
I20160120-14:04:31.577(1)?         pkFactory: [Object],
I20160120-14:04:31.577(1)?         serverCapabilities: undefined },
I20160120-14:04:31.577(1)?      _emitter: { domain: null, _events: {}, _maxListeners: 50 },
I20160120-14:04:31.578(1)?      _state: 2,
I20160120-14:04:31.578(1)?      _skin_db: 
I20160120-14:04:31.578(1)?       { _construct_args: [],
I20160120-14:04:31.579(1)?         _native: [Object],
I20160120-14:04:31.579(1)?         _emitter: [Object],
I20160120-14:04:31.580(1)?         _state: 2,
I20160120-14:04:31.580(1)?         _connect_args: [Object] },
I20160120-14:04:31.581(1)?      _collection_args: [ 'jobs', undefined ] },
I20160120-14:04:31.581(1)?   data: 
I20160120-14:04:31.582(1)?    { name: 'readDirJob',
I20160120-14:04:31.582(1)?      params: 
I20160120-14:04:31.583(1)?       { options: [Object],
I20160120-14:04:31.583(1)?         _id: 'tbQXS9auYKPBT99Fk',
I20160120-14:04:31.584(1)?         _className: 'readDirJob' },
I20160120-14:04:31.585(1)?      queue: 'jobs',
I20160120-14:04:31.585(1)?      attempts: { count: 10, delay: 10000, strategy: 'exponential' },
I20160120-14:04:31.585(1)?      timeout: undefined,
I20160120-14:04:31.586(1)?      delay: Wed Jan 20 2016 14:04:31 GMT+0100 (CET),
I20160120-14:04:31.586(1)?      priority: 0,
I20160120-14:04:31.587(1)?      status: 'queued',
I20160120-14:04:31.587(1)?      enqueued: Wed Jan 20 2016 14:04:31 GMT+0100 (CET),
I20160120-14:04:31.588(1)?      _id: 569f85dfacf4fc6b47c7e067 } }

Is it possible to send back data?

Thanks in advance