Git Product home page Git Product logo

majaxpheanstalkplugin's Introduction

To use

Pushing jobs

$pheanstalk = majaxPheanstalk::getInstance();
$pheanstalk->useTube('test_tube')->put('Job data');

To run jobs

Create a worker, modeled after ExampleWorkerThread in lib/thread/, which extends majaxPheanstalkWorkerThread and implements doRun().

<?php

class ExampleWorkerThread extends majaxPheanstalkWorkerThread
{
  protected function doRun()
  {
    $job = $this->getJob('test_tube');
    $data = $job->getData();
    $this->log('Got data: '.$data);
    $this->deleteJob($job);
  }
}

?>

Now you're ready to run the task!

./symfony pheanstalk:run_worker ExampleWorkerThread /path/to/store/log/in/

Easy-peasy

Extended Features

Helper Functions

There are two primary helpers you will need for stateful management.

protected function doConstruct() { }

This is run during __construct(), before Pheanstalk is initialized.

protected function doDestruct() { }

This is run during __destruct()

Configuration Options

memory_limit (10240000 -- 10mb)

You can set how much memory we're allowed to use (in bytes), and we will fail as soon after that as possible.

It is checked before every iteration of doRun().

To change it, in your doConstruct(), simply:

protected function doConstruct()
{
  $this->memory_limit = 8000000;
}

sleep_ms (100000 -- 1/10th of a second)

Number of microseconds (i.e. a millionth of a second, 1000000 == 1 second) to pause for between doRun() iterations.

To change it, in your doConstruct(), simply:

protected function doConstruct()
{
  $this->sleep_ms = 8000000;
}

enable_pheanstalk (true)

Set this to false to not instantize Pheanstalk in the constructor. Use this if you're making a generic worker thread as opposed to a Pheanstalk worker thread.

majaxpheanstalkplugin's People

Contributors

jmather avatar angelsk avatar benlancaster avatar

Stargazers

Janusz Slota avatar

Watchers

Kolba avatar James Cloos avatar Jimmy Wong avatar  avatar

Forkers

nixilla

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.