PHPackages                             bain2018/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bain2018/gotask

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bain2018/gotask
===============

A replacement for Swoole TaskWorker in Go,upgrade to hyperf3.1 and ^mongodb-1.20 || ^mongodb-2.1

v3.1.14(4mo ago)0140↓75%1MITPHPPHP &gt;=8.2CI passing

Since Dec 15Pushed 4mo agoCompare

[ Source](https://github.com/bain2018/gotask)[ Packagist](https://packagist.org/packages/bain2018/gotask)[ RSS](/packages/bain2018-gotask/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (11)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 bain2018/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()
}
```

```
