Class: TaskServiceSubscribeClient
- Inherits:
-
Object
- Object
- TaskServiceSubscribeClient
- Defined in:
- lib/client/task_service_subscribe_client.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#stub ⇒ Object
Returns the value of attribute stub.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(address, auth, use_gzip = true) ⇒ TaskServiceSubscribeClient
constructor
A new instance of TaskServiceSubscribeClient.
- #marshal(obj) ⇒ Object
- #Send(streamMessage) ⇒ Object
- #test_a(bbb, streamMessage) ⇒ Object
- #test_send(streamMessage) ⇒ Object
- #unmarshal(str) ⇒ Object
Constructor Details
#initialize(address, auth, use_gzip = true) ⇒ TaskServiceSubscribeClient
Returns a new instance of TaskServiceSubscribeClient.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/client/task_service_subscribe_client.rb', line 5 def initialize(address,auth,use_gzip=true) = GRPC::Core::CompressionOptions.new(default_algorithm: :gzip,default_level: :high) compression_channel_args = .to_channel_arg_hash if !use_gzip compression_channel_args = {} end @stub = GRPC::ClientStub.new(address,:this_channel_is_insecure,channel_args:compression_channel_args) @metadata = {"authorization": auth} end |
Instance Attribute Details
#metadata ⇒ Object
Returns the value of attribute metadata.
3 4 5 |
# File 'lib/client/task_service_subscribe_client.rb', line 3 def @metadata end |
#stub ⇒ Object
Returns the value of attribute stub.
2 3 4 |
# File 'lib/client/task_service_subscribe_client.rb', line 2 def stub @stub end |
Instance Method Details
#each ⇒ Object
46 47 48 |
# File 'lib/client/task_service_subscribe_client.rb', line 46 def each end |
#marshal(obj) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/client/task_service_subscribe_client.rb', line 22 def marshal(obj) # a = { # code: obj.code, # node_key: obj.node_key, # key: obj.key, # from: obj.from, # to: obj.to, # data: obj.data, # error: obj.error, # } # return a.to_json return Grpc::StreamMessage.encode(obj) end |
#Send(streamMessage) ⇒ Object
17 18 19 |
# File 'lib/client/task_service_subscribe_client.rb', line 17 def Send(streamMessage) @stub.client_streamer("/grpc.TaskService/Subscribe", streamMessage, method(:marshal), method(:unmarshal),metadata: @metadata) end |
#test_a(bbb, streamMessage) ⇒ Object
54 55 56 57 |
# File 'lib/client/task_service_subscribe_client.rb', line 54 def test_a(bbb,streamMessage) a = bbb.call(streamMessage) puts a end |
#test_send(streamMessage) ⇒ Object
50 51 52 |
# File 'lib/client/task_service_subscribe_client.rb', line 50 def test_send(streamMessage) test_a(method(:marshal),streamMessage) end |
#unmarshal(str) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/client/task_service_subscribe_client.rb', line 37 def unmarshal(str) # a = JSON.parse(str) # obj = StreamMessage.new(a) # return obj return Grpc::StreamMessage.decode(str) end |