Skip to content

Commit 755d9ad

Browse files
author
Jamie Hannaford
committed
Merge pull request rackspace#649 from dansoap/loadbalancer-add-nodes-multi-request
refactored load balancer node adding to use one request instead of se…
2 parents 97a6739 + 8401e0e commit 755d9ad

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/OpenCloud/LoadBalancer/Resource/LoadBalancer.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,20 @@ public function addNodes()
255255
);
256256
}
257257

258-
$requests = array();
258+
$requestData = array('nodes' => array());
259259

260+
/** @var Node $node */
260261
foreach ($this->nodes as $node) {
261262
// Only add the node if it is new
262263
if (null === $node->getId()) {
263-
$json = json_encode($node->createJson());
264-
$requests[] = $this->getClient()->post($node->getUrl(), self::getJsonHeader(), $json);
264+
$nodeJson = $node->createJson();
265+
$requestData['nodes'][] = $nodeJson['nodes'][0];
265266
}
266267
}
267268

268-
return $this->getClient()->send($requests);
269+
$request = $this->getClient()->post($node->getUrl(), self::getJsonHeader(), json_encode($requestData));
270+
271+
return $this->getClient()->send($request);
269272
}
270273

271274
/**

0 commit comments

Comments
 (0)