Skip to content

Commit

Permalink
Merge pull request #2 from utopia-php/fix-random-fixes
Browse files Browse the repository at this point in the history
Implement Hooks and DI
  • Loading branch information
eldadfux authored Oct 19, 2022
2 parents d8ad1b7 + 3d0ac46 commit 4927cd7
Show file tree
Hide file tree
Showing 20 changed files with 576 additions and 648 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ WORKDIR /usr/local/src/

RUN apk add autoconf build-base

RUN set -ex \
&& pecl update-channels \
&& pecl install redis-stable \
&& docker-php-ext-enable redis
RUN docker-php-ext-enable redis

COPY . .

Expand Down
50 changes: 41 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Utopia Queue

[![Build Status](https://travis-ci.com/utopia-php/system.svg?branch=main)](https://travis-ci.com/utopia-php/queue)
[![Build Status](https://travis-ci.com/utopia-php/queue.svg?branch=main)](https://travis-ci.com/utopia-php/queue)
![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/queue.svg)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)

Expand All @@ -21,21 +21,53 @@ Init in your application:

require_once __DIR__ . '/../../vendor/autoload.php';

// Create a worker using swoole adapter
use Utopia\Queue;

use Utopia\Queue\Message;

$connection = new Queue\Connection\RedisSwoole('redis');
$adapter = new Queue\Adapter\Swoole($connection, 12, 'swoole');
$server = new Queue\Server($adapter);

$server->job()
->inject('message')
->action(function (Message $message) {
var_dump($message);
});

$server
->error()
->inject('error')
->action(function ($error) {
echo $error->getMessage() . PHP_EOL;
});

$server
->workerStart(function () {
echo "Worker Started" . PHP_EOL;
})
->start();


// Enqueue messages to the worker using swoole adapter
$connection = new RedisSwoole('redis', 6379);
run(function () use ($connection) {
$client = new Client('swoole', $connection);
go(function () use ($client) {
$client->resetStats();

$client->enqueue([
'type' => 'test_number',
'value' => 123
]);
});
});
```

## System Requirements

Utopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.

## Authors

**Torsten Dittmann**

+ [https://twitter.com/dittmanntorsten](https://twitter.com/dittmanntorsten)
+ [https://github.com/torstendittmann](https://github.com/torstendittmann)

## Copyright and license

The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
},
"require": {
"php": ">=8.0",
"utopia-php/cli": "0.12.*"
"utopia-php/cli": "0.12.*",
"utopia-php/framework": "0.*.*"
},
"require-dev": {
"swoole/ide-helper": "4.8.8",
Expand Down
Loading

0 comments on commit 4927cd7

Please sign in to comment.