diff --git a/composer.json b/composer.json index c3cd64f..e3680c3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "license": "MIT", "require": { "php": "^7.4|^8.0", - "adt/background-queue": "^4.20", + "adt/background-queue": "^4.21", "nette/di": "^2.4|^3.0", "nette/schema": "^1.2" }, diff --git a/src/DI/BackgroundQueueExtension.php b/src/DI/BackgroundQueueExtension.php index a529e7b..ee99f11 100644 --- a/src/DI/BackgroundQueueExtension.php +++ b/src/DI/BackgroundQueueExtension.php @@ -24,8 +24,9 @@ public function getConfigSchema(): Schema Expect::anyOf( Expect::type('callable'), // callbackName => callback Expect::structure([ // callbackName => callback + queue - 'callback' => Expect::type('callable'), - 'queue' => Expect::string(), + 'callback' => Expect::type('callable')->required(), + 'queue' => Expect::string()->nullable(), + 'priority' => Expect::int()->min(1)->nullable(), ]) ), 'string' @@ -33,7 +34,8 @@ public function getConfigSchema(): Schema 'notifyOnNumberOfAttempts' => Expect::int()->min(1)->required(), 'tempDir' => Expect::string()->required(), 'locksDir' => Expect::string()->required(), - 'queue' => Expect::string()->nullable(), + 'queue' => Expect::string()->required(), + 'priorities' => Expect::arrayOf(Expect::int()->min(1))->default([1])->mergeDefaults(false), 'connection' => Expect::anyOf('string', Expect::arrayOf('int|string|object', 'string')), 'tableName' => Expect::string('background_job'), 'producer' => Expect::string()->nullable(), @@ -61,6 +63,7 @@ public function loadConfiguration(): void $config['callbacks'][$callbackName] = [ 'callback' => $callbackData, 'queue' => null, + 'priority' => null, ]; } }