-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I report status from a worker? #87
Labels
Comments
Maybe this process could be documented. |
Definitely and I am happy to do it once I understand the process better. Please can you provide the necessary steps for implementing and using an status callback event listener e.g.
|
Ok, good first aprox. Some hints :)
<?php
/**
* My project 2014
*/
namespace My\Bundle\AdminBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
use Psr\Log\LoggerInterface;
use Mmoreram\GearmanBundle\Event\GearmanClientCallbackStatusEvent;
/**
* EventListener for UpdateImageSize
*/
class UpdateImageSizeEventListener
{
/**
* @var LoggerInterface
*
* Logger
*/
protected $logger;
/**
* Construct method
*
* @param LoggerInterface $logger Logger
*/
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* Subscriber to onStatus event
*
* @param GearmanClientCallbackStatusEvent $event Event
*
* @return UpdateImageSizeEventListener self Object
*/
public function onStatus(GearmanClientCallbackStatusEvent $event)
{
$this->logger->info('this ran');
$task = $event->getGearmanTask();
$response = new Response();
$response->setContent($task->taskDenominator(), $task->taskNumerator());
$event->setResponse($response);
}
} |
BTW, I'll se what are you asking me to fill ... |
@mmoreram any update on this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've written a worker and can fire this from a dummy gearman client. Which methods allow me to report job status? I want to report status as the job progresses.
I see that status callback is provided as a kernel event but am not sure how to implement this. Do I need to write an Event listener? Does it matter if my worker is not defined as a service? Is there an example anywhere?
The text was updated successfully, but these errors were encountered: