Sha256: da055c2849478f5d930071abf1616b308df76681b3dc91fcc7a9d2ea58edefed

Contents?: true

Size: 882 Bytes

Versions: 7

Compression:

Stored size: 882 Bytes

Contents

require 'protobuf/logging'

module Protobuf
  module Rpc
    class ServiceDispatcher
      include ::Protobuf::Logging

      attr_reader :env

      def initialize(app)
        # End of the line...
      end

      def call(env)
        @env = env

        env.response = dispatch_rpc_request
        env
      end

      def rpc_service
        @rpc_service ||= env.rpc_service.new(env)
      end

    private

      # Call the given service method.
      def dispatch_rpc_request
        unless rpc_service.respond_to?(method_name)
          raise MethodNotFound.new("#{service_name}##{method_name} is not a publicly defined method.")
        end

        rpc_service.callable_rpc_method(method_name).call
        rpc_service.response
      end

      def method_name
        env.method_name
      end

      def service_name
        env.service_name
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
protobuf-3.3.6 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.3.5 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.3.4 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.3.3 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.3.2 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.3.1 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.3.0 lib/protobuf/rpc/service_dispatcher.rb