Sha256: 03c920173de1b7ee31b1e9b1e3d8cf0b1cb93f7d0f5717171f71b3ab3761b4a7

Contents?: true

Size: 888 Bytes

Versions: 6

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

require 'grpc_kit/rpcs'
require 'grpc_kit/calls/server_request_response'

module GrpcKit
  module Rpcs::Server
    class RequestResponse < GrpcKit::Rpcs::ServerRpc
      # @param stream [GrpcKit::Stream::ServerStream]
      # @param metadata [Hash<String, String>]
      # @return [void]
      def invoke(stream, metadata: {})
        call = GrpcKit::Calls::Server::RequestResponse.new(metadata: metadata, config: @config, stream: stream)
        request = call.recv(last: true)

        resp =
          if @config.interceptor
            @config.interceptor.intercept(request, call) do |_, _|
              @handler.send(@config.ruby_style_method_name, request, call)
            end
          else
            @handler.send(@config.ruby_style_method_name, request, call)
          end

        call.send_msg(resp, last: true)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
grpc_kit-0.1.14 lib/grpc_kit/rpcs/server_request_response.rb
grpc_kit-0.1.13 lib/grpc_kit/rpcs/server_request_response.rb
grpc_kit-0.1.12 lib/grpc_kit/rpcs/server_request_response.rb
grpc_kit-0.1.11 lib/grpc_kit/rpcs/server_request_response.rb
grpc_kit-0.1.10 lib/grpc_kit/rpcs/server_request_response.rb
grpc_kit-0.1.9 lib/grpc_kit/rpcs/server_request_response.rb