{"id":13609897,"url":"https://github.com/soyuka/relieve","last_synced_at":"2025-04-15T01:43:30.303Z","repository":{"id":2491184,"uuid":"46666724","full_name":"soyuka/relieve","owner":"soyuka","description":"Ease the implementation of multi processing accross your microservices","archived":false,"fork":false,"pushed_at":"2022-07-06T22:31:40.000Z","size":599,"stargazers_count":48,"open_issues_count":7,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-03T12:16:27.597Z","etag":null,"topics":["child-process","failsafe","microservice","process","task","workers"],"latest_commit_sha":null,"homepage":"http://soyuka.github.io/relieve/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soyuka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-22T15:35:21.000Z","updated_at":"2024-05-05T23:42:41.000Z","dependencies_parsed_at":"2022-08-06T12:15:30.220Z","dependency_job_id":null,"html_url":"https://github.com/soyuka/relieve","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyuka%2Frelieve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyuka%2Frelieve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyuka%2Frelieve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyuka%2Frelieve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soyuka","download_url":"https://codeload.github.com/soyuka/relieve/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991516,"owners_count":21194893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["child-process","failsafe","microservice","process","task","workers"],"created_at":"2024-08-01T19:01:39.076Z","updated_at":"2025-04-15T01:43:30.279Z","avatar_url":"https://github.com/soyuka.png","language":"JavaScript","readme":"## Relieve [![Test Coverage](https://codeclimate.com/github/soyuka/relieve/badges/coverage.svg)](https://codeclimate.com/github/soyuka/relieve/coverage) [![Code Climate](https://codeclimate.com/github/soyuka/relieve/badges/gpa.svg)](https://codeclimate.com/github/soyuka/relieve) [![Build Status](https://travis-ci.org/soyuka/relieve.svg?branch=master)](https://travis-ci.org/soyuka/relieve) [![Build status](https://ci.appveyor.com/api/projects/status/kixnoqeg0tntgaad?svg=true)](https://ci.appveyor.com/project/soyuka/relieve)\n\nThe goal of this library is to ease the implementation of multi processing accross your existing microservices.\nRelieve aims to give a reusable design pattern using process forks. It also eases communication with child processes with an high-level abstraction.\n\nFor example, with a CallableTask:\n\n```javascript\n//task.js\n//just export a module in the child process\nmodule.exports = {\n  print: (str) =\u003e {\n    console.log(str)\n  },\n  data: () =\u003e {\n    //return some async data\n    return Promise.resolve({foo: 'bar'})\n  }\n}\n```\n\nThen from your master, just call the task:\n\n```javascript\n//worker.js\nvar CallableTask = require('relieve/tasks/CallableTask')\nvar task = new CallableTask('task.js')\n\ntask.start()\n.then(() =\u003e {\n  task.call('print', 'hello world')\n  return task.get('data')\n})\n.then(d =\u003e {\n  //d is {foo: 'bar'}\n})\n```\n\n### The design pattern\n\nRelieve is based on a design pattern containing:\n- A Worker\n- One or more tasks\n\n![](https://raw.githubusercontent.com/soyuka/relieve/master/examples/images/relieve.jpg)\n\nThe task can be used without a Worker, but the Worker helps managing workflows.\n\n### Task\n\nThe task will implement a child process using `fork`. It'll make sure that there is an ipc channel open so that Workers and Tasks can communicate.\nThere are different tasks implementations:\n\n- Fork Task - simply transforms a `ChildProcess.fork` in a Task\n- Script Task - wraps a script path in a container that is managed through `ChildProcess.fork`. It gives the ability to start, restart or kill a Task\n- Callable Task - this is a Script Task with convenience methods to `call` or `get` script methods remotely\n\n\n#### Tutorials:\n\n- [Fork Task](http://soyuka.github.io/relieve/tutorial-1-ForkTask.html)\n- [Script Task](http://soyuka.github.io/relieve/tutorial-2-ScriptTask.html)\n- [Callable Task](http://soyuka.github.io/relieve/tutorial-3-CallableTask.html)\n\n### Worker\n\nDifferent kind of Workers for different use cases. Every Worker takes one or more tasks and handles them.\n\n- Worker - it's a basic worker. Helps sending a message to every task.\n- QueueWorker - process tasks one after the other, or in concurrency. Waits for a Task to exit before it consider's it as done.\n- CloudWorker - does not wait for tasks to exit and process them through a Strategy (ie: RoundRobin)\n\n#### Tutorials:\n\n- [Worker](http://soyuka.github.io/relieve/tutorial-4-Worker.html)\n- [QueueWorker](http://soyuka.github.io/relieve/tutorial-5-QueueWorker.html)\n- [CloudWorker](http://soyuka.github.io/relieve/tutorial-6-CloudWorker.html)\n\n### Tools\n\n- [Containers](http://soyuka.github.io/relieve/tutorial-7-Containers.html) - easy way to add ipc methods for your tasks\n- [Interfaces](http://soyuka.github.io/relieve/tutorial-8-Interfaces.html) - extends how the tasks are managed (FailSafe, Logger)\n\n### Links\n- [Documentation](http://soyuka.github.io/relieve/)\n- [Coverage](http://soyuka.github.io/relieve/coverage/lcov-report/)\n- [Blog post](https://soyuka.me/having-fun-with-nodejs-child-processes/)\n","funding_links":[],"categories":["JavaScript","workers"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoyuka%2Frelieve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoyuka%2Frelieve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoyuka%2Frelieve/lists"}