Skip to content

Commit

Permalink
Added interface for pausing features
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Wolf committed Feb 17, 2015
1 parent 4ea1576 commit 0e1b8b6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
Expand Up @@ -103,7 +103,7 @@ public function startProcessing(Task\TaskInterface $task)
// if Blitline's having server side problems (in case of 5xx errors).
// Either way, we need to fail...
throw new Exception\ProcessingFailedException(
sprintf('Processing failed immediately after submitting the job: %s',$e->getMessage()),
sprintf('Processing failed immediately after submitting the job: %s', $e->getMessage()),
0,
$e
);
Expand Down Expand Up @@ -145,7 +145,7 @@ public function checkProcessing(Task\TaskInterface $task)
// if Blitline's having server side problems (in case of 5xx errors).
// Either way, we need to fail...
throw new Exception\ProcessingFailedException(
sprintf('Processing failed after polling for the completion of the job: %s',$e->getMessage()),
sprintf('Processing failed after polling for the completion of the job: %s', $e->getMessage()),
0,
$e
);
Expand Down
@@ -0,0 +1,29 @@
<?php

namespace Detail\FileConversion\Processing;

use DateTime;

interface PausableTaskProcessorInterface
{
/**
* @param DateTime $until
* @return DateTime
*/
public function pauseProcessing(DateTime $until = null);

/**
* @return void
*/
public function resumeProcessing();

/**
* @return DateTime|boolean
*/
public function getPausedUntil();

/**
* @return boolean
*/
public function isPaused();
}
8 changes: 5 additions & 3 deletions src/Detail/FileConversion/Processing/TaskProcessor.php
Expand Up @@ -6,7 +6,8 @@
use DateTime;

class TaskProcessor implements
TaskProcessorInterface
TaskProcessorInterface,
PausableTaskProcessorInterface
{
/**
* @var AdapterManagerInterface
Expand Down Expand Up @@ -96,7 +97,7 @@ public function setPauseOnIncident($pauseOnIncident)
{
if (is_string($pauseOnIncident)) {
$pauseOnIncident = DateInterval::createFromDateString($pauseOnIncident);
} else if (!$pauseOnIncident instanceof DateInterval) {
} elseif (!$pauseOnIncident instanceof DateInterval) {
throw new Exception\InvalidArgumentException(
'$pauseOnIncident must be a valid date string or DateInterval object'
);
Expand Down Expand Up @@ -248,7 +249,8 @@ protected function getAdapter(Task\TaskInterface $task)
*/
protected function callAdapter(
Adapter\AdapterInterface $adapter,
$method, array $arguments = array(),
$method,
array $arguments = array(),
$considerPaused = true
) {
if ($considerPaused !== false && $this->isPaused()) {
Expand Down

0 comments on commit 0e1b8b6

Please sign in to comment.