Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Worker part of queue-xec , can runs jobs - install required dependencies dynamically on demand.All required data with master exchanged with encryption.

License

NotificationsYou must be signed in to change notification settings

queue-xec/worker

Repository files navigation

Publish to NPM

As the name itself states it , Worker is the task processor node. After initial connection , Worker waiting for new tasks.

Info needs from Master :

  • token
  • transferEncryptToken

These 2 tokens are generated inMaster due setup.Worker can operate in any network condition as long is online, can work behind NAT or home routers. Using webrtc and peer to peer trackers to connect and communicate with master.

Can receive task assets and their dependencies , while can track any changes made in files shared fromMaster ,if has outdated version of those files , will request again latest ones from Master.Dependencies automatically installed when a file change takes place.

Can receive job data , as part of job ifMaster passes them.And finally send back to Master job results , all data communication are encrypted.

Get started

Withnpm

yarn add queue-xec-worker#or# npm install queue-xec-worker

Including in existing project

constWorker=require('queue-xec-worker')constwork1=newWorker({    token,// token generated from Master    name='worker_1',    loglevel,// off -> info -> warn -> error -> debug    transferEncryptToken=null,// token generated from Master});// work1 instance is ready for incoming new tasks

** file an issue if you think Worker should expose any other functionalities (for example, to have more control) .

  git clone https://github.com/queue-xec/workercd worker  yarn#or# npm install
 node worker.js --setup

Will prompt user to enter following info:

  • transferEncryptToken token frommaster to secure data communications
  • token frommaster this used for peers connection through webrtc.

These info will saved and loaded (later) in .env file at root workers folder.

Run and Wait for jobs :

  • node worker.js

Task File Structure

The worker expects atask.js file to be provided by the Master. This file should export a class with arun method that accepts ajob object as an argument and returns a Promise that resolves with the job's results.

Exampletask.js:

classTask{asyncrun(job){// Process the job dataconsole.log('Processing job:',job.id);// ... perform some work ...return{jobId:job.id,status:'completed',result:'some_result',};}}module.exports=Task;

MIT License

> Contributors <

⚠️ Under development⚠️

About

Worker part of queue-xec , can runs jobs - install required dependencies dynamically on demand.All required data with master exchanged with encryption.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2026 Movatter.jp