Class: GrpcKit::Transport::ClientTransport
- Inherits:
-
Object
- Object
- GrpcKit::Transport::ClientTransport
show all
- Includes:
- Packable
- Defined in:
- lib/grpc_kit/transport/client_transport.rb
Instance Method Summary
collapse
Methods included from Packable
#pack, #unpack, #unpacker
Constructor Details
Returns a new instance of ClientTransport.
12
13
14
15
16
|
# File 'lib/grpc_kit/transport/client_transport.rb', line 12
def initialize(session)
@session = session
@stream = nil @deferred = false
end
|
Instance Method Details
#close_and_flush ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/grpc_kit/transport/client_transport.rb', line 23
def close_and_flush
resume_if_need
@stream.end_write
@session.start(@stream.stream_id)
@stream.end_read
@deferred = false
end
|
#each ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/grpc_kit/transport/client_transport.rb', line 32
def each
loop do
data = recv
return if data.nil?
yield(data)
end
end
|
#read_data(last: false) ⇒ Object
49
50
51
|
# File 'lib/grpc_kit/transport/client_transport.rb', line 49
def read_data(last: false)
unpack(read(last: last))
end
|
53
54
55
56
|
# File 'lib/grpc_kit/transport/client_transport.rb', line 53
def
wait_close
@stream.
end
|
#start_request(data, header, last: false) ⇒ Object
18
19
20
21
|
# File 'lib/grpc_kit/transport/client_transport.rb', line 18
def start_request(data, , last: false)
@stream = @session.send_request(GrpcKit::Transport::SendBuffer.new, )
write_data(data, last: last)
end
|
#write_data(buf, last: false) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/grpc_kit/transport/client_transport.rb', line 41
def write_data(buf, last: false)
resume_if_need
write(@stream.pending_send_data, pack(buf), last: last)
@session.run_once
@deferred = true unless last
end
|