Skip to content

Commit

Permalink
add ConstantRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
bucko909 committed Aug 21, 2024
1 parent 52b40b2 commit 60da284
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/carbon/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ def getDestinations(self, key):
raise NotImplementedError()


class ConstantRouter(DatapointRouter):
plugin_name = 'constant'

def __init__(self, settings):
self.destinations = set()

def addDestination(self, destination):
self.destinations.add(destination)

def removeDestination(self, destination):
self.destinations.discard(destination)

def hasDestination(self, destination):
return destination in self.destinations

def countDestinations(self):
return len(self.destinations)

def getDestinations(self, key):
for destination in self.destinations:
yield destination


class RelayRulesRouter(DatapointRouter):
plugin_name = 'rules'

Expand Down

0 comments on commit 60da284

Please sign in to comment.