Class: EventMeter::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/event_meter/configuration.rb

Constant Summary collapse

DEFAULT_NAMESPACE =
"event_meter:v1"
DEFAULT_REDIS_READ_LIMIT =
nil
DEFAULT_ROLLUP_TTL =
31 * 24 * 60 * 60
DEFAULT_LOCK_TTL =
30
DEFAULT_AUTO_CLEANUP_HISTORY =
false
DEFAULT_CLEANUP_HISTORY_RETENTION =
DEFAULT_ROLLUP_TTL
DEFAULT_CLEANUP_HISTORY_INTERVAL =
60 * 60
DEFAULT_SUMMARY_KEY_LIMIT =
10_000
DEFAULT_AUTO_CLEANUP_ERROR_HANDLER =
lambda do |error|
  warn "EventMeter auto cleanup failed: #{error.class}: #{error.message}"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/event_meter/configuration.rb', line 21

def initialize
  @configuration_lock = Monitor.new
  @namespace = DEFAULT_NAMESPACE
  @redis_read_limit = DEFAULT_REDIS_READ_LIMIT
  @rollup_ttl = DEFAULT_ROLLUP_TTL
  @lock_ttl = DEFAULT_LOCK_TTL
  @auto_cleanup_history = DEFAULT_AUTO_CLEANUP_HISTORY
  @cleanup_history_retention = DEFAULT_CLEANUP_HISTORY_RETENTION
  @cleanup_history_interval = DEFAULT_CLEANUP_HISTORY_INTERVAL
  @summary_key_limit = DEFAULT_SUMMARY_KEY_LIMIT
  @auto_cleanup_error_handler = DEFAULT_AUTO_CLEANUP_ERROR_HANDLER
end

Instance Attribute Details

#auto_cleanup_error_handlerObject

Returns the value of attribute auto_cleanup_error_handler.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def auto_cleanup_error_handler
  @auto_cleanup_error_handler
end

#auto_cleanup_historyObject

Returns the value of attribute auto_cleanup_history.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def auto_cleanup_history
  @auto_cleanup_history
end

#cleanup_history_intervalObject

Returns the value of attribute cleanup_history_interval.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def cleanup_history_interval
  @cleanup_history_interval
end

#cleanup_history_retentionObject

Returns the value of attribute cleanup_history_retention.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def cleanup_history_retention
  @cleanup_history_retention
end

#lock_ttlObject

Returns the value of attribute lock_ttl.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def lock_ttl
  @lock_ttl
end

#namespaceObject

Returns the value of attribute namespace.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def namespace
  @namespace
end

#redisObject

Returns the value of attribute redis.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def redis
  @redis
end

#redis_read_limitObject

Returns the value of attribute redis_read_limit.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def redis_read_limit
  @redis_read_limit
end

#rollup_ttlObject

Returns the value of attribute rollup_ttl.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def rollup_ttl
  @rollup_ttl
end

#summary_key_limitObject

Returns the value of attribute summary_key_limit.



17
18
19
# File 'lib/event_meter/configuration.rb', line 17

def summary_key_limit
  @summary_key_limit
end

Instance Method Details

#rollup_storageObject



114
115
116
117
118
119
# File 'lib/event_meter/configuration.rb', line 114

def rollup_storage
  synchronize do
    reset_redis_clients_if_stale
    @rollup_storage ||= default_rollup_storage
  end
end

#rollup_storage=(storage) ⇒ Object

Raises:

  • (ArgumentError)


121
122
123
124
125
126
127
128
# File 'lib/event_meter/configuration.rb', line 121

def rollup_storage=(storage)
  raise ArgumentError, "rollup_storage cannot be nil" if storage.nil?

  synchronize do
    @rollup_storage = storage
    @rollup_storage_default = false
  end
end

#stream_storageObject



98
99
100
101
102
103
# File 'lib/event_meter/configuration.rb', line 98

def stream_storage
  synchronize do
    reset_redis_clients_if_stale
    @stream_storage ||= default_stream_storage
  end
end

#stream_storage=(storage) ⇒ Object

Raises:

  • (ArgumentError)


105
106
107
108
109
110
111
112
# File 'lib/event_meter/configuration.rb', line 105

def stream_storage=(storage)
  raise ArgumentError, "stream_storage cannot be nil" if storage.nil?

  synchronize do
    @stream_storage = storage
    @stream_storage_default = false
  end
end