.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 = {}
 
int lock = 0
 

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 searx.metrics.models.CounterStorage.counters, searx.metrics.models.CounterStorage.lock, and searx.search.processors.abstract.SuspendedStatus.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 searx.metrics.models.CounterStorage.lock, and searx.search.processors.abstract.SuspendedStatus.lock.

Referenced by searx.metrics.models.HistogramStorage.__init__().

+ Here is the caller graph for this function:

◆ 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

◆ 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 searx.metrics.models.CounterStorage.counters, searx.metrics.models.CounterStorage.lock, and searx.search.processors.abstract.SuspendedStatus.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 searx.metrics.models.CounterStorage.counters.

Referenced by searx.botdetection.config.Config.__getitem__(), searx.botdetection.config.Config.path(), and searx.botdetection.config.Config.pyobj().

+ 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 = {}

◆ lock [1/2]

◆ lock [2/2]


The documentation for this class was generated from the following file: