Sha256: a4488ee9bcea315bbfd87a5849b84d8492ade5a79ea5cb55044d7a9d25127e1e

Contents?: true

Size: 880 Bytes

Versions: 23

Compression:

Stored size: 880 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)
          fail MethodNotFound, "#{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

23 entries across 23 versions & 2 rubygems

Version Path
protobuf-3.6.10 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.7.0.pre2 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.6.9 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.7.0.pre1 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.7.0.pre0 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.6.7 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.6.6 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.6.2 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.6.1 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.6.0 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.5.5 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.5.4 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.5.3 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.5.2 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.5.1 lib/protobuf/rpc/service_dispatcher.rb
prepor-protobuf-3.5.1 lib/protobuf/rpc/service_dispatcher.rb
prepor-protobuf-3.5.0 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.5.0 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.4.4 lib/protobuf/rpc/service_dispatcher.rb
protobuf-3.4.3 lib/protobuf/rpc/service_dispatcher.rb