- Notifications
You must be signed in to change notification settings - Fork2
Worker part of queue-xec , can runs jobs - install required dependencies dynamically on demand.All required data with master exchanged with encryption.
License
queue-xec/worker
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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.
Withnpm
yarn add queue-xec-worker#or# npm install queue-xec-workerIncluding 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.
node worker.js
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;
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.