Skip to content

Commit ec7fba5

Browse files
author
wangjichao
committed
添加 context, keepalive, heartbeat参数支持
1 parent 52d1ce9 commit ec7fba5

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

amqplibconnector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ function GetConnectionObject($details)
9797
null,
9898
'en_US',
9999
$details['socket_connect_timeout'],
100-
$details['socket_timeout']
100+
$details['socket_timeout'],
101+
$details['context'],
102+
$details['keepalive'],
103+
$details['heartbeat']
101104
);
102105

103106
$this->waitChan = new \chan(1);

celery.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ function __construct($host, $login, $password, $vhost,
103103
$exchange = 'celery', $binding = 'celery', $port = 5672,
104104
$confirmAckCallback = null, $confirmNAckCallback = null, $returnCallback = null,
105105
$connector = false, $result_expire = 0, $socket_connect_timeout = 3.0, $socket_timeout = 3.0,
106-
$persistent_messages = false,
107-
$ssl_options = array())
106+
$persistent_messages = false, $ssl_options = array(), $context = null, $keepalive = false, $heartbeat = 0)
108107
{
109108
$broker_connection = array(
110109
'host' => $host,
@@ -122,6 +121,9 @@ function __construct($host, $login, $password, $vhost,
122121
'socket_connect_timeout' => $socket_connect_timeout,
123122
'socket_timeout' => $socket_timeout,
124123
'ssl_options' => $ssl_options,
124+
'context' => $context,
125+
'keepalive' => $keepalive,
126+
'heartbeat' => $heartbeat
125127
);
126128
$backend_connection = $broker_connection;
127129

@@ -166,11 +168,13 @@ abstract class CeleryAbstract
166168
private $backend_connection = null;
167169
private $backend_connection_details = array();
168170
private $backend_amqp = null;
169-
170171
private $origin = null;
171-
172172
private $isConnected = false;
173173

174+
/**
175+
* check broker connection
176+
* @return mixed
177+
*/
174178
public function getBrokerConnectStatus()
175179
{
176180
return $this->broker_connection->isConnected();
@@ -183,14 +187,16 @@ private function SetDefaultValues($details)
183187
"vhost" => "", "exchange" => "celery", "binding" => "celery",
184188
"port" => 5672, 'confirm_ack_callback' => [], 'confirm_nack_callback' => [],
185189
'return_callback' => [], "connector" => false, "persistent_messages" => false,
186-
"result_expire" => 0, 'socket_connect_timeout' => 3.0, 'socket_timeout' => 3.0, "ssl_options" => array());
190+
"result_expire" => 0, 'socket_connect_timeout' => 3.0, 'socket_timeout' => 3.0,
191+
"ssl_options" => array(), 'context' => null, 'keepalive' => false, 'heartbeat' => 0
192+
);
187193

188194
$returnValue = array();
189195

190196
foreach (array('host', 'login', 'password', 'vhost', 'exchange', 'binding', 'port',
191197
'confirm_ack_callback', 'confirm_nack_callback', 'return_callback', 'connector',
192198
'persistent_messages', 'result_expire', "result_expire", 'socket_connect_timeout',
193-
'socket_timeout', 'ssl_options') as $detail) {
199+
'socket_timeout', 'ssl_options', 'context', 'keepalive', 'heartbeat') as $detail) {
194200
if (!array_key_exists($detail, $details)) {
195201
$returnValue[$detail] = $defaultValues[$detail];
196202
} else $returnValue[$detail] = $details[$detail];

0 commit comments

Comments
 (0)