Categorygithub.com/blcksec/roadrunner
repositorypackage
0.9.0
Repository: https://github.com/blcksec/roadrunner.git
Documentation: pkg.go.dev

# README

RoadRunner

GoDoc Build Status Go Report Card Scrutinizer Code Quality Codecov

High-performance PHP job balancer and process manager library for Golang.

Features:

  • no external dependencies or services, drop-in
  • load balancer, process manager and task pipeline
  • build for multiple frontends (queue, rest, psr-7, async php, etc)
  • works over TPC, unix sockets and standard pipes
  • automatic worker replacement and safe destruction
  • worker lifecycle management (create/allocate/destroy timeouts)
  • payload context and body
  • control over max jobs per worker
  • protocol, worker and job level error management (including PHP errors)
  • very fast (~250k calls per second on Ryzen 1700X over 16 threads)
  • works on Windows

Examples:

p, err := NewPool(
    func() *exec.Cmd { return exec.Command("php", "worker.php", "pipes") },
    NewPipeFactory(),
    Config{
        NumWorkers:      uint64(runtime.NumCPU()),
        AllocateTimeout: time.Second,              
        DestroyTimeout:  time.Second,               
    },
)
defer p.Destroy()

rsp, err := p.Exec(&Payload{Body: []byte("hello")})
<?php
/**
 * @var Goridge\RelayInterface $relay
 */

use Spiral\Goridge;
use Spiral\RoadRunner;

$rr = new RoadRunner\Worker($relay);

while ($body = $rr->receive($context)) {
    try {
        $rr->send((string)$body, (string)$context);
    } catch (\Throwable $e) {
        $rr->error((string)$e);
    }
}

Check how to init relay here.

License:

The MIT License (MIT). Please see LICENSE for more information.