Class: ReactOnRailsPro::RendererHttpClient::PersistentThreadClient
- Inherits:
-
Object
- Object
- ReactOnRailsPro::RendererHttpClient::PersistentThreadClient
show all
- Defined in:
- lib/react_on_rails_pro/renderer_http_client.rb,
sig/react_on_rails_pro/renderer_http_client.rbs
Defined Under Namespace
Classes: ResponseEnvelope
Instance Method Summary
collapse
Constructor Details
#initialize(endpoint:, protocol:, pool_limit:) ⇒ PersistentThreadClient
Returns a new instance of PersistentThreadClient.
238
239
240
241
242
243
244
245
246
247
248
249
|
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 238
def initialize(endpoint:, protocol:, pool_limit:)
@queue = Queue.new
@ready = Queue.new
@pending_results = {}.compare_by_identity
@pending_results_mutex = Mutex.new
@closed = false
@closed_mutex = Mutex.new
@thread = Thread.new { run_loop(endpoint:, protocol:, pool_limit:) }
status, payload = @ready.pop
raise payload if status == :error
end
|
Instance Method Details
#alive? ⇒ Boolean
274
275
276
|
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 274
def alive?
@thread.alive?
end
|
#close ⇒ nil
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 259
def close
result = nil
@closed_mutex.synchronize do
return if @closed
@closed = true
result = Queue.new
@queue << [:close, result]
end
status, payload = wait_for_close_result(result)
@thread.join
raise payload if status == :error
end
|
#get(path, headers:) ⇒ Object
255
256
257
|
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 255
def get(path, headers:)
request(:get, path, headers:, body: nil)
end
|
#post(path, headers:, body:) ⇒ Object
251
252
253
|
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 251
def post(path, headers:, body:)
request(:post, path, headers:, body:)
end
|