Class: AmplitudeExperiment::LocalEvaluationConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/experiment/local/config.rb

Overview

LocalEvaluationConfig

Constant Summary collapse

DEFAULT_SERVER_URL =

Default server url

'https://api.lab.amplitude.com'.freeze
EU_SERVER_URL =
'https://flag.lab.eu.amplitude.com'.freeze
DEFAULT_LOGDEV =
$stdout
DEFAULT_LOG_LEVEL =
Logger::ERROR

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_url: DEFAULT_SERVER_URL, server_zone: ServerZone::US, bootstrap: {}, flag_config_polling_interval_millis: 30_000, debug: false, logger: nil, assignment_config: nil, cohort_sync_config: nil) ⇒ LocalEvaluationConfig

Returns a new instance of LocalEvaluationConfig.

Parameters:

  • debug (Boolean) (defaults to: false)

    Set to true to log some extra information to the console.

  • logger (Logger) (defaults to: nil)

    instance to be used for all client logging behavior

  • server_url (String) (defaults to: DEFAULT_SERVER_URL)

    The server endpoint from which to request variants.

  • server_zone (String) (defaults to: ServerZone::US)

    Location of the Amplitude data center to get flags and cohorts from, US or EU

  • bootstrap (Hash) (defaults to: {})

    The value of bootstrap.

  • flag_config_polling_interval_millis (long) (defaults to: 30_000)

    The value of flag config polling interval in million seconds.

  • assignment_config (AssignmentConfig) (defaults to: nil)

    Configuration for automatically tracking assignment events after an evaluation.

  • cohort_sync_config (CohortSyncConfig) (defaults to: nil)

    Configuration for downloading cohorts required for flag evaluation



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/experiment/local/config.rb', line 53

def initialize(server_url: DEFAULT_SERVER_URL,
               server_zone: ServerZone::US,
               bootstrap: {},
               flag_config_polling_interval_millis: 30_000,
               debug: false,
               logger: nil,
               assignment_config: nil,
               cohort_sync_config: nil)
  @logger = logger
  if logger.nil?
    @logger = Logger.new(DEFAULT_LOGDEV)
    @logger.level = debug ? Logger::DEBUG : DEFAULT_LOG_LEVEL
  end
  @server_url = server_url
  @server_zone = server_zone
  @cohort_sync_config = cohort_sync_config
  if server_url == DEFAULT_SERVER_URL && @server_zone == ServerZone::EU
    @server_url = EU_SERVER_URL
    @cohort_sync_config.cohort_server_url = EU_COHORT_SYNC_URL if @cohort_sync_config && @cohort_sync_config.cohort_server_url == DEFAULT_COHORT_SYNC_URL
  end
  @bootstrap = bootstrap
  @flag_config_polling_interval_millis = flag_config_polling_interval_millis
  @assignment_config = assignment_config
end

Instance Attribute Details

#assignment_configAssignmentConfig

Configuration for automatically tracking assignment events after an evaluation.

Returns:



39
40
41
# File 'lib/experiment/local/config.rb', line 39

def assignment_config
  @assignment_config
end

#cohort_sync_configCohortSyncConfig

Configuration for downloading cohorts required for flag evaluation

Returns:



43
44
45
# File 'lib/experiment/local/config.rb', line 43

def cohort_sync_config
  @cohort_sync_config
end

#debugBoolean

Set to true to log some extra information to the console.

Returns:

  • (Boolean)

    the value of debug



19
20
21
# File 'lib/experiment/local/config.rb', line 19

def debug
  @debug
end

#flag_config_polling_interval_millislong

The polling interval for flag configs.

Returns:

  • (long)

    the value of flag config polling interval in million seconds



35
36
37
# File 'lib/experiment/local/config.rb', line 35

def flag_config_polling_interval_millis
  @flag_config_polling_interval_millis
end

#loggerLogger

Set the client logger to a user defined [Logger]

Returns:

  • (Logger)

    the logger instance of the client



23
24
25
# File 'lib/experiment/local/config.rb', line 23

def logger
  @logger
end

#server_urlString

The server endpoint from which to request variants.

Returns:

  • (String)

    the value of server url



27
28
29
# File 'lib/experiment/local/config.rb', line 27

def server_url
  @server_url
end

#server_zoneString

Location of the Amplitude data center to get flags and cohorts from, US or EU

Returns:

  • (String)

    the value of server zone



31
32
33
# File 'lib/experiment/local/config.rb', line 31

def server_zone
  @server_zone
end