Search code examples
phpphalconbeanstalkd

what's the difference phalcon beanstalk queue's choose and watch methods


what's the difference between phalcon beanstalk queue's choose and watch methods. the comments of the two are same.

namespace Phalcon\Queue {
        ...
        /**
         * Change the active tube. By default the tube is 'default'
         *
         * @param string $tube
         * @return string|boolean
         */
        public function choose($tube){ }


        /**
         * Change the active tube. By default the tube is 'default'
         *
         * @param string $tube
         * @return string|boolean
         */
        public function watch($tube){ }
        ...
}

Solution

  • "watched" queue is the tube that the client is reserving jobs from. "used" queue is the tube the client is putting jobs into.

    Is it helpful? I think that Phalcon docs here is too short. Should be improved!

    Code of Phalcon 2.0:

    choose() method: https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/queue/beanstalk.zep#L182

    watch() method: https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/queue/beanstalk.zep#L202

    Beanstalkd docs fragment: http://beanstalkc.readthedocs.org/en/latest/tutorial.html#tube-management

    I always read the code of Phalcon 2.0 because it is written in Zephir which looks like PHP and it is easier to understand than the C code of Phalcon 1.x.x