.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.metrics.models.CounterStorage Class Reference
Inheritance diagram for searx.metrics.models.CounterStorage:

Public Member Functions

 __init__ (self)
 clear (self)
 configure (self, *str args)
 get (self, *str args)
 add (self, int value, *str args)
 dump (self)

Public Attributes

 lock = threading.Lock()
dict counters = {}

Static Private Attributes

str __slots__ = 'counters', 'lock'

Detailed Description

Definition at line 130 of file models.py.

Constructor & Destructor Documentation

◆ __init__()

searx.metrics.models.CounterStorage.__init__ ( self)

Definition at line 134 of file models.py.

134 def __init__(self):
135 self.lock = threading.Lock()
136 self.clear()
137

Member Function Documentation

◆ add()

searx.metrics.models.CounterStorage.add ( self,
int value,
*str args )

Reimplemented in searx.metrics.models.VoidCounterStorage.

Definition at line 149 of file models.py.

149 def add(self, value: int, *args: str):
150 with self.lock:
151 self.counters[args] += value
152

References counters, and lock.

◆ clear()

searx.metrics.models.CounterStorage.clear ( self)

Definition at line 138 of file models.py.

138 def clear(self):
139 with self.lock:
140 self.counters: dict[t.Hashable, int] = {}
141

References lock.

◆ configure()

searx.metrics.models.CounterStorage.configure ( self,
*str args )

Definition at line 142 of file models.py.

142 def configure(self, *args: str):
143 with self.lock:
144 self.counters[args] = 0
145

References counters, and lock.

◆ dump()

searx.metrics.models.CounterStorage.dump ( self)

Definition at line 153 of file models.py.

153 def dump(self):
154 with self.lock:
155 ks = sorted(self.counters.keys(), key='/'.join) # pylint: disable=invalid-name
156 logger.debug("Counters:")
157 for k in ks:
158 logger.debug("- %-60s %s", '|'.join(k), self.counters[k])
159
160

References counters, and lock.

◆ get()

searx.metrics.models.CounterStorage.get ( self,
*str args )

Definition at line 146 of file models.py.

146 def get(self, *args: str):
147 return self.counters[args]
148

References counters.

Referenced by searx.result_types._base.LegacyResult.__init__(), searx.result_types._base.LegacyResult.defaults_from(), and searx.answerers._core.AnswerStorage.register().

Here is the caller graph for this function:

Member Data Documentation

◆ __slots__

str searx.metrics.models.CounterStorage.__slots__ = 'counters', 'lock'
staticprivate

Definition at line 132 of file models.py.

◆ counters

dict searx.metrics.models.CounterStorage.counters = {}

Definition at line 140 of file models.py.

Referenced by add(), configure(), dump(), and get().

◆ lock

searx.metrics.models.CounterStorage.lock = threading.Lock()

The documentation for this class was generated from the following file:
  • /home/andrew/Documents/code/public/searxng/searx/metrics/models.py