Skip to content

Discussion: QueueManager::push $callable Argument #78

@amayer5125

Description

@amayer5125

Currently the first argument of QueueManager::push accepts a callable which is passed to Enqueue\Client\Message. Since all cake jobs should implement Cake\Queue\Job\JobInterface our $callable value will always be an array where the second value is 'execute'. To make using the queue as easy as possible for all users it would be nicer to accept a string as the first argument of the push method which would be a fully qualified class name. This will make the code read easier and will be simpler to use.

Example of current usage:

QueueManager::push([HelloJob::class, 'execute'], ['name' => 'Alex']);

Proposed usage:

QueueManager::push(HelloJob::class, ['name' => 'Alex']);

If we accepted the FQCN as the first argument we could then construct the callable array for the user when we create the Enqueue\Client\Message. Something like:

$message = new ClientMessage([
    'queue' => $queue,
    'class' => [$firstArgClassNameVariable, 'execute'],
    'args' => [$args],
]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions