Class: Thrift::BaseClient

Inherits:
Object
  • Object
show all
Includes:
Client
Defined in:
lib/thrift/client.rb

Instance Method Summary collapse

Methods included from Client

#handle_exception, #initialize, #receive_message, #send_message, #send_message_instance

Instance Method Details

#call_binary(name, req, resp_klass) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/thrift/client.rb', line 99

def call_binary(name, req, resp_klass)
  @mutex.synchronize do
    @cond.wait(@mutex) until @ready

    rpc_call(name, req, resp_klass)
  end
end

#call_unary(name, req) ⇒ Object



89
90
91
92
93
94
95
96
97
# File 'lib/thrift/client.rb', line 89

def call_unary(name, req)
  @mutex.synchronize do
    @cond.wait(@mutex) until @ready

    @seqid += 1
    @oprot.write_message_begin(name, Thrift::MessageTypes::ONEWAY, @seqid)
    send_message_instance(req)
  end
end

#stream_bidi(name, req, resp_klass, stream_klass, sink_klass) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/thrift/client.rb', line 133

def stream_bidi(name, req, resp_klass, stream_klass, sink_klass)
  resp = stream_call(name, req, resp_klass)
  stream = TBidiStream.new(
    @iprot, @oprot, name, @seqid,
    stream_klass, sink_klass,
    MessageTypes::SERVER_STREAM_MESSAGE,
    MessageTypes::CLIENT_STREAM_MESSAGE,
    method(:finish_call)
  )

  stream.ready

  [
    resp,
    TBidiInboundStream.new(stream),
    TBidiOutboundStream.new(stream)
  ]
end

#stream_client(name, req, resp_klass, sink_klass) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/thrift/client.rb', line 107

def stream_client(name, req, resp_klass, sink_klass)
  resp = stream_call(name, req, resp_klass)
  stream = TOutboundStream.new(
    @iprot, @oprot, name, @seqid, sink_klass,
    MessageTypes::CLIENT_STREAM_MESSAGE,
    method(:finish_call)
  )

  stream.ready

  [resp, stream]
end

#stream_server(name, req, resp_klass, sink_klass) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/thrift/client.rb', line 120

def stream_server(name, req, resp_klass, sink_klass)
  resp = stream_call(name, req, resp_klass)
  stream = TInboundStream.new(
    @iprot, @oprot, name, @seqid, sink_klass,
    MessageTypes::SERVER_STREAM_MESSAGE,
    method(:finish_call)
  )

  stream.ready

  [resp, stream]
end