2017 © Pedro Peláez
 

library mw-gearman

A ZF2 modules that provides a gearman wrapper.

image

mwillbanks/mw-gearman

A ZF2 modules that provides a gearman wrapper.

  • Friday, June 5, 2015
  • by mwillbanks
  • Repository
  • 3 Watchers
  • 21 Stars
  • 429 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 3 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

mwGearman

Version 0.1.0 Created by Mike Willbanks, (*1)

Introduction

mwGearman is a module that handles interfacing with the Gearman extension. This module presently can handle client and worker communication and abstracts portions of task handling. The overall goal is once Zend\Console has been completed to integrate workers into the Console to make building out gearman worker models far more simplistic., (*2)

Requirements

Installation

Composer Your composer.json should include the following., (*3)

{
"repositories": [
        {
            "type": "package",
            "package": {
                "version": "master",
                "name": "mwGearman",
                "source": {
                    "type": "git",
                    "url": "https://github.com/mwillbanks/mwGearman",
                    "reference": "master"
                } 
            }

        }
    ],
    "require": {
            "mwGearman": "master"
        }
}

Git Submodule, (*4)

  • git submodule add [repo-url] ./vendor/mwGearman
  • add 'mwGearman' to your application.config.php file

Usage

DI Configuration for Connection Handling, (*5)

<?php
return array(
    'di' => array(
        'instance' => array(
            'mwGearman\Client\Pecl' => array(
                'parameters' => array(
                    'servers' => array(
                        array('localhost'),
                    ),
                ),
            ),
            'mwGearman\Worker\Pecl' => array(
                'parameters' => array(
                    'servers' => array(
                        array('localhost'),
                    ),
                ),
            ),
        ),
    ),
);

Submitting a Job to Gearman, (*6)

<?php
$gearman = $serviceMananger->get('mwGearman\Client\Pecl');
$gearman->connect();

$workload = 'some-string';

$task = new mwGearman\Task\Task();
$task->setBackground(true)
     ->setFunction('myJob')
     ->setWorkload($workload)
     ->setUnique(crc32($workload));

$handle = $gearman->doTask($task);

Retrieving a Job from Gearman, (*7)

<?php
$gearman = $serviceMananger->get('mwGearman\Worker\Pecl');
$gearman->register('myJob', 'handleJob');
$gearman->connect();
while($gearman->work());

function handleJob($job) {
    $workload = $job->workload();
    echo $workload;
}

Roadmap

  • Integrate Net_Gearman from PEAR
  • Integrate Zend\Console for a BaseWorker

The Versions

05/06 2015

dev-master

9999999-dev https://github.com/mwillbanks/MwGearman

A ZF2 modules that provides a gearman wrapper.

  Sources   Download

The Requires

  • php >=5.3.3

 

The Development Requires

zf2 gearman mwgearman

11/06 2012

dev-topic/connection-and-interface-refactor

dev-topic/connection-and-interface-refactor https://github.com/mwillbanks/mwGearman

A module that implements Gearman

  Sources   Download

The Requires

 

zf2 gearman