library/TaskDaemon/TaskDaemon.php
public function runTask($name, $data = null, $allowDuplicates = false)
    {
        $options = static::getOptions();
        $debug = @$options['debug'] === true;

        if ($debug)
            echo "==> Trying to run task: $name" . PHP_EOL;

        $function = $options['namespace'] . '-' . $name;
        $data = json_encode($data);
        if ($allowDuplicates)
            $unique = self::generateUnique();
        else
            $unique = md5($function . '-' . $data);

        $gmClient = new GearmanClient();
        $gmClient->addServer($options['gearman']['host'], $options['gearman']['port']);

        $gmClient->doBackground($function, $data, $unique);
        $code = $gmClient->returnCode();
        if ($code != GEARMAN_SUCCESS)
            throw new \Exception("Could not run task: $name ($code)");

        return $this;
    }
public function runTask($name, $data = null, $allowDuplicates = false)
    {
        $options = static::getOptions();
        $debug = @$options['debug'] === true;

        if ($debug)
            echo "==> Trying to run task: $name" . PHP_EOL;

        $function = $options['namespace'] . '-' . $name;
        $data = json_encode($data);
        if ($allowDuplicates)
            $unique = self::generateUnique();
        else
            $unique = md5($function . '-' . $data);

        $gmClient = new GearmanClient();
        $gmClient->addServer($options['gearman']['host'], $options['gearman']['port']);

        $gmClient->doBackground($function, $data, $unique);
        $code = $gmClient->returnCode();
        if ($code != GEARMAN_SUCCESS)
            throw new \Exception("Could not run task: $name ($code)");

        return $this;
    }
public function runTask ( $ name , $ data = null , $ allowDuplicates = false ) { $ options = static :: getOptions ( ) ; $ debug = @ $ options [ 'debug' ] === true ; if ( $ debug ) echo "==> Trying to run task: $name" . PHP_EOL ; $ function = $ options [ 'namespace' ] . '-' . $ name ; $ data = json_encode ( $ data ) ; if ( $ allowDuplicates ) $ unique = self :: generateUnique ( ) ; else $ unique = md5 ( $ function . '-' . $ data ) ; $ gmClient = new GearmanClient ( ) ; $ gmClient -> addServer ( $ options [ 'gearman' ] [ 'host' ] , $ options [ 'gearman' ] [ 'port' ] ) ; $ gmClient -> doBackground ( $ function , $ data , $ unique ) ; $ code = $ gmClient -> returnCode ( ) ; if ( $ code != GEARMAN_SUCCESS ) throw new \ Exception ( "Could not run task: $name ($code)" ) ; return $ this ; }
Add known task to the run queue

@param string $name
@param mixed $data
@param boolean $allowDuplicates
@return TaskDaemon
Add known task to the run queue