Skip to content

Commit

Permalink
Merge pull request #4 from utopia-php/fix-remove-unnecessary-swoole-r…
Browse files Browse the repository at this point in the history
…edis-connection

fix: remove unnecessary redis swoole connection
  • Loading branch information
eldadfux authored Oct 19, 2022
2 parents b13be34 + ab23b7d commit 42b132c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 191 deletions.
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ Although this library is part of the [Utopia Framework](https://github.com/utopi
## Getting Started

Install using composer:

```bash
composer require utopia-php/queue
```

Init in your application:

```php
<?php

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

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

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

Expand All @@ -49,19 +51,15 @@ $server
->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();
// Enqueue messages to the worker using the Redis adapter
$connection = new Redis('redis', 6379);
$client = new Client('swoole', $connection);
$client->resetStats();

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

## System Requirements
Expand Down
174 changes: 0 additions & 174 deletions src/Queue/Connection/RedisSwoole.php

This file was deleted.

3 changes: 1 addition & 2 deletions tests/Queue/e2e/AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use PHPUnit\Framework\TestCase;
use Utopia\Queue\Client;
use Utopia\Queue\Connection\Redis;
use Utopia\Queue\Connection\RedisSwoole;

use function Swoole\Coroutine\go;
use function Swoole\Coroutine\run;
Expand Down Expand Up @@ -81,7 +80,7 @@ public function testEvents(): void

public function testSwoole(): void
{
$connection = new RedisSwoole('redis', 6379);
$connection = new Redis('redis', 6379);

run(function () use ($connection) {
$client = new Client('swoole', $connection);
Expand Down
2 changes: 1 addition & 1 deletion tests/Queue/servers/Swoole/worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Utopia\Queue;
use Utopia\Queue\Message;

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

Expand Down

0 comments on commit 42b132c

Please sign in to comment.