Get support for soyuka/relieve

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

soyuka/relieve

Relieve Test Coverage Code Climate Build Status Build status

The goal of this library is to ease the implementation of multi processing accross your existing microservices. Relieve aims to give a reusable design pattern using process forks. It also eases communication with child processes with an high-level abstraction.

For example, with a CallableTask:

//task.js
//just export a module in the child process
module.exports = {
  print: (str) => {
    console.log(str)
  },
  data: () => {
    //return some async data
    return Promise.resolve({foo: 'bar'})
  }
}

Then from your master, just call the task:

//worker.js
var CallableTask = require('relieve/tasks/CallableTask')
var task = new CallableTask('task.js')

task.start()
.then(() => {
  task.call('print', 'hello world')
  return task.get('data')
})
.then(d => {
  //d is {foo: 'bar'}
})

The design pattern

Relieve is based on a design pattern containing:

  • A Worker
  • One or more tasks

The task can be used without a Worker, but the Worker helps managing workflows.

Task

The 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. There are different tasks implementations:

  • Fork Task - simply transforms a ChildProcess.fork in a Task
  • 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
  • Callable Task - this is a Script Task with convenience methods to call or get script methods remotely

Tutorials:

Worker

Different kind of Workers for different use cases. Every Worker takes one or more tasks and handles them.

  • Worker - it's a basic worker. Helps sending a message to every task.
  • QueueWorker - process tasks one after the other, or in concurrency. Waits for a Task to exit before it consider's it as done.
  • CloudWorker - does not wait for tasks to exit and process them through a Strategy (ie: RoundRobin)

Tutorials:

Tools

  • Containers - easy way to add ipc methods for your tasks
  • Interfaces - extends how the tasks are managed (FailSafe, Logger)

Links

Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2