Class: Multiwoven::Integrations::Source::HttpModel::Client
- Inherits:
-
SourceConnector
- Object
- SourceConnector
- Multiwoven::Integrations::Source::HttpModel::Client
- Defined in:
- lib/multiwoven/integrations/source/http_model/client.rb
Instance Method Summary collapse
- #check_connection(connection_config) ⇒ Object
- #discover(_connection_config = nil) ⇒ Object
- #read(sync_config) ⇒ Object
Instance Method Details
#check_connection(connection_config) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/multiwoven/integrations/source/http_model/client.rb', line 7 def check_connection(connection_config) connection_config = connection_config.with_indifferent_access url_host = connection_config[:url_host] http_method = connection_config[:http_method] headers = connection_config[:headers] payload = JSON.parse(connection_config[:request_format]) config = connection_config[:config] config[:timeout] ||= 30 response = send_request(url_host, http_method, payload, headers, config) if success?(response) success_status else failure_status(nil) end rescue StandardError => e handle_exception(e, { context: "HTTP MODEL:CHECK_CONNECTION:EXCEPTION", type: "error" }) failure_status(e) end |
#discover(_connection_config = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/multiwoven/integrations/source/http_model/client.rb', line 29 def discover(_connection_config = nil) catalog_json = read_json(CATALOG_SPEC_PATH) catalog = build_catalog(catalog_json) catalog. rescue StandardError => e handle_exception(e, { context: "HTTP MODEL:DISCOVER:EXCEPTION", type: "error" }) end |
#read(sync_config) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/multiwoven/integrations/source/http_model/client.rb', line 40 def read(sync_config) connection_config = sync_config.source.connection_specification connection_config = connection_config.with_indifferent_access # The server checks the ConnectorQueryType. # If it's "ai_ml," the server calculates the payload and passes it as a query in the sync config model protocol. # This query is then sent to the AI/ML model. payload = JSON.parse(sync_config.model.query) run_model(connection_config, payload) rescue StandardError => e handle_exception(e, { context: "HTTP MODEL:READ:EXCEPTION", type: "error" }) end |