Class: TaskServiceSubscribeClient

Inherits:
Object
  • Object
show all
Defined in:
lib/client/task_service_subscribe_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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)
	compression_options =
     GRPC::Core::CompressionOptions.new(default_algorithm: :gzip,default_level: :high)
   compression_channel_args = compression_options.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

#metadataObject

Returns the value of attribute metadata.



3
4
5
# File 'lib/client/task_service_subscribe_client.rb', line 3

def 
  @metadata
end

#stubObject

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

#eachObject



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