Example #1
0
 /**
  * Factory method which allows for easy service creation
  *
  * @param  ClientInterface $client
  * @return self
  */
 public static function factory(\Guzzle\Http\ClientInterface $client)
 {
     $tempAuth = new self();
     if (($client instanceof \OpenCloud\Common\Base || $client instanceof \OpenCloud\OpenStack) && $client->hasLogger()) {
         $tempAuth->setLogger($client->getLogger());
     }
     $tempAuth->setClient($client);
     $tempAuth->setEndpoint(clone $client->getAuthUrl());
     return $tempAuth;
 }
Example #2
0
 /**
  * Factory method which allows for easy service creation
  *
  * @param  ClientInterface $client
  * @return self
  */
 public static function factory(ClientInterface $client)
 {
     $identity = new self();
     if (($client instanceof Base || $client instanceof OpenStack) && $client->hasLogger()) {
         $identity->setLogger($client->getLogger());
     }
     $identity->setClient($client);
     $identity->setEndpoint(clone $client->getAuthUrl());
     return $identity;
 }
Example #3
0
 /**
  * Create a new Socket.
  *
  * @param \ZMQContext     $context      The Context to create this Socket with
  * @param integer         $type         One of the ZMQ::SOCKET_{PUB,SUB,PUSH,PULL,REQ,REP,ROUTER,DEALER} contants.
  * @param LoggerInterface $logger       A Logger
  * @param string          $persistentId When using a persistent socket: the persistence ID
  * @param callable|null   $onNewSocket  Callback to use when a new socket is created
  *
  * @return \AlphaRPC\Common\Socket\Socket
  */
 public static function create($context, $type, LoggerInterface $logger = null, $persistentId = null, $onNewSocket = null)
 {
     if (!is_callable($onNewSocket)) {
         $onNewSocket = null;
     }
     $newSocket = false;
     $callback = function () use($onNewSocket, &$newSocket) {
         $newSocket = true;
         if ($onNewSocket !== null) {
             $onNewSocket();
         }
     };
     $instance = new self($context, $type, $persistentId, $callback);
     $instance->setId(self::$nextId);
     $instance->setNewSocket($newSocket);
     $instance->setSockOpt(ZMQ::SOCKOPT_LINGER, 0);
     self::$nextId++;
     if (null !== $logger) {
         $instance->setLogger($logger);
     }
     return $instance;
 }
Example #4
0
 public static function create(array $config, LoggerInterface $logger = null)
 {
     if (empty($config)) {
         throw new \InvalidArgumentException('Error while creating Deploy Runner, config is empty');
     }
     if (null === $logger) {
         $logger = new NullLogger();
     }
     $self = new self();
     $self->setLogger($logger);
     $servers = $self->getServersFromConfig($config);
     $steps = $self->getStepsFromConfig($config, $servers);
     return new Runner(array_values($steps), $logger);
 }