.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, *args)
 
 get (self, *args)
 
 add (self, value, *args)
 
 dump (self)
 

Public Attributes

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

Static Private Attributes

str __slots__ = 'counters', 'lock'
 

Detailed Description

Definition at line 128 of file models.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 132 of file models.py.

132 def __init__(self):
133 self.lock = threading.Lock()
134 self.clear()
135

Member Function Documentation

◆ add()

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

Reimplemented in searx.metrics.models.VoidCounterStorage.

Definition at line 147 of file models.py.

147 def add(self, value, *args):
148 with self.lock:
149 self.counters[args] += value
150

References counters, and lock.

◆ clear()

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

Definition at line 136 of file models.py.

136 def clear(self):
137 with self.lock:
138 self.counters = {}
139

References lock.

◆ configure()

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

Definition at line 140 of file models.py.

140 def configure(self, *args):
141 with self.lock:
142 self.counters[args] = 0
143

References counters, and lock.

◆ dump()

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

Definition at line 151 of file models.py.

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

References counters, and lock.

◆ get()

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

Definition at line 144 of file models.py.

144 def get(self, *args):
145 return self.counters[args]
146

References counters.

Referenced by 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 130 of file models.py.

◆ counters

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

Definition at line 138 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: