send a request to a service, this will wait for a response

 *service_name*:: the name of the service
 *message*:: the message to be sent

 This method can optionally take a block which will be executed asynchronously and yielded the response
764183
def send_request_to_service(service_name, message)
      if block_given?
        EventMachine.defer do
          yield send_request_to_service(service_name, message)
        end
      else
        send_HTTP_request(@channel.default_exchange, service_name, message)
      end
    end
21980
def request(method, path)
        resource[path].send(method.to_sym, request_headers) { |response, request, result, &block|
          case response.code
            when 200
              response
            when 400
              if response.include? ' is required'
                raise ArgumentError.new(response)
              else
                raise BadRequestError.new(response)
              end
            else
              response.return!(request, result, &block)
          end
        }
      end
477316
def on(method, *args, &block)

      if [:initialize, :before, :setup, :after].include? method
        raise "#{method} should not be called directly"
      end

      buffer  = [] # Container for the response buffer  
      threads = [] # Container for the execution threads

  		@registry.each do |s|
        if s.respond_to?(method.to_sym, false)
          threads << Thread.new do 
            responder = DispatchResponder.new(s)
          
            responder.trap(@timeout) do 
              if s.method(method.to_sym).arity == 0
                s.send(method, &block)
              else
                s.send(method, *args, &block)
              end
            end

            responder.finalize

            buffer << responder.to_h
          end
  			end
  		end

      threads.map(&:join)

      buffer
  	end
1079268
def call(args = {}, &block)
      response = API.call(full_name, args, token)
      Result.process(response, type, block)
    end
1230323
def core__send_request_success(payload)
      response = { result: true, error_message: nil }
      response[:payload] = payload if payload
      render json: response
    end
428330
def method_missing(method, *args, &block)
      if respond_to_missing?(method)
        new.public_send(method, *args, &block)
      else
        super
      end
    end
1276402
async def _send_request(self, request_type, payload):
        
        try:
            return await self._connection.send(
                message_type=request_type,
                message_content=payload,
                timeout=self._timeout)
        except DisconnectError:
            LOGGER.warning('Validator disconnected while waiting for response')
            raise errors.ValidatorDisconnected()
        except asyncio.TimeoutError:
            LOGGER.warning('Timed out while waiting for validator response')
            raise errors.ValidatorTimedOut()
        except SendBackoffTimeoutError:
            LOGGER.warning('Failed sending message - Backoff timed out')
            raise errors.SendBackoffTimeout()
894910
def send_request(req, &block)
      @last_response = @http.request(req.delete(:method), req.delete(:uri), req, &block)
    end
1092768
def request_blocking(self, method, params):
        
        response = self._make_request(method, params)

        if "error" in response:
            raise ValueError(response["error"])

        return response['result']
1070496
def give_response(response, deferred)
      @delayer.new do
        next if deferred.spoiled?
        deferred.exit_await
        fiber.resume(response).accept_request(worker: self,
                                              deferred: deferred)
      end
      nil
    end
939960
def send(self, **kwargs):
        
        payload = self.api_payload()
        payload.update(**kwargs)
        return self.api_method()(**payload)
1000727
async def send_message(  # type: ignore
        self, request: str, response_expected: bool, **kwargs: Any
    ) -> Response:
        
        headers = dict(self.DEFAULT_HEADERS)
        headers.update(kwargs.pop("headers", {}))

        response = await self.client.fetch(
            self.endpoint, method="POST", body=request, headers=headers, **kwargs
        )

        return Response(response.body.decode(), raw=response)
64693
def send_message(
        self, request: str, response_expected: bool, **kwargs: Any
    ) -> Response:
        
        payload = str(request) + self.delimiter
        self.socket.send(payload.encode(self.encoding))

        response = bytes()
        decoded = None

        # Receive the response until we find the delimiter.
        # TODO Do not wait for a response if the message sent is a notification.
        while True:
            response += self.socket.recv(1024)

            decoded = response.decode(self.encoding)
            if len(decoded) < self.delimiter_length:
                continue

            # TODO Check that're not in the middle of the response.
            elif decoded[-self.delimiter_length :] == self.delimiter:
                break

        assert decoded is not None
        return Response(decoded[: -self.delimiter_length])
1206359
def request(method, path, options = {})
      options = options.dup

      raw = raw? || options.delete(:raw)
      params(options)
      response = connection.send method, path, (@raw_body || @params), @headers
      raw ? response : @scopeable.parse(response)
    end
273367
def method_missing(sym, *args, &block)
      if self.data.respond_to?(sym)
        return self.data.send(sym, *args, &block)
      end

      super
    end
600759
def request_service(name)
      # Use RequestName, but asynchronously!
      # A synchronous call would not work with service activation, where
      # method calls to be serviced arrive before the reply for RequestName
      # (Ticket#29).
      proxy.RequestName(name, NAME_FLAG_REPLACE_EXISTING) do |rmsg, r|
        # check and report errors first
        raise rmsg if rmsg.is_a?(Error)
        raise NameRequestError unless r == REQUEST_NAME_REPLY_PRIMARY_OWNER
      end
      @service = Service.new(name, self)
      @service
    end
995983
def send_request(request)
      api_name = Protocol.api_name(request.api_key)

      # Default notification payload.
      notification = {
        broker_host: @host,
        api: api_name,
        request_size: 0,
        response_size: 0,
      }

      raise IdleConnection if idle?

      @logger.push_tags(api_name)
      @instrumenter.instrument("request.connection", notification) do
        open unless open?

        @correlation_id += 1

        @logger.debug "Sending #{api_name} API request #{@correlation_id} to #{to_s}"

        write_request(request, notification)

        response_class = request.response_class
        response = wait_for_response(response_class, notification) unless response_class.nil?

        @last_request = Time.now

        response
      end
    rescue SystemCallError, EOFError, IOError => e
      close

      raise ConnectionError, "Connection error #{e.class}: #{e}"
    ensure
      @logger.pop_tags
    end