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
Constant Summary
Constants included from Interruptible
Interruptible::INTERRUPT_ERRORS
Instance Method Summary collapse
- #inspect ⇒ String private
-
#interrupt!(owner) ⇒
nil private
Interrupt an active request, if any.
-
#interrupted?(owner)
⇒ Boolean? private
Returns whether an execution owner was interrupted.
-
#request_owner ⇒
Fiber private
Returns the current request owner.
-
#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.
- #initialize(host:, port:, timeout:, ssl:, persistent: false) ⇒ LLM::Provider::Transport::HTTP constructor private
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.
24 25 26 27 28 29 30 31 32 |
# File 'lib/llm/provider/transport/http.rb', line 24 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.
93 94 95 |
# File 'lib/llm/provider/transport/http.rb', line 93 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.
38 39 40 |
# File 'lib/llm/provider/transport/http.rb', line 38 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.
46 47 48 |
# File 'lib/llm/provider/transport/http.rb', line 46 def interrupted?(owner) super 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.
53 54 55 |
# File 'lib/llm/provider/transport/http.rb', line 53 def request_owner Fiber.current 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.
60 61 62 63 64 65 66 |
# File 'lib/llm/provider/transport/http.rb', line 60 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.
71 72 73 |
# File 'lib/llm/provider/transport/http.rb', line 71 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.
81 82 83 84 85 86 87 88 89 |
# File 'lib/llm/provider/transport/http.rb', line 81 def request(request, owner:, &) if persistent? request_persistent(request, owner, &) else request_transient(request, owner, &) end ensure clear_request(owner) end |