Esempio n. 1
0
def linked_pair(servicer, default_timeout):
  """Creates a Server and Stub linked together for use."""
  link_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  front_work_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  front_transmission_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  front_utility_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  back_work_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  back_transmission_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  back_utility_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  pools = (
      link_pool,
      front_work_pool, front_transmission_pool, front_utility_pool,
      back_work_pool, back_transmission_pool, back_utility_pool)

  link = in_memory.Link(link_pool)
  front = implementations.front_link(
      front_work_pool, front_transmission_pool, front_utility_pool)
  back = implementations.back_link(
      servicer, back_work_pool, back_transmission_pool, back_utility_pool,
      default_timeout, _MAXIMUM_TIMEOUT)
  front.join_rear_link(link)
  link.join_fore_link(front)
  back.join_fore_link(link)
  link.join_rear_link(back)

  return _LinkedPair(front, back, pools)
Esempio n. 2
0
def linked_pair(servicer, default_timeout):
    """Creates a Server and Stub linked together for use."""
    link_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
    front_work_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
    front_transmission_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
    front_utility_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
    back_work_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
    back_transmission_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
    back_utility_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
    pools = (link_pool, front_work_pool, front_transmission_pool,
             front_utility_pool, back_work_pool, back_transmission_pool,
             back_utility_pool)

    link = in_memory.Link(link_pool)
    front = implementations.front_link(front_work_pool,
                                       front_transmission_pool,
                                       front_utility_pool)
    back = implementations.back_link(servicer, back_work_pool,
                                     back_transmission_pool, back_utility_pool,
                                     default_timeout, _MAXIMUM_TIMEOUT)
    front.join_rear_link(link)
    link.join_fore_link(front)
    back.join_fore_link(link)
    link.join_rear_link(back)

    return _LinkedPair(front, back, pools)
Esempio n. 3
0
    def set_up_implementation(self, name, methods, method_implementations,
                              multi_method_implementation):
        pool = logging_pool.pool(_MAXIMUM_POOL_SIZE)

        servicer = face_implementations.servicer(pool, method_implementations,
                                                 multi_method_implementation)

        serialization = serial.serialization(methods)

        fore_link = fore.ForeLink(pool, serialization.request_deserializers,
                                  serialization.response_serializers, None, ())
        fore_link.start()
        port = fore_link.port()
        rear_link = rear.RearLink('localhost', port, pool,
                                  serialization.request_serializers,
                                  serialization.response_deserializers, False,
                                  None, None, None)
        rear_link.start()
        front = base_implementations.front_link(pool, pool, pool)
        back = base_implementations.back_link(servicer, pool, pool, pool,
                                              _TIMEOUT, _MAXIMUM_TIMEOUT)
        fore_link.join_rear_link(back)
        back.join_fore_link(fore_link)
        rear_link.join_fore_link(front)
        front.join_rear_link(rear_link)

        stub = face_implementations.generic_stub(front, pool)
        return stub, (rear_link, fore_link, front, back)
Esempio n. 4
0
  def set_up_implementation(
      self, name, methods, method_implementations,
      multi_method_implementation):
    pool = logging_pool.pool(_MAXIMUM_POOL_SIZE)

    servicer = face_implementations.servicer(
        pool, method_implementations, multi_method_implementation)

    serialization = serial.serialization(methods)

    fore_link = fore.ForeLink(
        pool, serialization.request_deserializers,
        serialization.response_serializers, None, ())
    fore_link.start()
    port = fore_link.port()
    rear_link = rear.RearLink(
        'localhost', port, pool,
        serialization.request_serializers,
        serialization.response_deserializers, False, None, None, None)
    rear_link.start()
    front = base_implementations.front_link(pool, pool, pool)
    back = base_implementations.back_link(
        servicer, pool, pool, pool, _TIMEOUT, _MAXIMUM_TIMEOUT)
    fore_link.join_rear_link(back)
    back.join_fore_link(fore_link)
    rear_link.join_fore_link(front)
    front.join_rear_link(rear_link)

    stub = face_implementations.generic_stub(front, pool)
    return stub, (rear_link, fore_link, front, back)
Esempio n. 5
0
def server_and_stub(
    default_timeout,
    inline_value_in_value_out_methods=None,
    inline_value_in_stream_out_methods=None,
    inline_stream_in_value_out_methods=None,
    inline_stream_in_stream_out_methods=None,
    event_value_in_value_out_methods=None,
    event_value_in_stream_out_methods=None,
    event_stream_in_value_out_methods=None,
    event_stream_in_stream_out_methods=None,
    multi_method=None):
  """Creates a Server and Stub linked together for use."""
  front_work_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  front_transmission_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  front_utility_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  back_work_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  back_transmission_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  back_utility_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  stub_pool = logging_pool.pool(_POOL_SIZE_LIMIT)
  pools = (
      front_work_pool, front_transmission_pool, front_utility_pool,
      back_work_pool, back_transmission_pool, back_utility_pool,
      stub_pool)

  servicer = implementations.servicer(
      back_work_pool,
      inline_value_in_value_out_methods=inline_value_in_value_out_methods,
      inline_value_in_stream_out_methods=inline_value_in_stream_out_methods,
      inline_stream_in_value_out_methods=inline_stream_in_value_out_methods,
      inline_stream_in_stream_out_methods=inline_stream_in_stream_out_methods,
      event_value_in_value_out_methods=event_value_in_value_out_methods,
      event_value_in_stream_out_methods=event_value_in_stream_out_methods,
      event_stream_in_value_out_methods=event_stream_in_value_out_methods,
      event_stream_in_stream_out_methods=event_stream_in_stream_out_methods,
      multi_method=multi_method)

  front = _base_implementations.front_link(
      front_work_pool, front_transmission_pool, front_utility_pool)
  back = _base_implementations.back_link(
      servicer, back_work_pool, back_transmission_pool, back_utility_pool,
      default_timeout, _MAXIMUM_TIMEOUT)
  front.join_rear_link(back)
  back.join_fore_link(front)

  stub = implementations.stub(front, stub_pool)

  return _LinkedPair(implementations.server(), stub, front, back, pools)
Esempio n. 6
0
 def setUp(self):
   self.memory_transmission_pool = logging_pool.pool(POOL_MAX_WORKERS)
   self.front_work_pool = logging_pool.pool(POOL_MAX_WORKERS)
   self.front_transmission_pool = logging_pool.pool(POOL_MAX_WORKERS)
   self.front_utility_pool = logging_pool.pool(POOL_MAX_WORKERS)
   self.back_work_pool = logging_pool.pool(POOL_MAX_WORKERS)
   self.back_transmission_pool = logging_pool.pool(POOL_MAX_WORKERS)
   self.back_utility_pool = logging_pool.pool(POOL_MAX_WORKERS)
   self.test_pool = logging_pool.pool(POOL_MAX_WORKERS)
   self.test_servicer = interfaces_test_case.TestServicer(self.test_pool)
   self.front = implementations.front_link(
       self.front_work_pool, self.front_transmission_pool,
       self.front_utility_pool)
   self.back = implementations.back_link(
       self.test_servicer, self.back_work_pool, self.back_transmission_pool,
       self.back_utility_pool, DEFAULT_TIMEOUT, MAXIMUM_TIMEOUT)
   self.front.join_rear_link(self.back)
   self.back.join_fore_link(self.front)
Esempio n. 7
0
 def _start(self):
   with self._lock:
     if self._pool is None:
       self._pool = logging_pool.pool(_THREAD_POOL_SIZE)
       servicer = _face_implementations.servicer(
           self._pool, self._breakdown.implementations, None)
       self._back = _base_implementations.back_link(
           servicer, self._pool, self._pool, self._pool, _ONE_DAY_IN_SECONDS,
           _ONE_DAY_IN_SECONDS)
       self._fore_link = _fore.ForeLink(
           self._pool, self._breakdown.request_deserializers,
           self._breakdown.response_serializers, None, self._key_chain_pairs,
           port=self._port)
       self._back.join_fore_link(self._fore_link)
       self._fore_link.join_rear_link(self._back)
       self._fore_link.start()
     else:
       raise ValueError('Server currently running!')
Esempio n. 8
0
 def _start(self):
     with self._lock:
         if self._pool is None:
             self._pool = logging_pool.pool(_THREAD_POOL_SIZE)
             servicer = _face_implementations.servicer(
                 self._pool, self._breakdown.implementations, None)
             self._back = _base_implementations.back_link(
                 servicer, self._pool, self._pool, self._pool,
                 _ONE_DAY_IN_SECONDS, _ONE_DAY_IN_SECONDS)
             self._fore_link = _fore.ForeLink(
                 self._pool,
                 self._breakdown.request_deserializers,
                 self._breakdown.response_serializers,
                 None,
                 self._key_chain_pairs,
                 port=self._port)
             self._back.join_fore_link(self._fore_link)
             self._fore_link.join_rear_link(self._back)
             self._fore_link.start()
         else:
             raise ValueError('Server currently running!')