Skip to content

Commit

Permalink
Small stuff before first tagged release.
Browse files Browse the repository at this point in the history
- Renamed `PredisDriver` to `PredisRedisDriver`, so that any other
  drivers can use a clear naming scheme `<Something><TransportType>Driver`.
  - For example a Redis driver backed by `phpredis` PHP extension would
    then be named `PhpRedisRedisDriver`,
  - or a RabbitMQ driver backed by `php-amqplib` would be named something
    like `PhpAmqpLibRabbitMqDriver` or something.
  • Loading branch information
smuuf committed Oct 26, 2023
1 parent 8af8ac5 commit 70eb531
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 16 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ A modern PHP client library for [Celery - Distributed Task Queue](https://docs.c
use Smuuf\CeleryForPhp\Celery;
use Smuuf\CeleryForPhp\TaskSignature;
use Smuuf\CeleryForPhp\Brokers\RedisBroker;
use Smuuf\CeleryForPhp\Drivers\PredisDriver;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;
use Smuuf\CeleryForPhp\Backends\RedisBackend;

$predis = new PredisClient(['host' => '127.0.0.1']);
$redisDriver = new PredisDriver($predis);
$redisDriver = new PredisRedisDriver($predis);

$celery = new Celery(
new RedisBroker($redisDriver),
new RedisBackend($redisDriver),
// Optionally explicit config object.
// config: new \Smuuf\CeleryForPhp\Config(...)
);

$task = new TaskSignature(
taskName: 'my_celery_app.add_numbers',
queue: 'my_queue', // Optional, 'celery' by default.
args: [1, 3, 5],
// ... more optional arguments.
// kwargs: ['arg_a' => 123, 'arg_b' => 'something'],
// eta: 'now +10 minutes',
// ... or more optional arguments.
);

// Send the task into Celery.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Redis driver backed by Predis.
*/
class PredisDriver implements IRedisDriver {
class PredisRedisDriver implements IRedisDriver {

use StrictObject;

Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Smuuf\CeleryForPhp\Celery;
use Smuuf\CeleryForPhp\Config;
use Smuuf\CeleryForPhp\Brokers\RedisBroker;
use Smuuf\CeleryForPhp\Drivers\PredisDriver;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;
use Smuuf\CeleryForPhp\Backends\RedisBackend;
use Smuuf\CeleryForPhp\Serializers\JsonSerializer;

Expand All @@ -27,7 +27,7 @@ public static function getCelery(): Celery {
);

$predis = new PredisClient(self::getPredisConnectionConfig());
$redisDriver = new PredisDriver($predis);
$redisDriver = new PredisRedisDriver($predis);
$broker = new RedisBroker($redisDriver);
$backend = new RedisBackend($redisDriver);

Expand Down
4 changes: 2 additions & 2 deletions tests/suite/Backends.RedisBackend.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use Smuuf\CeleryForPhp\State;
use Smuuf\CeleryForPhp\TaskMetaResult;
use Smuuf\CeleryForPhp\AsyncResult;
use Smuuf\CeleryForPhp\Backends\RedisBackend;
use Smuuf\CeleryForPhp\Drivers\PredisDriver;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;

require __DIR__ . '/../bootstrap.php';

$predis = new PredisClient(CeleryFactory::getPredisConnectionConfig());
$redisDriver = new PredisDriver($predis);
$redisDriver = new PredisRedisDriver($predis);

$x = serialize($predis);
$predis = unserialize($x);
Expand Down
4 changes: 2 additions & 2 deletions tests/suite/Brokers.RedisBroker.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Predis\Client as PredisClient;

use Smuuf\CeleryForPhp\DeliveryInfo;
use Smuuf\CeleryForPhp\Brokers\RedisBroker;
use Smuuf\CeleryForPhp\Drivers\PredisDriver;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;
use Smuuf\CeleryForPhp\Messaging\CeleryMessage;
use Smuuf\CeleryForPhp\Serializers\JsonSerializer;

Expand All @@ -24,7 +24,7 @@ function _prepare_random_queue(): string {
}

$predis = new PredisClient(CeleryFactory::getPredisConnectionConfig());
$redisDriver = new PredisDriver($predis);
$redisDriver = new PredisRedisDriver($predis);
$broker = new RedisBroker($redisDriver);

// Whatever message. DeliveryInfo is important.
Expand Down
4 changes: 2 additions & 2 deletions tests/suite/Integration/RealTask.eta.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use Smuuf\CeleryForPhp\AsyncResult;
use Smuuf\CeleryForPhp\TaskSignature;
use Smuuf\CeleryForPhp\Backends\RedisBackend;
use Smuuf\CeleryForPhp\Brokers\RedisBroker;
use Smuuf\CeleryForPhp\Drivers\PredisDriver;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;
use Smuuf\CeleryForPhp\Exc\InvalidArgumentException;
use Smuuf\CeleryForPhp\State;

require __DIR__ . '/../../bootstrap.php';

$predis = new PredisClient(CeleryFactory::getPredisConnectionConfig());
$redisDriver = new PredisDriver($predis);
$redisDriver = new PredisRedisDriver($predis);

$c = new Celery(
new RedisBroker($redisDriver),
Expand Down
4 changes: 2 additions & 2 deletions tests/suite/Integration/RealTask.task.justWait.revoke.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use Smuuf\CeleryForPhp\State;
use Smuuf\CeleryForPhp\Celery;
use Smuuf\CeleryForPhp\TaskSignature;
use Smuuf\CeleryForPhp\Brokers\RedisBroker;
use Smuuf\CeleryForPhp\Drivers\PredisDriver;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;
use Smuuf\CeleryForPhp\Backends\RedisBackend;
use Smuuf\CeleryForPhp\Exc\CeleryTaskException;
use Smuuf\CeleryForPhp\Helpers\Signals;

require __DIR__ . '/../../bootstrap.php';

$predis = new PredisClient(CeleryFactory::getPredisConnectionConfig());
$redisDriver = new PredisDriver($predis);
$redisDriver = new PredisRedisDriver($predis);

$c = new Celery(
new RedisBroker($redisDriver),
Expand Down
4 changes: 2 additions & 2 deletions tests/suite/Integration/RealTask.task.sumList.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use Smuuf\CeleryForPhp\Celery;
use Smuuf\CeleryForPhp\TaskSignature;
use Smuuf\CeleryForPhp\Backends\RedisBackend;
use Smuuf\CeleryForPhp\Brokers\RedisBroker;
use Smuuf\CeleryForPhp\Drivers\PredisDriver;
use Smuuf\CeleryForPhp\Drivers\PredisRedisDriver;
use Smuuf\CeleryForPhp\Exc\CeleryTaskException;
use Smuuf\CeleryForPhp\State;

require __DIR__ . '/../../bootstrap.php';

$predis = new PredisClient(CeleryFactory::getPredisConnectionConfig());
$redisDriver = new PredisDriver($predis);
$redisDriver = new PredisRedisDriver($predis);

$c = new Celery(
new RedisBroker($redisDriver),
Expand Down

0 comments on commit 70eb531

Please sign in to comment.