Module: Wurk::Web::Enterprise::Limits
- Defined in:
- lib/wurk/web/enterprise.rb
Overview
Limits tab — list every registered limiter, filter by name, expose reset + delete. List/metrics already render via ‘Wurk::Limiter::Base`; this wrapper adds the name filter documented in §1.2.0+.
Class Method Summary collapse
-
.list(filter: nil) ⇒ Array<String>
Limiter names, optionally filtered to those whose name contains the case-insensitive substring ‘filter`.
- .metadata(name) ⇒ Object
-
.reset(name) ⇒ Object
Stats-key reset: drops every ‘lmtr-stats:` / state key for the named limiter while keeping its metadata + LIST membership so the row remains in the UI.
Class Method Details
.list(filter: nil) ⇒ Array<String>
Returns limiter names, optionally filtered to those whose name contains the case-insensitive substring ‘filter`.
27 28 29 30 31 32 33 |
# File 'lib/wurk/web/enterprise.rb', line 27 def list(filter: nil) names = Wurk.redis { |c| c.call('SMEMBERS', Wurk::Limiter::LIST_KEY) }.sort return names if filter.nil? || filter.to_s.empty? needle = filter.to_s.downcase names.select { |n| n.downcase.include?(needle) } end |
.metadata(name) ⇒ Object
35 36 37 38 |
# File 'lib/wurk/web/enterprise.rb', line 35 def (name) raw = Wurk.redis { |c| c.call('HGETALL', "lmtr:#{name}") } raw.is_a?(Array) ? raw.each_slice(2).to_h : raw end |
.reset(name) ⇒ Object
Stats-key reset: drops every ‘lmtr-stats:` / state key for the named limiter while keeping its metadata + LIST membership so the row remains in the UI. Mirrors the §1.5 `#reset` surface — the name is wire-compat, so the trailing-? rule doesn’t apply here.
44 45 46 47 48 49 50 |
# File 'lib/wurk/web/enterprise.rb', line 44 def reset(name) # rubocop:disable Naming/PredicateMethod Wurk.redis do |c| %W[lmtr-cs:#{name} lmtr-b:#{name} lmtr-w:#{name} lmtr-l:#{name} lmtr-p:#{name} lmtr-stats:#{name}].each { |k| c.call('DEL', k) } end true end |