Sha256: ab25de87448e68becca2a56fd85040735f1f90e33ee5096ac20dc51cc6ad2dfd

Contents?: true

Size: 1.08 KB

Versions: 31

Compression:

Stored size: 1.08 KB

Contents

require 'protobuf'
require 'protobuf/logging'
require 'protobuf/rpc/rpc.pb'
require 'protobuf/rpc/buffer'
require 'protobuf/rpc/env'
require 'protobuf/rpc/error'
require 'protobuf/rpc/middleware'
require 'protobuf/rpc/service_dispatcher'

module Protobuf
  module Rpc
    module Server
      def gc_pause
        ::GC.disable if ::Protobuf.gc_pause_server_request?

        yield

        ::GC.enable if ::Protobuf.gc_pause_server_request?
      end

      # Invoke the service method dictated by the proto wrapper request object
      #
      def handle_request(request_data, env_data = {})
        # Create an env object that holds different parts of the environment and
        # is available to all of the middlewares
        env = Env.new(env_data.merge('encoded_request' => request_data, 'log_signature' => log_signature))

        # Invoke the middleware stack, the last of which is the service dispatcher
        env = Rpc.middleware.call(env)

        env.encoded_response
      end

      def log_signature
        @_log_signature ||= "[server-#{self.class.name}]"
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
protobuf-3.10.9 lib/protobuf/rpc/server.rb
protobuf-3.10.8 lib/protobuf/rpc/server.rb
protobuf-3.10.7 lib/protobuf/rpc/server.rb
protobuf-3.10.6 lib/protobuf/rpc/server.rb
protobuf-3.10.5 lib/protobuf/rpc/server.rb
protobuf-3.10.4 lib/protobuf/rpc/server.rb
protobuf-cucumber-3.10.8 lib/protobuf/rpc/server.rb
protobuf-cucumber-3.10.7 lib/protobuf/rpc/server.rb
protobuf-cucumber-3.10.6 lib/protobuf/rpc/server.rb
protobuf-cucumber-3.10.5 lib/protobuf/rpc/server.rb
protobuf-cucumber-3.10.4 lib/protobuf/rpc/server.rb
protobuf-3.10.3 lib/protobuf/rpc/server.rb
protobuf-3.10.2 lib/protobuf/rpc/server.rb
protobuf-3.10.1 lib/protobuf/rpc/server.rb
protobuf-3.10.0 lib/protobuf/rpc/server.rb
protobuf-3.10.0.pre0 lib/protobuf/rpc/server.rb
protobuf-3.9.0 lib/protobuf/rpc/server.rb
protobuf-3.9.0.pre2 lib/protobuf/rpc/server.rb
protobuf-3.9.0.pre lib/protobuf/rpc/server.rb
protobuf-3.8.5 lib/protobuf/rpc/server.rb