Skip to content

Commit 4927cd7

Browse files
authored
Merge pull request #2 from utopia-php/fix-random-fixes
Implement Hooks and DI
2 parents d8ad1b7 + 3d0ac46 commit 4927cd7

File tree

20 files changed

+576
-648
lines changed

20 files changed

+576
-648
lines changed

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ WORKDIR /usr/local/src/
1313

1414
RUN apk add autoconf build-base
1515

16-
RUN set -ex \
17-
&& pecl update-channels \
18-
&& pecl install redis-stable \
19-
&& docker-php-ext-enable redis
16+
RUN docker-php-ext-enable redis
2017

2118
COPY . .
2219

README.md

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Utopia Queue
22

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

@@ -21,21 +21,53 @@ Init in your application:
2121

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

24+
// Create a worker using swoole adapter
2425
use Utopia\Queue;
25-
26+
use Utopia\Queue\Message;
27+
28+
$connection = new Queue\Connection\RedisSwoole('redis');
29+
$adapter = new Queue\Adapter\Swoole($connection, 12, 'swoole');
30+
$server = new Queue\Server($adapter);
31+
32+
$server->job()
33+
->inject('message')
34+
->action(function (Message $message) {
35+
var_dump($message);
36+
});
37+
38+
$server
39+
->error()
40+
->inject('error')
41+
->action(function ($error) {
42+
echo $error->getMessage() . PHP_EOL;
43+
});
44+
45+
$server
46+
->workerStart(function () {
47+
echo "Worker Started" . PHP_EOL;
48+
})
49+
->start();
50+
51+
52+
// Enqueue messages to the worker using swoole adapter
53+
$connection = new RedisSwoole('redis', 6379);
54+
run(function () use ($connection) {
55+
$client = new Client('swoole', $connection);
56+
go(function () use ($client) {
57+
$client->resetStats();
58+
59+
$client->enqueue([
60+
'type' => 'test_number',
61+
'value' => 123
62+
]);
63+
});
64+
});
2665
```
2766

2867
## System Requirements
2968

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

32-
## Authors
33-
34-
**Torsten Dittmann**
35-
36-
+ [https://twitter.com/dittmanntorsten](https://twitter.com/dittmanntorsten)
37-
+ [https://github.com/torstendittmann](https://github.com/torstendittmann)
38-
3971
## Copyright and license
4072

4173
The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},
2626
"require": {
2727
"php": ">=8.0",
28-
"utopia-php/cli": "0.12.*"
28+
"utopia-php/cli": "0.12.*",
29+
"utopia-php/framework": "0.*.*"
2930
},
3031
"require-dev": {
3132
"swoole/ide-helper": "4.8.8",

0 commit comments

Comments
 (0)