PHPackages                             reasno/gotask - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. reasno/gotask

ActiveLibrary

reasno/gotask
=============

A replacement for Swoole TaskWorker in Go

v3.0.1(2y ago)2562429[15 issues](https://github.com/hyperf/gotask/issues)[3 PRs](https://github.com/hyperf/gotask/pulls)MITPHPPHP &gt;=8.1

Since Mar 26Pushed 1y ago2 watchersCompare

[ Source](https://github.com/hyperf/gotask)[ Packagist](https://packagist.org/packages/reasno/gotask)[ Fund](https://hyperf.wiki/#/zh-cn/donate)[ Fund](https://opencollective.com/hyperf)[ RSS](/packages/reasno-gotask/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (13)Versions (36)Used By (0)

GoTask
======

[](#gotask)

English | [中文](./README-CN.md)

[![Build Status](https://camo.githubusercontent.com/e88a23855d3546bfe2b2a38c9282c63b18349457a70623e2284efe939066376a/68747470733a2f2f7472617669732d63692e6f72672f6879706572662f676f7461736b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hyperf/gotask)

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
```

Feature
-------

[](#feature)

- [High performance with low footprint.](https://github.com/reasno/gotask-benchmark)
- Based on Swoole 4 coroutine socket API.
- Support Unix Socket, TCP and stdin/stdout pipes.
- Support both PHP-to-Go and Go-to-PHP calls.
- Automatic sidecar lifecycle management.
- Correctly handle remote error.
- Support both structural payload and binary payload.
- Sidecar API compatible with net/rpc.
- Baked-in connection pool.
- Optionally integrated with Hyperf framework.

Perfect For
-----------

[](#perfect-for)

- Blocking operations in Swoole, such as MongoDB queries.
- CPU Intensive operations, such as encoding and decoding.
- Leveraging Go eco-system, such as Kubernetes clients.

Requirement
-----------

[](#requirement)

- PHP 7.2+
- Go 1.13+
- Swoole 4.4LTS+
- Hyperf 1.1+ (optional)

Task Delivery Demo
------------------

[](#task-delivery-demo)

```
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()
}
```

```
