22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/datadog/open_feature/remote.rb', line 22
def receivers(telemetry, component_provider:, logger: Datadog.logger)
matcher = Core::Remote::Dispatcher::Matcher::Product.new(FFE_PRODUCTS)
receiver = Core::Remote::Dispatcher::Receiver.new(matcher) do |repository, changes|
component = component_provider.call
next unless component
changes.each do |change|
content = repository[change.path]
logger.debug do
version = content ? " (version #{content.version})" : ""
"Feature Flags: received Remote Configuration #{change.type} for #{change.path}#{version}"
end
unless content || change.type == :delete
logger.debug do
"Feature Flags: ignored Remote Configuration #{change.type} for #{change.path}: content is missing"
end
next telemetry.error("OpenFeature: Remote Configuration change is not present on #{change.type}")
end
case change.type
when :insert, :update
begin
component.reconfigure!(read_content(content))
content.applied
rescue EvaluationEngine::ReconfigurationError => e
content.errored("Error applying OpenFeature configuration: #{e.class}: #{e.message}")
end
when :delete
component.reconfigure!(nil)
end
end
end
[receiver]
end
|