forest_admin_datasource_rpc 1.22.0 → 1.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 257ae1978e7bea8eaf90b4add89663c29aed4af4611f539bdb0dbd1c4407e701
4
- data.tar.gz: 7a0ff918ce2888e3f2faf4e294fef542b04025bbc7598d5af0a57ce8aef8524d
3
+ metadata.gz: ee7aa557c745a41ad9255d6e71ba5fab30ed3b6f3b9c48d7ff24c4d031280d4b
4
+ data.tar.gz: 600f4cae467a95b84779dff19568b9a572f4ce64f12f49f6851112d165fb6bc4
5
5
  SHA512:
6
- metadata.gz: 943b84abae7c5c66647e912d879cb3163d44be20bf43b32e1aa14f0a95fe408767a82456fce7953ad3833b5c85d4a2010236b83df5f5ab5b815b91a25d684daf
7
- data.tar.gz: cabbe8f164f8aabdd5362b583de0b266d31ff6adab4bee0fa33a1193359b6d224f495942cddd5ba072d79f4d1e8483ed25b386a63185bb3c72799a9189d31a51
6
+ metadata.gz: ebbf43da8ccca6679c0e33f9765af986ac3b138b30db72bcc1a9e6775038db90f85469301ff3176721dd544c13d5c1d2371b6da15b99a77c578d011ce21eaaf6
7
+ data.tar.gz: 0f1eb73352ca77a4380548e657fc8dfaeff4910a971fc571fee401903880069ce6dec6251d74522a91a3769e89c990c0cd6642a2a1dbfd2fa042cd9a89986a84
@@ -60,7 +60,21 @@ module ForestAdminDatasourceRpc
60
60
  def make_request(endpoint, caller: nil, method: :get, payload: nil, symbolize_keys: false, if_none_match: nil)
61
61
  log_request_start(method, endpoint, if_none_match)
62
62
 
63
- client = Faraday.new(url: @api_url) do |faraday|
63
+ client = build_faraday_client(symbolize_keys)
64
+ headers = build_request_headers(caller, if_none_match)
65
+
66
+ response = client.send(method, endpoint, payload, headers)
67
+ log_request_complete(response, endpoint)
68
+ response
69
+ rescue Faraday::ConnectionFailed => e
70
+ handle_connection_failed(endpoint, e)
71
+ rescue Faraday::TimeoutError => e
72
+ handle_timeout_error(endpoint, e)
73
+ end
74
+ # rubocop:enable Metrics/ParameterLists
75
+
76
+ def build_faraday_client(symbolize_keys)
77
+ Faraday.new(url: @api_url) do |faraday|
64
78
  faraday.request :json
65
79
  faraday.response :json, parser_options: { symbolize_names: symbolize_keys }
66
80
  faraday.adapter Faraday.default_adapter
@@ -68,7 +82,9 @@ module ForestAdminDatasourceRpc
68
82
  faraday.options.timeout = DEFAULT_TIMEOUT
69
83
  faraday.options.open_timeout = DEFAULT_OPEN_TIMEOUT
70
84
  end
85
+ end
71
86
 
87
+ def build_request_headers(caller, if_none_match)
72
88
  timestamp = Time.now.utc.iso8601(3)
73
89
  signature = generate_signature(timestamp)
74
90
 
@@ -80,12 +96,26 @@ module ForestAdminDatasourceRpc
80
96
 
81
97
  headers['forest_caller'] = caller.to_json if caller
82
98
  headers['If-None-Match'] = %("#{if_none_match}") if if_none_match
99
+ headers
100
+ end
83
101
 
84
- response = client.send(method, endpoint, payload, headers)
85
- log_request_complete(response, endpoint)
86
- response
102
+ def handle_connection_failed(endpoint, error)
103
+ ForestAdminAgent::Facades::Container.logger&.log(
104
+ 'Error',
105
+ "[RPC Client] Connection failed to #{@api_url}#{endpoint}: #{error.message}"
106
+ )
107
+ raise ForestAdminDatasourceToolkit::Exceptions::ForestException,
108
+ "RPC connection failed: Unable to connect to #{@api_url}. Please check if the RPC server is running."
109
+ end
110
+
111
+ def handle_timeout_error(endpoint, error)
112
+ ForestAdminAgent::Facades::Container.logger&.log(
113
+ 'Error',
114
+ "[RPC Client] Request timeout to #{@api_url}#{endpoint}: #{error.message}"
115
+ )
116
+ raise ForestAdminDatasourceToolkit::Exceptions::ForestException,
117
+ "RPC request timeout: The RPC server at #{@api_url} did not respond in time."
87
118
  end
88
- # rubocop:enable Metrics/ParameterLists
89
119
 
90
120
  def generate_signature(timestamp)
91
121
  OpenSSL::HMAC.hexdigest('SHA256', @auth_secret, timestamp)
@@ -69,6 +69,8 @@ module ForestAdminDatasourceRpc
69
69
  log_connection_error(e)
70
70
  rescue ForestAdminAgent::Http::Exceptions::AuthenticationOpenIdClient => e
71
71
  log_authentication_error(e)
72
+ rescue ForestAdminDatasourceToolkit::Exceptions::ForestException => e
73
+ log_rpc_error(e)
72
74
  rescue StandardError => e
73
75
  log_unexpected_error(e)
74
76
  end
@@ -108,7 +110,8 @@ module ForestAdminDatasourceRpc
108
110
 
109
111
  @introspection_schema = nil
110
112
  rescue Faraday::ConnectionFailed, Faraday::TimeoutError,
111
- ForestAdminAgent::Http::Exceptions::AuthenticationOpenIdClient, StandardError => e
113
+ ForestAdminAgent::Http::Exceptions::AuthenticationOpenIdClient,
114
+ ForestAdminDatasourceToolkit::Exceptions::ForestException, StandardError => e
112
115
  handle_initial_fetch_error(e)
113
116
  end
114
117
 
@@ -213,6 +216,13 @@ module ForestAdminDatasourceRpc
213
216
  )
214
217
  end
215
218
 
219
+ def log_rpc_error(error)
220
+ ForestAdminAgent::Facades::Container.logger&.log(
221
+ 'Warn',
222
+ "[Schema Polling] RPC error: #{error.message}"
223
+ )
224
+ end
225
+
216
226
  def log_authentication_error(error)
217
227
  ForestAdminAgent::Facades::Container.logger&.log(
218
228
  'Error',
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceRpc
2
- VERSION = "1.22.0"
2
+ VERSION = "1.22.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_datasource_rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.0
4
+ version: 1.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2026-01-08 00:00:00.000000000 Z
12
+ date: 2026-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: base64