Class: EchoService

Inherits:
Object show all
Includes:
GRPC::GenericService
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/support/services.rb

Overview

A test service with an echo implementation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GRPC::GenericService

included, underscore

Constructor Details

#initialize(**kw) ⇒ EchoService

Returns a new instance of EchoService.



45
46
47
48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/support/services.rb', line 45

def initialize(**kw)
  @trailing_metadata = kw
  @received_md = []
end

Instance Attribute Details

#received_mdObject (readonly)

Returns the value of attribute received_md.



43
44
45
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/support/services.rb', line 43

def received_md
  @received_md
end

Instance Method Details

#a_bidi_rpc(requests, call) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/support/services.rb', line 71

def a_bidi_rpc(requests, call)
  call..update(@trailing_metadata)
  requests.each do |r|
    GRPC.logger.info(r)
  end
  [EchoMsg.new, EchoMsg.new]
end

#a_client_streaming_rpc(call) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/support/services.rb', line 57

def a_client_streaming_rpc(call)
  # iterate through requests so call can complete
  call..update(@trailing_metadata)
  call.each_remote_read.each do |r|
    GRPC.logger.info(r)
  end
  EchoMsg.new
end

#a_server_streaming_rpc(_req, call) ⇒ Object



66
67
68
69
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/support/services.rb', line 66

def a_server_streaming_rpc(_req, call)
  call..update(@trailing_metadata)
  [EchoMsg.new, EchoMsg.new]
end

#an_rpc(req, call) ⇒ Object



50
51
52
53
54
55
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/spec/support/services.rb', line 50

def an_rpc(req, call)
  GRPC.logger.info('echo service received a request')
  call..update(@trailing_metadata)
  @received_md << call. unless call..nil?
  req
end