Class: DatagroutConduit::Transport::Base
- Inherits:
-
Object
- Object
- DatagroutConduit::Transport::Base
- Defined in:
- lib/datagrout_conduit/transport/base.rb
Overview
Base transport shared by MCP and JSONRPC transports. Manages a Faraday connection with optional mTLS and auth headers.
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #connect ⇒ Object
- #connected? ⇒ Boolean
- #disconnect ⇒ Object
-
#initialize(url:, auth: {}, identity: nil) ⇒ Base
constructor
A new instance of Base.
-
#send_request(_method, _params = nil, id: nil) ⇒ Object
Subclasses must implement this.
Constructor Details
#initialize(url:, auth: {}, identity: nil) ⇒ Base
Returns a new instance of Base.
15 16 17 18 19 20 21 |
# File 'lib/datagrout_conduit/transport/base.rb', line 15 def initialize(url:, auth: {}, identity: nil) @url = url @auth = normalize_auth(auth) @identity = identity @connected = false @connection = build_connection end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
13 14 15 |
# File 'lib/datagrout_conduit/transport/base.rb', line 13 def url @url end |
Instance Method Details
#connect ⇒ Object
23 24 25 26 |
# File 'lib/datagrout_conduit/transport/base.rb', line 23 def connect URI.parse(@url) # validate URL @connected = true end |
#connected? ⇒ Boolean
32 33 34 |
# File 'lib/datagrout_conduit/transport/base.rb', line 32 def connected? @connected end |
#disconnect ⇒ Object
28 29 30 |
# File 'lib/datagrout_conduit/transport/base.rb', line 28 def disconnect @connected = false end |
#send_request(_method, _params = nil, id: nil) ⇒ Object
Subclasses must implement this.
37 38 39 |
# File 'lib/datagrout_conduit/transport/base.rb', line 37 def send_request(_method, _params = nil, id: nil) raise NotImplementedError, "#{self.class}#send_request must be implemented" end |