Class: AmplitudeExperiment::RemoteEvaluationConfig

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

Overview

Configuration

Constant Summary collapse

DEFAULT_SERVER_URL =

Default server url

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debug: false, logger: nil, server_url: DEFAULT_SERVER_URL, connect_timeout_millis: 60_000, fetch_timeout_millis: 10_000, fetch_retries: 0, fetch_retry_backoff_min_millis: 500, fetch_retry_backoff_max_millis: 10_000, fetch_retry_backoff_scalar: 1.5, fetch_retry_timeout_millis: 10_000) ⇒ RemoteEvaluationConfig

Returns a new instance of RemoteEvaluationConfig.

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.

  • connect_timeout_millis (Integer) (defaults to: 60_000)

    The request connection open timeout, in milliseconds, used when fetching variants triggered by calling start() or setUser().

  • fetch_timeout_millis (Integer) (defaults to: 10_000)

    The request timeout, in milliseconds, used when fetching variants triggered by calling start() or setUser().

  • fetch_retries (Integer) (defaults to: 0)

    The number of retries to attempt before failing.

  • fetch_retry_backoff_min_millis (Integer) (defaults to: 500)

    Retry backoff minimum (starting backoff delay) in milliseconds. The minimum backoff is scaled by ‘fetch_retry_backoff_scalar` after each retry failure.

  • fetch_retry_backoff_max_millis (Integer) (defaults to: 10_000)

    Retry backoff maximum in milliseconds. If the scaled backoff is greater than the max, the max is used for all subsequent retries.

  • fetch_retry_backoff_scalar (Float) (defaults to: 1.5)

    Scales the minimum backoff exponentially.

  • fetch_retry_timeout_millis (Integer) (defaults to: 10_000)

    The request timeout for retrying fetch requests.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/experiment/remote/config.rb', line 67

def initialize(debug: false,
               logger: nil,
               server_url: DEFAULT_SERVER_URL,
               connect_timeout_millis: 60_000,
               fetch_timeout_millis: 10_000,
               fetch_retries: 0,
               fetch_retry_backoff_min_millis: 500,
               fetch_retry_backoff_max_millis: 10_000,
               fetch_retry_backoff_scalar: 1.5,
               fetch_retry_timeout_millis: 10_000)
  @logger = logger
  if logger.nil?
    @logger = Logger.new(DEFAULT_LOGDEV)
    @logger.level = debug ? Logger::DEBUG : DEFAULT_LOG_LEVEL
  end
  @server_url = server_url
  @connect_timeout_millis = connect_timeout_millis
  @fetch_timeout_millis = fetch_timeout_millis
  @fetch_retries = fetch_retries
  @fetch_retry_backoff_min_millis = fetch_retry_backoff_min_millis
  @fetch_retry_backoff_max_millis = fetch_retry_backoff_max_millis
  @fetch_retry_backoff_scalar = fetch_retry_backoff_scalar
  @fetch_retry_timeout_millis = fetch_retry_timeout_millis
end

Instance Attribute Details

#connect_timeout_millisInteger

The request connection open timeout, in milliseconds, used when fetching variants triggered by calling start() or setUser().

Returns:

  • (Integer)

    the value of connect_timeout_millis



25
26
27
# File 'lib/experiment/remote/config.rb', line 25

def connect_timeout_millis
  @connect_timeout_millis
end

#debugBoolean

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

Returns:

  • (Boolean)

    the value of debug



13
14
15
# File 'lib/experiment/remote/config.rb', line 13

def debug
  @debug
end

#fetch_retriesInteger

The number of retries to attempt before failing.

Returns:

  • (Integer)

    the value of fetch_retries



33
34
35
# File 'lib/experiment/remote/config.rb', line 33

def fetch_retries
  @fetch_retries
end

#fetch_retry_backoff_max_millisInteger

Retry backoff maximum in milliseconds. If the scaled backoff is greater than the max,

the max is used for all subsequent retries.

Returns:

  • (Integer)

    the value of fetch_retry_backoff_max_millis



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

def fetch_retry_backoff_max_millis
  @fetch_retry_backoff_max_millis
end

#fetch_retry_backoff_min_millisInteger

Retry backoff minimum (starting backoff delay) in milliseconds. The minimum backoff is scaled

by `fetch_retry_backoff_scalar` after each retry failure.

Returns:

  • (Integer)

    the value of fetch_retry_backoff_min_millis



38
39
40
# File 'lib/experiment/remote/config.rb', line 38

def fetch_retry_backoff_min_millis
  @fetch_retry_backoff_min_millis
end

#fetch_retry_backoff_scalarFloat

Scales the minimum backoff exponentially.

Returns:

  • (Float)

    the value of fetch_retry_backoff_scalar



47
48
49
# File 'lib/experiment/remote/config.rb', line 47

def fetch_retry_backoff_scalar
  @fetch_retry_backoff_scalar
end

#fetch_retry_timeout_millisInteger

The request timeout for retrying fetch requests.

Returns:

  • (Integer)

    the value of fetch_retry_timeout_millis



51
52
53
# File 'lib/experiment/remote/config.rb', line 51

def fetch_retry_timeout_millis
  @fetch_retry_timeout_millis
end

#fetch_timeout_millisInteger

The request timeout, in milliseconds, used when fetching variants triggered by calling start() or setUser().

Returns:

  • (Integer)

    the value of fetch_timeout_millis



29
30
31
# File 'lib/experiment/remote/config.rb', line 29

def fetch_timeout_millis
  @fetch_timeout_millis
end

#loggerLogger

Set the client logger to a user defined [Logger]

Returns:

  • (Logger)

    the logger instance of the client



17
18
19
# File 'lib/experiment/remote/config.rb', line 17

def logger
  @logger
end

#server_urlBoolean

The server endpoint from which to request variants.

Returns:

  • (Boolean)

    the value of server url



21
22
23
# File 'lib/experiment/remote/config.rb', line 21

def server_url
  @server_url
end