registerClientPooler

Add or replace a Client pooler for the specified type.

@param   ClientPoolerInterface $client_pooler
@return  Session               $this
506767
public function registerClientPooler(ClientPoolerInterface $client_pooler)
    {
        if ($client_pooler->getPoolerType() == null) {
            throw new \InvalidArgumentException("Can not register a pooler for the empty type.");
        }

        $client_pooler->register($this);
        $this->client_poolers[$client_pooler->getPoolerType()] = $client_pooler;
        $this->hasLogger()
            && $this->getLogger()
            ->debug(
                "Pomm: Registering new client pooler.",
                ['type' => $client_pooler->getPoolerType()]
            );

        return $this;
    }
29573
public function register(ContainerInterface $container)
    {
        if (! isset($container['session'])) {
            $container['session'] = function (ContainerInterface $container) {
                return new Session;
            };
        }

        if (! isset($container['router'])) {
            /**
             * This service MUST return a SHARED instance
             * of Mbh\Interfaces\RouterInterface.
             *
             * @param Container $container
             * @return RouterInterface
             */
            $container['router'] = function (ContainerInterface $container) {
                $routerCacheFile = false;
                if (isset($container->get('settings')['routerCacheFile'])) {
                    $routerCacheFile = $container->get('settings')['routerCacheFile'];
                }

                $router = (new Router)->setCacheFile($routerCacheFile);
                if (method_exists($router, 'setContainer')) {
                    $router->setContainer($container);
                }

                if (method_exists($router, 'setCallableResolver')) {
                    $router->setCallableResolver($container['callableResolver']);
                }

                return $router;
            };
        }
    }
603298
public function register($serializer)
    {
        if (is_array($serializer)) {
            foreach ($serializer as $s) {
                $this->register($s);
            }

            return $this;
        }

        if (is_string($serializer)) {
            if (!class_exists($serializer)) {
                throw new SerializersPoolException("Serializer class '{$serializer}' not found");
            }

            $serializer = new $serializer;
        }

        if (!is_object($serializer)) {
            $serializer_type = gettype($serializer);
            throw new SerializersPoolException("Serializer should be object or class name, scalar '{$serializer_type}' given instead");
        }

        if (!is_subclass_of($serializer, 'AMQPy\Serializers\SerializerInterface')) {
            $serializer_class = get_class($serializer);
            throw new SerializersPoolException("Serializer class '{$serializer_class}' doesn't implement default serializer interface");
        }

        $this->registered[$serializer->getContentType()] = $serializer;

        return $this;
    }
443468
private function addClient(ClientInterface $client): self
    {
        $configurations = $this->configResolver->getParameter('configurations', 'ez_platform_automated_translation');
        $reflection     = new \ReflectionClass($client);
        $key            = strtolower($reflection->getShortName());
        if (isset($configurations[$key])) {
            $client->setConfiguration($configurations[$key]);
            $this->clients[$key] = $client;
        }

        return $this;
    }
167084
public function addObserver(ConnectionObserver $observer)
    {
        if (!in_array($observer, $this->observers, true)) {
            $this->observers[] = $observer;
        }
        return $this;
    }
962622
public function addHttpClient($client): void
    {
        if (!$client instanceof HttpClientPoolItem) {
            $client = new HttpClientPoolItem($client);
        }

        $this->clientPool[] = $client;
    }
621563
public function register(ServiceProviderInterface $provider)
    {
        if ($this->frozen) {
            throw new FrozenContainerException(
                'The container is frozen and is not possible to register the provider "' . get_class($provider) . '".'
            );
        }

        $provider->register($this);

        return $this;
    }
825134
protected function _addService(Zend_Server_Reflection_Class $refclass, DOMElement $target)
    {
        foreach ($refclass->getMethods() as $method) {
            if (!$method->isPublic()
                || $method->isConstructor()
                || ('__' == substr($method->name, 0, 2))
            ) {
                continue;
            }

            foreach ($method->getPrototypes() as $proto) {
                $op = $this->_xml->createElement('operation');
                $op->setAttribute('name', $method->getName());

                $rettype = $this->_registerType($proto->getReturnType());
                $op->setAttribute('returnType', $rettype);

                foreach ($proto->getParameters() as $param) {
                    $arg = $this->_xml->createElement('argument');
                    $arg->setAttribute('name', $param->getName());

                    $type = $param->getType();
                    if ($type == 'mixed' && ($pclass = $param->getClass())) {
                        $type = $pclass->getName();
                    }

                    $ptype = $this->_registerType($type);
                    $arg->setAttribute('type', $ptype);

                    if($param->isDefaultValueAvailable()) {
                        $arg->setAttribute('defaultvalue', $param->getDefaultValue());
                    }

                    $op->appendChild($arg);
                }

                $target->appendChild($op);
            }
        }
    }
5657
protected function changeQueueCount($queueCounter)
    {
        if ($queueCounter < 0) {
            $queueCounter = 0;
        }
        $this->_poolClientQueueCounter = $queueCounter;
        //Automatically change client state to `ClientInterface::CLIENT_POOL_STATE_READY` on empty queue
        if ($this->_poolClientQueueCounter === 0 && $this->_poolClientState === PoolClientInterface::CLIENT_POOL_STATE_BUSY) {
            $this->changeState(PoolClientInterface::CLIENT_POOL_STATE_READY);
        } elseif ($this->_poolClientQueueCounter > 0 && $this->_poolClientState === PoolClientInterface::CLIENT_POOL_STATE_READY) {
            $this->changeState(PoolClientInterface::CLIENT_POOL_STATE_BUSY);
        }
        $this->emit(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE, [$queueCounter]);
    }
367058
private function registerClients(array $config, ContainerBuilder $container)
    {
        foreach ($config['clients'] as $clientType => $clients) {
            $clientFQCN = ($clientType == 'apns') ? 'LinkValue\MobileNotifBundle\Client\ApnsClient' : 'LinkValue\MobileNotifBundle\Client\GcmClient';

            foreach ($clients as $clientName => $clientConfig) {
                $params = isset($clientConfig['params']) ? $clientConfig['params'] : array();
                $services = isset($clientConfig['services']) ? $clientConfig['services'] : array();

                // The final client name is a concatenation of the client type (apns/gcm) and the client name (defined by user) separated by a point '.'
                $clientName = sprintf('%s.%s', $clientType, $clientName);

                // Register client with required stuff
                $client = $container->register(sprintf('link_value_mobile_notif.clients.%s', $clientName), $clientFQCN)
                    ->addMethodCall('setUp', array($params))
                    ->addTag('link_value_mobile_notif.client', array('name' => $clientName))
                ;

                // Set optional logger
                if(!empty($services['logger'])) {
                    $client->addMethodCall('setLogger', array(new Reference($services['logger'])));
                }

                // Set optional profiler
                if(!empty($services['profiler'])) {
                    $client->addMethodCall('setClientProfiler', array(new Reference($services['profiler'])));
                }
            }
        }
    }
1267005
public void setClientContainer(boolean clientContainer) // F48603.7
    {
        setOwningFlow(clientContainer ? ReferenceFlowKind.CLIENT : null);
        if (isClientContainer() && ivInjectionClasses != null && !ivInjectionClasses.isEmpty()) {
            ivClientMainClass = ivInjectionClasses.get(0);
        }
    }
1237959
public function add(ProviderInterface $provider)
    {
        $container = $this->container;

        $this->container = $provider->register($container);

        $this->providers[] = (string) get_class($provider);

        return $this;
    }
974126
public function addBatchRequest(ClientRequestInterface $request)
    {
        if ($request instanceof ContextAwareInterface) {
            $request->setContextIfNull($this->getConfig()->getContext());
        }
        $this->batchRequests[] = $request;
        return $this;
    }
1185802
public function register(ServiceProviderInterface $provider, array $values = [])
    {
        $this->container->register($provider, $values);
        // register event subcriber
        if ($provider instanceof EventSubscriberInterface) {
            $this->eventSubscribers[] = $provider;
        }

        return $this;
    }
929852
public final function register(CacheInterface $container): ServiceInterface
   {
       foreach ($this->service as $key => &$value) {
           $container->set($key, $value);
       }
       return $this;
   }
393697
def connect(self, client: BasicClient, *args, **kwargs):
        
        self.clients.add(client)
        self.connect_args[client] = (args, kwargs)
        # hack the clients event loop to use the pools own event loop
        client.eventloop = self.eventloop
772017
public static Client using(final Configuration configuration, final ClientConsumerType type, final int poolSize) throws Exception {
    return new Client(configuration, type, poolSize);
  }