Module: UserPattern
- Defined in:
- lib/userpattern.rb,
lib/userpattern/buffer.rb,
lib/userpattern/engine.rb,
lib/userpattern/version.rb,
lib/userpattern/anonymizer.rb,
lib/userpattern/rate_limiter.rb,
lib/userpattern/configuration.rb,
lib/userpattern/path_normalizer.rb,
lib/userpattern/threshold_cache.rb,
lib/userpattern/stats_calculator.rb,
app/models/user_pattern/violation.rb,
lib/userpattern/threshold_exceeded.rb,
lib/userpattern/violation_recorder.rb,
lib/userpattern/controller_tracking.rb,
app/models/user_pattern/request_event.rb,
lib/userpattern/request_event_cleanup.rb,
app/controllers/user_pattern/dashboard_controller.rb
Defined Under Namespace
Modules: ControllerTracking, PathNormalizer, RequestEventCleanup
Classes: Anonymizer, Buffer, Configuration, DashboardController, Engine, RateLimiter, RequestEvent, StatsCalculator, ThresholdCache, ThresholdExceeded, Violation, ViolationRecorder
Constant Summary
collapse
- VERSION =
'0.2.1'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.rate_limiter ⇒ Object
Returns the value of attribute rate_limiter.
23
24
25
|
# File 'lib/userpattern.rb', line 23
def rate_limiter
@rate_limiter
end
|
.threshold_cache ⇒ Object
Returns the value of attribute threshold_cache.
23
24
25
|
# File 'lib/userpattern.rb', line 23
def threshold_cache
@threshold_cache
end
|
Class Method Details
.buffer ⇒ Object
16
17
18
19
20
21
|
# File 'lib/userpattern.rb', line 16
def buffer
@buffer ||= begin
require 'userpattern/buffer'
Buffer.new
end
end
|
.cleanup! ⇒ Object
38
39
40
41
|
# File 'lib/userpattern.rb', line 38
def cleanup!
require 'userpattern/request_event_cleanup'
RequestEventCleanup.run!
end
|
.configuration ⇒ Object
8
9
10
|
# File 'lib/userpattern.rb', line 8
def configuration
@configuration ||= Configuration.new
end
|
12
13
14
|
# File 'lib/userpattern.rb', line 12
def configure
yield(configuration)
end
|
.enabled? ⇒ Boolean
34
35
36
|
# File 'lib/userpattern.rb', line 34
def enabled?
configuration.enabled
end
|
.reset! ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/userpattern.rb', line 43
def reset!
@buffer&.shutdown
@threshold_cache&.shutdown
@configuration = Configuration.new
@buffer = nil
@threshold_cache = nil
@rate_limiter = nil
end
|
.start_alert_mode! ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/userpattern.rb', line 25
def start_alert_mode!
require 'userpattern/threshold_cache'
require 'userpattern/rate_limiter'
@threshold_cache = ThresholdCache.new
store = configuration.rate_limiter_store || default_cache_store
@rate_limiter = RateLimiter.new(store: store, threshold_cache: @threshold_cache)
end
|