forest_admin_datasource_rpc 1.19.1 → 1.19.2

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: 6fe97adef6604fbdd481a33bb2cb4edd1ccf0714934efdf1427c381dd11313c5
4
- data.tar.gz: 9359c5f4b64cf2b1ef7e470375e4c263d6d72e21af4fd4c4bff68b3741488888
3
+ metadata.gz: 8005cf0d61ee6de8ddd0551e4af829e6949b04e3efbc920b2f6471681d909c67
4
+ data.tar.gz: 265bdffa1cbc99e9e3cae4a174def1c2c3982d889a3b83619e52bf4c20e748de
5
5
  SHA512:
6
- metadata.gz: 4582367363f7a396c8f4bbd76c4ca4b984ab49c240e5c8bb3dc875fedbf2fa1cdc7396b79f7fde7eb03f5a786172c8340bf1893b6d3735174c978a6a8cf81a9a
7
- data.tar.gz: 59aace65b04ae6a21262789a5b6f6fa808cd06bb8c9f85a6e078bf0532b53e704394866c9d6b5f41478b8017513041558c7abff01db1a04dce5735c9f818ef6f
6
+ metadata.gz: 5e682e70de460d239d7653ecb4e8345f5582c3cfc64e0c00e6c85c214abfb95e8c7ba68a44c21ba80169251d1a46d4d5f460bbe3dbfecaccb95d8a3a8803ce95
7
+ data.tar.gz: 064aa70451798d8321786b1fe2d4805e6b838a0c49f1fa539c3303d8b3c43381a22c81616d0a895fd282ad5abf111aad1f6de7fc460a36b6b881ab3f89b02726
@@ -13,13 +13,14 @@ module ForestAdminDatasourceRpc
13
13
  MAX_POLLING_INTERVAL = 3600
14
14
 
15
15
  def initialize(uri, auth_secret, polling_interval: DEFAULT_POLLING_INTERVAL, introspection_schema: nil,
16
- &on_schema_change)
16
+ introspection_etag: nil, &on_schema_change)
17
17
  @uri = uri
18
18
  @auth_secret = auth_secret
19
19
  @polling_interval = polling_interval
20
20
  @on_schema_change = on_schema_change
21
21
  @closed = false
22
22
  @introspection_schema = introspection_schema
23
+ @introspection_etag = introspection_etag
23
24
  @current_schema = nil
24
25
  @cached_etag = nil
25
26
  @connection_attempts = 0
@@ -77,12 +78,12 @@ module ForestAdminDatasourceRpc
77
78
  def compute_etag(schema)
78
79
  return nil if schema.nil?
79
80
 
80
- Digest::SHA1.hexdigest(schema.to_json)
81
+ Digest::SHA1.hexdigest(JSON.generate(schema))
81
82
  end
82
83
 
83
84
  def fetch_initial_schema_sync
84
85
  # If we have an introspection schema, send its ETag to avoid re-downloading unchanged schema
85
- introspection_etag = compute_etag(@introspection_schema) if @introspection_schema
86
+ introspection_etag = @introspection_etag || (@introspection_schema && compute_etag(@introspection_schema))
86
87
  result = @rpc_client.fetch_schema('/forest/rpc-schema', if_none_match: introspection_etag)
87
88
 
88
89
  if result == RpcClient::NotModified
@@ -115,8 +116,9 @@ module ForestAdminDatasourceRpc
115
116
  if @introspection_schema
116
117
  # Fallback to introspection schema - don't crash
117
118
  @current_schema = @introspection_schema
118
- @cached_etag = compute_etag(@current_schema)
119
+ @cached_etag = @introspection_etag || compute_etag(@current_schema)
119
120
  @introspection_schema = nil
121
+ @introspection_etag = nil
120
122
  @initial_sync_completed = true
121
123
  ForestAdminAgent::Facades::Container.logger&.log(
122
124
  'Warn',
@@ -6,10 +6,9 @@ module ForestAdminDatasourceRpc
6
6
  include ForestAdminDatasourceRpc::Utils
7
7
  include ForestAdminDatasourceCustomizer::Decorators::Action
8
8
 
9
- def initialize(datasource, name, options, schema)
9
+ def initialize(datasource, name, schema)
10
10
  super(datasource, name)
11
- @options = options
12
- @client = RpcClient.new(@options[:uri], @options[:auth_secret] || ForestAdminAgent::Facades::Container.cache(:auth_secret))
11
+ @client = datasource.shared_rpc_client
13
12
  @rpc_collection_uri = "/forest/rpc/#{name}"
14
13
  @base_params = { collection_name: name }
15
14
 
@@ -2,6 +2,8 @@ module ForestAdminDatasourceRpc
2
2
  class Datasource < ForestAdminDatasourceToolkit::Datasource
3
3
  include ForestAdminDatasourceRpc::Utils
4
4
 
5
+ attr_reader :shared_rpc_client
6
+
5
7
  def initialize(options, introspection, schema_polling_client = nil)
6
8
  super()
7
9
 
@@ -11,11 +13,15 @@ module ForestAdminDatasourceRpc
11
13
  "collections and #{introspection[:charts].length} charts."
12
14
  )
13
15
 
16
+ @shared_rpc_client = RpcClient.new(
17
+ options[:uri],
18
+ options[:auth_secret] || ForestAdminAgent::Facades::Container.cache(:auth_secret)
19
+ )
20
+
14
21
  introspection[:collections].each do |schema|
15
- add_collection(Collection.new(self, schema[:name], options, schema))
22
+ add_collection(Collection.new(self, schema[:name], schema))
16
23
  end
17
24
 
18
- @options = options
19
25
  @charts = introspection[:charts]
20
26
  @rpc_relations = introspection[:rpc_relations]
21
27
  @schema_polling_client = schema_polling_client
@@ -31,7 +37,6 @@ module ForestAdminDatasourceRpc
31
37
  end
32
38
 
33
39
  def render_chart(caller, name)
34
- client = RpcClient.new(@options[:uri], @options[:auth_secret] || ForestAdminAgent::Facades::Container.cache(:auth_secret))
35
40
  url = 'forest/rpc-datasource-chart'
36
41
 
37
42
  ForestAdminAgent::Facades::Container.logger.log(
@@ -39,11 +44,10 @@ module ForestAdminDatasourceRpc
39
44
  "Forwarding datasource chart '#{name}' call to the Rpc agent on #{url}."
40
45
  )
41
46
 
42
- client.call_rpc(url, caller: caller, method: :post, payload: { chart: name })
47
+ @shared_rpc_client.call_rpc(url, caller: caller, method: :post, payload: { chart: name })
43
48
  end
44
49
 
45
50
  def execute_native_query(connection_name, query, binds)
46
- client = RpcClient.new(@options[:uri], @options[:auth_secret] || ForestAdminAgent::Facades::Container.cache(:auth_secret))
47
51
  url = 'forest/rpc-native-query'
48
52
 
49
53
  ForestAdminAgent::Facades::Container.logger.log(
@@ -51,8 +55,11 @@ module ForestAdminDatasourceRpc
51
55
  "Forwarding native query for connection '#{connection_name}' to the Rpc agent on #{url}."
52
56
  )
53
57
 
54
- result = client.call_rpc(url, method: :post,
55
- payload: { connection_name: connection_name, query: query, binds: binds })
58
+ result = @shared_rpc_client.call_rpc(
59
+ url,
60
+ method: :post,
61
+ payload: { connection_name: connection_name, query: query, binds: binds }
62
+ )
56
63
  ForestAdminDatasourceToolkit::Utils::HashHelper.convert_keys(result.to_a)
57
64
  end
58
65
 
@@ -1,3 +1,3 @@
1
1
  module ForestAdminDatasourceRpc
2
- VERSION = "1.19.1"
2
+ VERSION = "1.19.2"
3
3
  end
@@ -16,6 +16,7 @@ module ForestAdminDatasourceRpc
16
16
  uri = options[:uri]
17
17
  auth_secret = options[:auth_secret] || ForestAdminAgent::Facades::Container.cache(:auth_secret)
18
18
  provided_introspection = options[:introspection]
19
+ provided_introspection_etag = options[:introspection_etag]
19
20
 
20
21
  polling_interval = options[:schema_polling_interval_sec] ||
21
22
  ENV['SCHEMA_POLLING_INTERVAL_SEC']&.to_i ||
@@ -28,7 +29,8 @@ module ForestAdminDatasourceRpc
28
29
  uri,
29
30
  auth_secret,
30
31
  polling_interval: polling_interval,
31
- introspection_schema: provided_introspection
32
+ introspection_schema: provided_introspection,
33
+ introspection_etag: provided_introspection_etag
32
34
  ) do
33
35
  Thread.new do
34
36
  logger = ForestAdminAgent::Facades::Container.logger
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.19.1
4
+ version: 1.19.2
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: 2025-12-24 00:00:00.000000000 Z
12
+ date: 2026-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: base64