Stars: 188
Forks: 20
Pull Requests: 29
Issues: 37
Watchers: 4
Last Updated: 2023-08-11 05:47:39
⚡️ A lightning speed replacement for Swoole TaskWorker in Go
License: MIT License
Languages: PHP, Go, Shell
English | 中文
GoTask spawns a go process as a Swoole sidecar and establishes a bi-directional IPC to offload heavy-duties to Go. Think of it as a Swoole Taskworker in Go.
composer require hyperf/gotask
package main
import (
"github.com/hyperf/gotask/v2/pkg/gotask"
)
type App struct{}
func (a *App) Hi(name string, r *interface{}) error {
*r = map[string]string{
"hello": name,
}
return nil
}
func main() {
gotask.SetAddress("127.0.0.1:6001")
gotask.Register(new(App))
gotask.Run()
}
<?php
use Hyperf\GoTask\IPC\SocketIPCSender;
use function Swoole\Coroutine\run;
require_once "../vendor/autoload.php";
run(function(){
$task = new SocketIPCSender('127.0.0.1:6001');
var_dump($task->call("App.Hi", "Hyperf"));
// [ "hello" => "Hyperf" ]
});
English documentation is not yet complete! Please see examples first.
https://github.com/reasno/gotask-benchmark