-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scrapped msgpack task message serialization option.
Because for both msgpack PHP extension or `rybakit/msgpack` Composer package there seem to be unsolvable problems with differentiating of how to serialize empty lists vs empty dicts (PHP only has arrays for both use cases).
- Loading branch information
Showing
20 changed files
with
87 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
<?php | ||
|
||
use Predis\Client as PredisClient; | ||
|
||
use Smuuf\CeleryForPhp\Celery; | ||
use Smuuf\CeleryForPhp\Config; | ||
use Smuuf\CeleryForPhp\Brokers\RedisBroker; | ||
use Smuuf\CeleryForPhp\Drivers\PredisDriver; | ||
use Smuuf\CeleryForPhp\Backends\RedisBackend; | ||
use Smuuf\CeleryForPhp\Serializers\JsonSerializer; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
\Tester\Environment::setup(); | ||
|
||
class TestEnv { | ||
class CeleryFactory { | ||
|
||
public static function getCelery(): Celery { | ||
|
||
$envConfig = self::readEnv(); | ||
|
||
$config = new Config( | ||
taskMessageProtocolVersion: $envConfig['task_message_protocol_version'], | ||
taskSerializer: match ($envConfig['serializer']) { | ||
'json' => new JsonSerializer(), | ||
}, | ||
); | ||
|
||
private static string $redisUri; | ||
$predis = new PredisClient(['host' => '127.0.0.1']); | ||
$redisDriver = new PredisDriver($predis); | ||
$broker = new RedisBroker($redisDriver); | ||
$backend = new RedisBackend($redisDriver); | ||
|
||
return new Celery($broker, $backend, $config); | ||
|
||
public static function init(): void { | ||
self::$redisUri = '127.0.0.1'; | ||
} | ||
|
||
public static function getRedisUri(): string { | ||
return self::$redisUri; | ||
/** | ||
* @return array{ | ||
* serializer: string, | ||
* message_protocol: int, | ||
* } | ||
*/ | ||
private static function readEnv(): array { | ||
|
||
return [ | ||
'serializer' => getenv('CELERYFORPHP_TASK_SERIALIZER') ?: '', | ||
'task_message_protocol_version' => (int) getenv('CELERYFORPHP_TASK_MESSAGE_PROTOCOL_VERSION'), | ||
]; | ||
|
||
} | ||
|
||
} | ||
|
||
TestEnv::init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.