Skip to content

Infrastructure for background, long running, or distributed work units

License

Notifications You must be signed in to change notification settings

meteor-space/job-queue

Repository files navigation

Space Job Queue Circle CI

A persistent Job Queue for your Space implementation. Uses the well maintained and tested vsivsi:job-collection - A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.


Licensed under the MIT license | Changelog | 1.0 Milestone list

Documentation

Documentation in this package only relates to the Space implementation. See job-collection documentation for an overview of the underlying infrastructure.

See space:job-queue-ui non-view UI elements.

Queue

A single job-collection instance is configured and mapped to the injector as 'Space.jobQueue.Jobs'

Configuration and defaults

configuration: Space.getenv.multi({
jobQueue: {
  log: {
    enabled: ['SPACE_JQ_LOG_ENABLED', false, 'bool'],
    mode: ['SPACE_JQ_LOG_MODE', 'normal', 'string']
   },
  promoteInterval: ['SPACE_JQ_PROMOTE_INTERVAL', 15000, 'int'],
  serverInstanceQty: ['SPACE_JQ_SERVER_INSTANCE_QTY', 1, 'int'],
  remoteAccess: {
    enabled: ['SPACE_JQ_REMOTE_ACCESS_ENABLED', true, 'bool'],
    publish: ['SPACE_JQ_REMOTE_ACCESS_PUBLISH', true, 'bool']
  },
  stats: {
    jobServer: {
      publish: ['SPACE_JQ_STATS_JOB_SERVER_PUBLISH', false, 'bool']
    },
    connectedWorkers: {
      publish: ['SPACE_JQ_STATS_CONNECTED_WORKERS_PUBLISH', false, 'bool']
    }
  }
}
})

In addition to the Module.configuration API above are these ENV-only options:

  • SPACE_JQ_COLLECTION_NAME - defaults to space_jobQueue_jobs
  • SPACE_JQ_MONGO_URL
  • SPACE_JQ_MONGO_OPLOG_URL

Remote Worker Access

Documentation coming soon, but there is full support now and enabled by default

Events

Job server events are translated and published on the server-side Space.messaging.EventBus module instance ready for deep integration with your Space implementation.

Event Reference

Publications

  • space-jobQueue-ready-jobs - Use for observer-based remote workers
  • enabled using remoteAccess.publish configuration.
  • Optionally pass a lastSessionId property to reliably track connected workers.
  • In your remote worker the subscription's connectionId can be saved to disk and passed back on reconnection to handle a few different disconnection/exit scenarios. This will be better documented when there's an example to reference.
  • space-jobQueue-job-server-stats - Exposes the jobServer running state and promoteInterval.
  • Useful for visualising the state in your UI, such as a green or red solid circle.
  • space-jobQueue-connected-workers - Exposes a collection of connected worker connections across all instances.
  • Useful for showing a count in your UI

Logging

  • normal default, simple message
  • full contains the message and full event payload

Installation

meteor add space:job-queue

Add 'Space.jobQueue' to the requiredModules array on a server module or application.

Tests

meteor test-packages ./

About

Infrastructure for background, long running, or distributed work units

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published