Sha256: 96bac3f0d681360552d88f94c195f96a3ccb4cfe932e3a6690de7c0b22a4c8ee

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'protobuf'
require 'protobuf/logger'
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, parent_env = nil)
        # Create an env object that holds different parts of the environment and
        # is available to all of the middlewares
        env = Env.new('encoded_request' => request_data,
                      'log_signature' => log_signature,
                      'parent_env' => parent_env)

        # 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

1 entries across 1 versions & 1 rubygems

Version Path
protobuffy-3.6.0 lib/protobuf/rpc/server.rb