Giter Club home page Giter Club logo

net_gearman's People

Contributors

bdeshong avatar bkw avatar brianlmoon avatar ddebin avatar dynamicnet avatar eschultz avatar etienneq avatar j03k64 avatar joestump avatar lenn0x avatar rokclimb15 avatar strayer avatar till avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

net_gearman's Issues

Package name

Hi ,

Most of the package names in composer are making use of hyphen. So I feel it will be good to change brianlmoon/net_gearman to brianlmoon/net-gearman . Your thoughts on this ?

No task by that handle

What this error i got means: "No task by that handle"?
I see what all works as expected, and when worker is fall down, i receive this exception. Even if worker is started again
I run tasks in loop, code below:

try
                {

                    $reqData = ...

$set = new \Net_Gearman_Set();
            $task = new \Net_Gearman_Task('exchange', [$reqData]);
            $task->attachCallback(function () {
                $commands = (array) func_get_arg(2);
$this->execCommands($commands);
            });
            $set->addTask($task);

		//do exchange
            $client->runSet($set, 10);
                }
                catch (\Exception $ex)
                {
                    //TODO HANDLE ME
                    var_dump($ex->getMessage(), $ex->getTraceAsString());
                }

012-client-runSet.phpt

The 012-client-runSet.phpt test fails for me always.

And I can't figure out why: ** ERROR: process timed out **

Try:

cd tests/
pear run-tests 012-client-runSet.phpt

Determine if no job servers were connected to

I didn't see an easy way to determine if connecting to all job servers failed. There's a protected $conn array which could be checked for length but I wasn't sure if there was a better way.

If not I'm happy to submit a pull request to add a method to get a count of servers that have been connected to.

Handling Job Retries Elegantly

Hi Brian. I was looking at this: brianlmoon/GearmanManager#87 . I also looked at your WORK_EXCEPTION issue you create here awhile back.

Basically, I want a worker to retry itself x times and then call support.

Here the worker does a call to exec(), and the output of that command indicates whether the process should be retried.

Am I failing to grasp the preferred approach? Thanks!

class Net_Gearman_Job_UntrustworthyJob extends \Net_Gearman_Job_Common {
    public function run($args) {
        $retries = $args['retries'];
        $max_retries = $args['max_retries'];
        $job_server = $args['job_server'];
        $whatever = $args['parameter'];
        $command = PHP_BINDIR . '/php command_might_be_doomed ' . $whatever;
        exec($command, $lines);
        if (end($lines) != 'COMPLETE')) {
            if ($retries == $max_retries) {
                // Create Case in Zendesk for Developer with the $args and other relevant details.
            }
            else {
                // add Job again, incrementing the $args['retries'].
                $args['retries']++;
                $gmclient= new \Net_Gearman_Client($job_server);
                $result = $gmclient->UntrustworthyJob($args);
            }
        }
    }
}

Any support for context?

I am unable to find any support for context as provided in GearmanClient::addTask. Any information on it is appreciated. TIA!

Suddenly gearman workers start refusing jobs but works fine after restart.

Hi Brain

We are running an application for which we are using gearman. We are facing a strange issue with workers, We have 6 jobs created for the workers, which workers process nicely but out of a sudden couple of the job's stops getting processed or workers don't accept any requests for them but rest of the jobs are behaving normally. I have exceeded the verbose level for gearman-manger to crazy (-vvvvv) to track the issue but I was not able to find any clue in the logs of gearman-manager. After that, i have turned on the DEGUG log level for gearmanD but still, I was not able to track the issue.

Everything works fine after I restart the gearman workers. I have pasted the gearmand and gearman-manager config file below. Please help me to identify the issue.
Thanks.

##########################
gearman-manager/config.ini
##########################
[GearmanManager]

; workers can be found in this dir

host=127.0.0.1
worker_dir=/etc/gearman-manager/workers

; Reload workers as new code is available
;auto_update=1

; 3 workers will do all jobs
count=3

; Workers will only live for 25 Minutes.
max_worker_lifetime=600


####################
gearmand.conf
####################
description "Gearmand Server"

start on started mysql
stop on runlevel [016]
kill timeout 3
respawn
exec gearmand
--listen=127.0.0.1
--log-file=/var/log1/gearmand/gearmand.log
--verbose=DEBUG
--job-retries=2
--queue-type=MySQL
--mysql-host=localhost
--mysql-port=3306
--mysql-user=gearman
--mysql-password=gearman
--mysql-db=gearman
--mysql-table=gearman_01
2>> /var/log/gearmand.log
~

If connection drops in the middle of worker init, then socket is not connected, but Worker destruct still tries to blindly write to it

[vendor/brianlmoon/net_gearman/Net/Gearman/Connection.php:283] "socket_write() expects parameter 1 to be resource, null given"
Utils/Gearman/GearmanPearManager.php:100 call_user_func_array(, )
Utils\Gearman\GearmanPearManager->Utils\Gearman{closure}(2, "socket_write() expects parameter 1 to be resource, null given", "vendor/brianlmoon/net_gearman/Net/Gearman/Connection.php", 283, )
vendor/brianlmoon/net_gearman/Net/Gearman/Connection.php:283 socket_write("", "REQ", 12)
vendor/brianlmoon/net_gearman/Net/Gearman/Worker.php:739 send("reset_abilities")
vendor/brianlmoon/net_gearman/Net/Gearman/Worker.php:730 close("gearman1")
vendor/brianlmoon/net_gearman/Net/Gearman/Worker.php:756 endWork()
Net_Gearman_Worker->__destruct()

PHP 8.1 Notices

Hello,

First, many thanks for your work in the Gearman/PHP space !
The lib emit some notices about return types when running under PHP 8.1.
Did you have plan to fix them ?

Otherwise I can take time to fix them and send a pull request, maybe in the next week.

Let me know

David

socket_set_block causing close latency

I have been a long time user of and much older version of this library. Recently I started messing with the most recent and noticed it is much slower when running side by side (same gearman server and everything else). When I stepped through the code, I found that the culprit was socket_set_block() inside of Connection::close

When I comment that out, it runs without the 1-2 second close() delay. Of course, who knows what the collateral damage is from commenting it out :-)

fix for package.xml

diff --git a/package.xml b/package.xml
index 2cec145..9345892 100644
--- a/package.xml
+++ b/package.xml
@@ -94,7 +94,7 @@
                       role="test" />
                 <file name="012-client-runSet.phpt"
                       role="test" />
-                <file name="tests-config.php"
+                <file name="tests-config.php-dist"
                       role="test" />
             </dir>
         </dir>

Could not find package brianlmoon/net_gearman at any version for your minimum-stability

Hello,
I am trying to install your GearmanManager and I need this package.
In order to install I prefer always composer so I used the instructions that you have on the readme.
But it's not working because the minimum stability I need is stable.
So to download the package I wrote on my composer.


"require": {
                "brianlmoon/net_gearman": "@dev"
	}

Because with Composer I couldn't do it otherwise.

Returning data from a function

I am having problem getting data back from a function. If I go to the php manual, with task you can send a return parameter that you can use later. But here I dont seem to be able to pass that parameter.

class GearmanTest
{
static function workCB($func, $handle, $result){
var_dump($result);
}

function doWork($param)
{
$client = new Net_Gearman_Client("localhost");
$set = new Net_Gearman_Set();
$task = new Net_Gearman_Task("gearman_function", $param);

    $task->attachCallback('GearmanTest::workCB');
    $set->addTask($task);
    $client->runSet($set);

    return WHAT???**********************

}

}

//using it here
$engine = new GearmanTest();
$out = $engine->doWork('123'); //dont know how to return the out data

Regarding a Binary Argument and the Gearman MySQL Queue

Hello Brian -

Awesome stuff. The following may not be a net_gearman "issue", and I outline a resolution, but I can't be the only one that has face-planted on it. Wondering what you can say about it.

When it come to using gearman with mysql queue turned on, I have found that the only way I can have success in passing binary data as one of multiple arguments is to base64_encode the data first. I later decode it with a worker. The file string in question is read from a PDF file.

Without thus forcing the string to a longer utf8, the job just sits in MySQL with an empty "data" field. The worker fails because the arguments never arrive.

Does this sound about right to you? I'm not overjoyed by the extra base64 processing. Now that I have a grasp of a solution, I may well shove the binary data into a different table as a proper blob and pass the id of that row as the argument instead.

But that just seems wrong. The argument field is already a long blob. Perhaps the reason why tutorials show binary objects as arguments is because they use no extra persistence mechanism, or use memcache?

Anyway, thanks, one way or the other!

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.