Create a function which can be used to create ClientStreamingCall

@param Channel|InterceptorChannel   $channel
@param callable $deserialize A function that deserializes the response

@return \Closure
2477
private function _StreamUnaryCallFactory($channel)
    {
        if (is_a($channel, 'Grpc\Internal\InterceptorChannel')) {
            return function ($method,
                             $deserialize,
                             array $metadata = [],
                             array $options = []) use ($channel) {
                return $channel->getInterceptor()->interceptStreamUnary(
                    $method,
                    $deserialize,
                    $metadata,
                    $options,
                    $this->_StreamUnaryCallFactory($channel->getNext())
                );
            };
        }
        return $this->_GrpcStreamUnary($channel);
    }
1140867
public RequestChannel getRequestChannel(Object client)
    {
        try {
            InvocationHandler genericHandler = Proxy.getInvocationHandler(client);
            ThriftInvocationHandler thriftHandler = (ThriftInvocationHandler) genericHandler;
            return thriftHandler.getChannel();
        }
        catch (IllegalArgumentException | ClassCastException e) {
            throw new IllegalArgumentException("Invalid swift client object", e);
        }
    }
709793
private static function run(Channel $channel, Socket\ClientSocket $socket = null): Promise
    {
        /** @noinspection PhpDeprecationInspection */
        self::$client = new IpcClient(self::callableFromStaticMethod("onReceivedMessage"), $channel, $socket);

        return call(static function () {
            try {
                yield self::$client->run();
            } catch (\Throwable $exception) {
                // Exception rethrown below as part of MultiReasonException.
            }

            list($exceptions) = yield self::terminate();

            if (isset($exception)) {
                $exceptions[] = $exception;
            }

            try {
                yield self::$client->close();
            } catch (\Throwable $exception) {
                $exceptions[] = $exception;
            }

            self::$client = null;

            if (!empty($exceptions)) {
                $exception = new MultiReasonException($exceptions);
                $message = \implode('; ', \array_map(function (\Throwable $exception): string {
                    return $exception->getMessage();
                }, $exceptions));
                throw new ClusterException("Cluster worker failed: " . $message, 0, $exception);
            }
        });
    }
1325222
private function intercept(array &$interceptors, &$request, &$method, &$metadata, &$options, callable $callback)
    {
        /** @var Client\Interceptors\Base $i */
        $i = array_shift($interceptors);
        if ($i) {
            $i->setRequest($request);
            $i->setMethod($method);
            $i->setMetadata($metadata);
            $client = $this->getClient();
            $i->setStub($client);
            return $i->call(function () use (
                &$i,
                &$interceptors,
                &$method,
                &$request,
                &$metadata,
                &$options,
                &$callback
            ) {
                $metadata = $i->getMetadata();
                $request = $i->getRequest();
                if (count($interceptors) > 0) {
                    return $this->intercept($interceptors, $request, $method, $metadata, $options, $callback);
                } else {
                    return $callback();
                }
            });
        } else {
            return $callback();
        }
    }
35253
public function call(string $method, RequestInterface $request)
    {
        try {
            $parameters = $request->toArray();

            return $this->__soapCall($method, ['parameters' => $parameters]);
        } catch (\Exception $exception) {
            if ($this->debug) {
                throw ClientException::create($this, $exception);
            }

            throw new ClientException($exception->getMessage(), $exception->getCode(), $exception);
        }
    }
1038650
public function createClient($identifier, array $redirect_uris = array(), array $grant_types = array(), array $scopes = array())
    {
        $client = new \OAuth2\ServerBundle\Entity\Client();
        $client->setClientId($identifier);
        $client->setClientSecret($this->generateSecret());
        $client->setRedirectUri($redirect_uris);
        $client->setGrantTypes($grant_types);

        // Verify scopes
        foreach ($scopes as $scope) {
            // Get Scope
            $scopeObject = $this->sm->findScopeByScope($scope);
            if (!$scopeObject) {
                throw new ScopeNotFoundException();
            }
        }

        $client->setScopes($scopes);

        // Store Client
        $this->em->persist($client);
        $this->em->flush();

        return $client;
    }
951297
public function call($method = 'GET', $uri = null, $headers = null, $body = null, array $options = array(), $classToUnserialize = null)
    {
        $request = $this->client->createRequest($method, $uri, $headers, $body, $options);

        if ($classToUnserialize) {
            return $this->serializer->deserialize(
                (string) $this->send($request)->getBody(),
                $classToUnserialize,
                'xml'
            );
        }

        return $this->send($request);
    }
850798
public function processRequest(Request $request)
    {
        return reactAdapt(\Amp\call(function () use ($request) {
            /** @var Response $response */
            $response = yield $this->client->request($request);

            if ($response->getStatus() >= 400) {
                throw new ClientException($response->getReason(), $response->getStatus());
            }

            return new TelegramResponse(yield $response->getBody(), $response->getHeaders());
        }));
    }
161857
protected function getStreamingWrapperCreator()
    {
        return function ($connection, $callback) {
            return function ($state, $response) use ($connection, $callback) {
                \call_user_func($callback, $response, $connection, null);
            };
        };
    }
615163
public function attributeUseHandler(
        string $attribute,
        Type\HandlerDeserializerInterface $deserialize,
        Type\HandlerSerializerInterface $serialize
    ): ObjectInterface {
        return $this;
    }
703839
private function createSerializer()
    {
        return SerializerBuilder::create()
            ->setPropertyNamingStrategy(new IdenticalPropertyNamingStrategy())
            ->configureListeners(function (EventDispatcher $dispatcher) {
                $dispatcher->addListener('serializer.post_deserialize',
                    function (ObjectEvent $event) {
                        $object = $event->getObject();
                        if ($object instanceof ClientAwareInterface) {
                            $object->setClient($this);
                        }
                    }
                );

                $dispatcher->addListener('serializer.post_serialize',
                    function (ObjectEvent $event) {
                        $options = $event->getContext()->attributes->get('options')->getOrElse(array());
                        $visitor = $event->getVisitor();

                        if ($visitor instanceof GenericSerializationVisitor) {
                            foreach ($options as $key => $value) {
                                $visitor->addData($key, $value);
                            }
                        }
                    }
                );
            })
            ->build();
    }
765494
def wrap_insecure_channel(insecure_channel_func, tracer=None):
    """"""
    def call(*args, **kwargs):
        channel = insecure_channel_func(*args, **kwargs)

        try:
            target = kwargs.get('target')
            tracer_interceptor = OpenCensusClientInterceptor(tracer, target)
            intercepted_channel = grpc.intercept_channel(
                channel, tracer_interceptor)
            return intercepted_channel  # pragma: NO COVER
        except Exception:
            log.warning(
                'Failed to wrap insecure channel, '
                'clientlibs grpc calls not traced.')
            return channel
    return call
478700
public static ManagedChannel newClientChannel(Transport transport, SocketAddress address,
        boolean tls, boolean testca, @Nullable String authorityOverride,
        int flowControlWindow, boolean directExecutor) {
    ManagedChannelBuilder<?> builder;
    if (transport == Transport.OK_HTTP) {
      builder = newOkHttpClientChannel(address, tls, testca);
    } else {
      try {
        builder = newNettyClientChannel(transport, address, tls, testca, flowControlWindow);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    if (authorityOverride != null) {
      builder.overrideAuthority(authorityOverride);
    }

    if (directExecutor) {
      builder.directExecutor();
    } else {
      // TODO(carl-mastrangelo): This should not be necessary.  I don't know where this should be
      // put.  Move it somewhere else, or remove it if no longer necessary.
      // See: https://github.com/grpc/grpc-java/issues/2119
      builder.executor(getExecutor());
    }

    return builder.build();
  }
156734
static <R, W> ConnectionImpl<R, W> create(Channel nettyChannel,
                                                                     ChannelOperations<W> delegate) {
        final ConnectionImpl<R, W> toReturn = new ConnectionImpl<>(nettyChannel, delegate);
        toReturn.connectCloseToChannelClose();
        return toReturn;
    }
295434
function _getClientStreamingInterceptor(method_definition, channel, emitter,
  callback) {
  var serialize = common.wrapIgnoreNull(method_definition.requestSerialize);
  var deserialize = method_definition.responseDeserialize;
  return function (options) {
    var first_listener;
    var call = getCall(channel, method_definition.path, options);
    var final_requester = {};
    final_requester.start = function (metadata, listener) {
      var metadata_batch = {
        [grpc.opType.SEND_INITIAL_METADATA]: metadata._getCoreRepresentation(),
        [grpc.opType.RECV_INITIAL_METADATA]: true
      };
      first_listener = listener;
      call.startBatch(metadata_batch, function (err, response) {
        if (err) {
          // The call has stopped for some reason. A non-OK status will arrive
          // in the other batch.
          return;
        }
        response.metadata = Metadata._fromCoreRepresentation(response.metadata);
        listener.onReceiveMetadata(response.metadata);
      });
      var recv_batch = {};
      recv_batch[grpc.opType.RECV_MESSAGE] = true;
      recv_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
      call.startBatch(recv_batch, function (err, response) {
        response.status.metadata = Metadata._fromCoreRepresentation(
          response.status.metadata);
        var status = response.status;
        var deserialized;
        if (status.code === constants.status.OK) {
          if (err) {
            // Got a batch error, but OK status. Something went wrong
            callback(err);
            return;
          } else {
            try {
              deserialized = deserialize(response.read);
            } catch (e) {
              /* Change status to indicate bad server response. This will result
               * in passing an error to the callback */
              status = {
                code: constants.status.INTERNAL,
                details: 'Failed to parse server response'
              };
            }
          }
        }
        listener.onReceiveMessage(deserialized);
        listener.onReceiveStatus(status);
      });
    };
    final_requester.sendMessage = function (chunk, context) {
      var message;
      var callback = (context && context.callback) ?
        context.callback :
        function () { };
      var encoding = (context && context.encoding) ?
        context.encoding :
        '';
      try {
        message = serialize(chunk);
      } catch (e) {
        /* Sending this error to the server and emitting it immediately on the
           client may put the call in a slightly weird state on the client side,
           but passing an object that causes a serialization failure is a misuse
           of the API anyway, so that's OK. The primary purpose here is to give
           the programmer a useful error and to stop the stream properly */
        call.cancelWithStatus(constants.status.INTERNAL,
          'Serialization failure');
        callback(e);
        return;
      }
      if (Number.isFinite(encoding)) {
        /* Attach the encoding if it is a finite number. This is the closest we
         * can get to checking that it is valid flags */
        message.grpcWriteFlags = encoding;
      }
      var batch = {
        [grpc.opType.SEND_MESSAGE]: message
      };
      call.startBatch(batch, function (err, event) {
        callback(err, event);
      });
    };
    final_requester.halfClose = function () {
      var batch = {
        [grpc.opType.SEND_CLOSE_FROM_CLIENT]: true
      };
      call.startBatch(batch, function () { });
    };
    final_requester.cancel = function () {
      call.cancel();
    };
    final_requester.cancelWithStatus = function(code, details) {
      call.cancelWithStatus(code, details)
    };
    final_requester.getPeer = function() {
      return call.getPeer();
    };
    return new InterceptingCall(null, final_requester);
  };
}
1004779
function clientNetworkData(channelDefArray, opt) {
	var self = {
		__TYPE__ : MessageType.CS_NET,
		channelCount : new type.UInt32Le( function () {
			return self.channelDefArray.obj.length;
		}),
		channelDefArray : channelDefArray || new type.Factory( function (s) {
			self.channelDefArray = new type.Component([]);
			
			for (var i = 0; i < self.channelCount.value; i++) {
				self.channelDefArray.obj.push(channelDef().read(s));
			}
		})
	};
	
	return new type.Component(self, opt);
}
662787
function callService(service, emitter, channel, callback) {
    var argsValue = Array.prototype.slice.call(Array.prototype.slice.call(arguments)[4]);
    var callerFunc = arguments.callee.caller;
    var eventName = service.name || service._name;
    var callerArgNames = _retrieveArgumentNames(callerFunc);
    var props = {};
    for(var i = 0; i < callerArgNames.length - 1; i++) {
        props[callerArgNames[i]] = argsValue[i];
    }
    if (callback) {
        emitter.once(eventName, callback);
    }
    if (emitter.isReady(true)) {
        try {
            service({
                props: props,
                channel: channel,
                callback: createEventEmitterCallback(eventName, emitter)
            });
        } catch (err) {
            emitter.emit('error', err);
        }
    }
    return new Promise(function (fulfill, reject) {
        emitter.once('error', reject);
        emitter.once(eventName, function (result) {
            emitter.removeListener('error', reject);
            if (typeof result !== 'boolean' && result.instanceOf('mtproto.type.Rpc_error')) {
                reject(new Error(result.error_message));
            } else {
                fulfill(result);
            }
        });
    });
}