Class: LLM::Provider::Transport::HTTP Private
- Inherits:
-
Object
- Object
- LLM::Provider::Transport::HTTP
- Includes:
- Interruptible
- Defined in:
- lib/llm/provider/transport/http.rb,
lib/llm/provider/transport/http/execution.rb,
lib/llm/provider/transport/http/interruptible.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The LLM::Provider::Transport::HTTP class manages HTTP connections for LLM::Provider. It handles transient and persistent clients, tracks active requests by owner, and interrupts in-flight requests when needed.
Defined Under Namespace
Modules: Execution, Interruptible Classes: StreamDecoder
Constant Summary
Constants included from Interruptible
Interruptible::INTERRUPT_ERRORS
Instance Method Summary collapse
- #initialize(host:, port:, timeout:, ssl:, persistent: false) ⇒ LLM::Provider::Transport::HTTP constructor private
- #inspect ⇒ String private
-
#interrupt!(owner) ⇒ nil
private
Interrupt an active request, if any.
-
#interrupted?(owner) ⇒ Boolean?
private
Returns whether an execution owner was interrupted.
-
#persist! ⇒ LLM::Provider::Transport::HTTP
(also: #persistent)
private
Configures the transport to use a persistent HTTP connection pool.
- #persistent? ⇒ Boolean private
-
#request(request, owner:) {|http| ... } ⇒ Object
private
Performs a request on the current HTTP transport.
-
#request_owner ⇒ Fiber
private
Returns the current request owner.
Constructor Details
#initialize(host:, port:, timeout:, ssl:, persistent: false) ⇒ LLM::Provider::Transport::HTTP
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 |
# File 'lib/llm/provider/transport/http.rb', line 25 def initialize(host:, port:, timeout:, ssl:, persistent: false) @host = host @port = port @timeout = timeout @ssl = ssl @base_uri = URI("#{ssl ? "https" : "http"}://#{host}:#{port}/") @persistent_client = persistent ? persistent_client : nil @monitor = Monitor.new end |
Instance Method Details
#inspect ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
94 95 96 |
# File 'lib/llm/provider/transport/http.rb', line 94 def inspect "#<#{self.class.name}:0x#{object_id.to_s(16)} @persistent=#{persistent?}>" end |
#interrupt!(owner) ⇒ nil
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Interrupt an active request, if any.
39 40 41 |
# File 'lib/llm/provider/transport/http.rb', line 39 def interrupt!(owner) super end |
#interrupted?(owner) ⇒ Boolean?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether an execution owner was interrupted.
47 48 49 |
# File 'lib/llm/provider/transport/http.rb', line 47 def interrupted?(owner) super end |
#persist! ⇒ LLM::Provider::Transport::HTTP Also known as: persistent
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Configures the transport to use a persistent HTTP connection pool.
61 62 63 64 65 66 67 |
# File 'lib/llm/provider/transport/http.rb', line 61 def persist! client = persistent_client lock do @persistent_client = client self end end |
#persistent? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 |
# File 'lib/llm/provider/transport/http.rb', line 72 def persistent? !persistent_client.nil? end |
#request(request, owner:) {|http| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Performs a request on the current HTTP transport.
82 83 84 85 86 87 88 89 90 |
# File 'lib/llm/provider/transport/http.rb', line 82 def request(request, owner:, &) if persistent? request_persistent(request, owner, &) else request_transient(request, owner, &) end ensure clear_request(owner) end |
#request_owner ⇒ Fiber
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the current request owner.
54 55 56 |
# File 'lib/llm/provider/transport/http.rb', line 54 def request_owner Fiber.current end |