pdezwart/php-amqp — pull request #13 by narkq (2012-11-06 00:12:48+00:00)
Title: Feature request: set connection timeout

There is currently no way to set a connection timeout through the API.

This is really sad when you're trying to use `AMQPQueue::consume` in a web server environment. If you've got no messages in 5-10 seconds, most likely this request will be canceled by user, and it makes more sense to report a timeout than to hang there indefinitely waiting for a message. I know that AMQP 0.9.1 spec doesn't support connection timeouts, but I think this feature is important enough.

This pull request adds the following:
- INI setting `amqp.timeout`
- `AMQPConnection::getTimeout` method
- `AMQPConnection::setTimeout` method. If connection is already established, timeout is set immediately. Otherwise, timeout is set next time connection is established.
- `timeout` option for `AMQPConnection::__construct`
- every method that reads from channel can throw `AMQPConnectionException` now
- `AMQPConnectionException::getCode` returns an error code from librabbitmq
- `AMQP_OS_SOCKET_TIMEOUT_ERRNO` constant to distinguish timeouts from any other connection error