class OptimizelyServerSide::DatafileFetcher
Attributes
content[R]
Responsible for fetching the optimizely sdk config from the API source. The API can be optimizely cdn itself or any other source.
success[R]
Responsible for fetching the optimizely sdk config from the API source. The API can be optimizely cdn itself or any other source.
Public Class Methods
call_optimizely_cdn()
click to toggle source
Gets data from Optimizely cdn
# File lib/optimizely_server_side/datafile_fetcher.rb, line 32 def call_optimizely_cdn ActiveSupport::Notifications.instrument "oss.call_optimizely_cdn",this: :data do Net::HTTP.get_response( URI(OptimizelyServerSide.configuration.config_endpoint) ) end end
fallback()
click to toggle source
# File lib/optimizely_server_side/datafile_fetcher.rb, line 40 def fallback new( content: '{"experiments": [],"version": "2","audiences": [],"attributes": [],"groups": [],"projectId": "5960232316","accountId": "5955320306","events": [],"revision": "30"}', success: false ) end
fetch()
click to toggle source
Fetch the Config from the specified source. Incase of any error or exception we goto the fallback data
# File lib/optimizely_server_side/datafile_fetcher.rb, line 20 def fetch begin response = call_optimizely_cdn return fallback unless response.is_a?(Net::HTTPSuccess) new(content: response.body, success: true) rescue Exception => e fallback end end
Also aliased as: datafile
new(content: nil, success: false)
click to toggle source
# File lib/optimizely_server_side/datafile_fetcher.rb, line 11 def initialize(content: nil, success: false) @content = content @success = success end