Method: Optimizely::HTTPProjectConfigManager#config

Defined in:
lib/optimizely/config_manager/http_project_config_manager.rb

#configObject



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/optimizely/config_manager/http_project_config_manager.rb', line 120

def config
  # Get Project Config.

  # if stopped is true, then simply return @config.
  # If the background datafile polling thread is running. and config has been initalized,
  # we simply return @config.
  # If it is not, we wait and block maximum for @blocking_timeout.
  # If thread is not running, we fetch the datafile and update config.
  return @config if @stopped

  if @async_scheduler.running
    return @config if ready?

    @mutex.synchronize do
      @resource.wait(@mutex, @blocking_timeout)
      return @config
    end
  end

  fetch_datafile_config
  @config
end