Commit 6c95ac26 authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Merge branch 'noc-928' into 'microservices'

#928 Add Datastream Mode config parameter.

See merge request !1196
parents 0272b243 e53100dc
Pipeline #8200 passed with stages
in 53 seconds
......@@ -517,12 +517,33 @@ class Config(BaseConfig):
class datastream(ConfigSection):
enable_administrativedomain = BooleanParameter(default=True)
enable_administrativedomain_wait = BooleanParameter(
default=True,
help="Activate Wait Mode for Adm. Domain datastream (Mongo greater 3.6 needed)")
enable_cfgping = BooleanParameter(default=True)
enable_cfgping_wait = BooleanParameter(
default=True,
help="Activate Wait Mode for CfgPing datastream (Mongo greater 3.6 needed)")
enable_cfgsyslog = BooleanParameter(default=True)
enable_cfgsyslog_wait = BooleanParameter(
default=True,
help="Activate Wait Mode for CfgSyslog datastream (Mongo greater 3.6 needed)")
enable_cfgtrap = BooleanParameter(default=True)
enable_dnszone = BooleanParameter(default=True)
enable_cfgtrap_wait = BooleanParameter(
default=True,
help="Activate Wait Mode for CfgTrap datastream (Mongo greater 3.6 needed)")
enable_dnszone = BooleanParameter(default=False)
enable_dnszone_wait = BooleanParameter(
default=True,
help="Activate Wait Mode for DNS Zone datastream (Mongo greater 3.6 needed)")
enable_managedobject = BooleanParameter(default=True)
enable_managedobject_wait = BooleanParameter(
default=True,
help="Activate Wait Mode for ManagedObject datastream (Mongo greater 3.6 needed)")
enable_resourcegroup = BooleanParameter(default=True)
enable_resourcegroup_wait = BooleanParameter(
default=True,
help="Activate Wait Mode for ResourceGroup datastream (Mongo greater 3.6 needed)")
class help(ConfigSection):
base_url = StringParameter(default="https://docs.getnoc.com")
......
......@@ -61,15 +61,19 @@ class DataStreamService(Service):
def on_activate(self):
# Detect we have working .watch() implementation
if self.has_watch():
waiter = self.watch_waiter
has_watch = True
else:
self.logger.warning(
"Realtime change tracking is not available, using polling emulation."
)
waiter = self.sleep_waiter
has_watch = False
# Start watcher threads
self.ds_queue = {}
for ds in self.get_datastreams():
if has_watch and getattr(config.datastream, "enable_%s_wait" % ds.name):
waiter = self.watch_waiter
else:
waiter = self.sleep_waiter
self.logger.info("Starting %s waiter thread", ds.name)
queue = Queue.Queue()
self.ds_queue[ds.name] = queue
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment