def instantiate(self, methods, method_implementations,
                    multi_method_implementation):
        pool = logging_pool.pool(test_constants.POOL_SIZE)
        servicer = crust_implementations.servicer(method_implementations,
                                                  multi_method_implementation,
                                                  pool)

        service_end_link = core_implementations.service_end_link(
            servicer, test_constants.DEFAULT_TIMEOUT,
            test_constants.MAXIMUM_TIMEOUT)
        invocation_end_link = core_implementations.invocation_end_link()
        invocation_end_link.join_link(service_end_link)
        service_end_link.join_link(invocation_end_link)
        service_end_link.start()
        invocation_end_link.start()

        generic_stub = crust_implementations.generic_stub(
            invocation_end_link, pool)
        # TODO(nathaniel): Add a "groups" attribute to _digest.TestServiceDigest.
        group = next(iter(methods))[0]
        # TODO(nathaniel): Add a "cardinalities_by_group" attribute to
        # _digest.TestServiceDigest.
        cardinalities = {
            method: method_object.cardinality()
            for (group, method), method_object in six.iteritems(methods)
        }
        dynamic_stub = crust_implementations.dynamic_stub(
            invocation_end_link, group, cardinalities, pool)

        return generic_stub, {
            group: dynamic_stub
        }, (invocation_end_link, service_end_link, pool)
Пример #2
0
def generic_stub(channel, host, metadata_transformer, request_serializers,
                 response_deserializers, thread_pool, thread_pool_size):
    end_link, grpc_link, invocation_pool, assembly_pool = _assemble(
        channel, host, metadata_transformer, request_serializers,
        response_deserializers, thread_pool, thread_pool_size)
    stub = _crust_implementations.generic_stub(end_link, invocation_pool)
    return _wrap_assembly(stub, end_link, grpc_link, assembly_pool)
  def instantiate(
      self, methods, method_implementations, multi_method_implementation):
    pool = logging_pool.pool(test_constants.POOL_SIZE)
    servicer = crust_implementations.servicer(
        method_implementations, multi_method_implementation, pool)

    service_end_link = core_implementations.service_end_link(
        servicer, test_constants.DEFAULT_TIMEOUT,
        test_constants.MAXIMUM_TIMEOUT)
    invocation_end_link = core_implementations.invocation_end_link()
    invocation_end_link.join_link(service_end_link)
    service_end_link.join_link(invocation_end_link)
    service_end_link.start()
    invocation_end_link.start()

    generic_stub = crust_implementations.generic_stub(invocation_end_link, pool)
    # TODO(nathaniel): Add a "groups" attribute to _digest.TestServiceDigest.
    group = next(iter(methods))[0]
    # TODO(nathaniel): Add a "cardinalities_by_group" attribute to
    # _digest.TestServiceDigest.
    cardinalities = {
        method: method_object.cardinality()
        for (group, method), method_object in methods.iteritems()}
    dynamic_stub = crust_implementations.dynamic_stub(
        invocation_end_link, group, cardinalities, pool)

    return generic_stub, {group: dynamic_stub}, (
        invocation_end_link, service_end_link, pool)
Пример #4
0
def generic_stub(
    channel, host, metadata_transformer, request_serializers,
    response_deserializers, thread_pool, thread_pool_size):
  end_link, grpc_link, invocation_pool, assembly_pool = _assemble(
      channel, host, metadata_transformer, request_serializers,
      response_deserializers, thread_pool, thread_pool_size)
  stub = _crust_implementations.generic_stub(end_link, invocation_pool)
  return _wrap_assembly(stub, end_link, grpc_link, assembly_pool)
    def instantiate(self, methods, method_implementations,
                    multi_method_implementation):
        pool = logging_pool.pool(test_constants.POOL_SIZE)
        servicer = crust_implementations.servicer(method_implementations,
                                                  multi_method_implementation,
                                                  pool)
        serialization_behaviors = _serialization_behaviors_from_test_methods(
            methods)
        invocation_end_link = core_implementations.invocation_end_link()
        service_end_link = core_implementations.service_end_link(
            servicer, test_constants.DEFAULT_TIMEOUT,
            test_constants.MAXIMUM_TIMEOUT)
        service_grpc_link = service.service_link(
            serialization_behaviors.request_deserializers,
            serialization_behaviors.response_serializers)
        port = service_grpc_link.add_port('[::]:0', None)
        channel = _intermediary_low.Channel('localhost:%d' % port, None)
        invocation_grpc_link = invocation.invocation_link(
            channel, b'localhost', None,
            serialization_behaviors.request_serializers,
            serialization_behaviors.response_deserializers)

        invocation_end_link.join_link(invocation_grpc_link)
        invocation_grpc_link.join_link(invocation_end_link)
        service_grpc_link.join_link(service_end_link)
        service_end_link.join_link(service_grpc_link)
        service_end_link.start()
        invocation_end_link.start()
        invocation_grpc_link.start()
        service_grpc_link.start()

        generic_stub = crust_implementations.generic_stub(
            invocation_end_link, pool)
        # TODO(nathaniel): Add a "groups" attribute to _digest.TestServiceDigest.
        group = next(iter(methods))[0]
        # TODO(nathaniel): Add a "cardinalities_by_group" attribute to
        # _digest.TestServiceDigest.
        cardinalities = {
            method: method_object.cardinality()
            for (group, method), method_object in six.iteritems(methods)
        }
        dynamic_stub = crust_implementations.dynamic_stub(
            invocation_end_link, group, cardinalities, pool)

        return generic_stub, {
            group: dynamic_stub
        }, (invocation_end_link, invocation_grpc_link, service_grpc_link,
            service_end_link, pool)
  def instantiate(
      self, methods, method_implementations, multi_method_implementation):
    pool = logging_pool.pool(test_constants.POOL_SIZE)
    servicer = crust_implementations.servicer(
        method_implementations, multi_method_implementation, pool)
    serialization_behaviors = _serialization_behaviors_from_test_methods(
        methods)
    invocation_end_link = core_implementations.invocation_end_link()
    service_end_link = core_implementations.service_end_link(
        servicer, test_constants.DEFAULT_TIMEOUT,
        test_constants.MAXIMUM_TIMEOUT)
    service_grpc_link = service.service_link(
        serialization_behaviors.request_deserializers,
        serialization_behaviors.response_serializers)
    port = service_grpc_link.add_port('[::]:0', None)
    channel = _intermediary_low.Channel('localhost:%d' % port, None)
    invocation_grpc_link = invocation.invocation_link(
        channel, b'localhost',
        serialization_behaviors.request_serializers,
        serialization_behaviors.response_deserializers)

    invocation_end_link.join_link(invocation_grpc_link)
    invocation_grpc_link.join_link(invocation_end_link)
    service_grpc_link.join_link(service_end_link)
    service_end_link.join_link(service_grpc_link)
    service_end_link.start()
    invocation_end_link.start()
    invocation_grpc_link.start()
    service_grpc_link.start()

    generic_stub = crust_implementations.generic_stub(invocation_end_link, pool)
    # TODO(nathaniel): Add a "groups" attribute to _digest.TestServiceDigest.
    group = next(iter(methods))[0]
    # TODO(nathaniel): Add a "cardinalities_by_group" attribute to
    # _digest.TestServiceDigest.
    cardinalities = {
        method: method_object.cardinality()
        for (group, method), method_object in methods.iteritems()}
    dynamic_stub = crust_implementations.dynamic_stub(
        invocation_end_link, group, cardinalities, pool)

    return generic_stub, {group: dynamic_stub}, (
        invocation_end_link, invocation_grpc_link, service_grpc_link,
        service_end_link, pool)