The following code is a snipet taken from an example of pheanstalk being implemented and working properly (obtained from pheanstalk's github page: https://github.com/pda/pheanstalk):
<?php
require_once("vendor/autoload.php");
use Pheanstalk\Pheanstalk;
$pheanstalk = new Pheanstalk('127.0.0.1');
// ------------ producer (queues jobs):
$pheanstalk
->useTube('testtube')
->put("job payload goes here\n");
// ------------ worker (performs jobs):
$job = $pheanstalk
->watch('testtube')
->ignore('default')
->reserve();
echo $job->getData();
$pheanstalk->delete($job);
// ------------ check server availability
$pheanstalk->getConnection()->isServiceListening(); // true or false
QUESTIONS:
What I don't understand are the following parts:
I am assuming that the newline spaces in the
producer
code don't make any difference in the execution, so this line would be equivalent:$pheanstalk->useTube('testtube')->put("job payload goes here\n");
correct? If that is true, then do those specific function calls have to be in that order, or can they be in any order? My previous understanding of functions and classes in php was that you would directly call a function from an object of it's class type: $object->classFunction()
, however is the above code a valid php technique where you can call all those functions simultaneously or is it something special to pheanstalk?
What is the
ignore('default')
code doing?What is the
$pheanstalk->getConnection()->isServiceListening();
code doing?