def get_events(i): client = KronosClient(node._host, blocking=True) start_time = node.start_time + (i * delta) if i == executor.parallelism - 1: end_time = node.end_time else: end_time = start_time + delta - 1 return list(client.get(node.stream, start_time, end_time, namespace=node._namespace))
def __init__(self, source, stream=None, start_time=None, end_time=None, **kwargs): self._config = app.config['DATA_SOURCES'][source] self._host = self._config['url'] self._namespace = self._config['namespace'] self._kronos_client = KronosClient(self._host, namespace=self._namespace) self.type = Operator.Type.DATA_ACCESS self.source = source self.stream = stream self.start_time = start_time self.end_time = end_time super(KronosSource, self).__init__(**kwargs)
def __init__(self): from django.conf import settings from django.core.exceptions import ImproperlyConfigured if not hasattr(settings, 'KRONOS_MIDDLEWARE'): raise ImproperlyConfigured kronos_config = settings.KRONOS_MIDDLEWARE if not isinstance(kronos_config, dict): raise ImproperlyConfigured if 'host' not in kronos_config: raise ImproperlyConfigured if 'stream' not in kronos_config: raise ImproperlyConfigured self.client = KronosClient( kronos_config['host'], blocking=kronos_config.get('blocking', False), sleep_block=kronos_config.get('sleep_block', 0.1)) self.stream = kronos_config['stream'] self.namespace = kronos_config.get('namespace') self.log_exception_stack_trace = kronos_config.get( 'log_exception_stack_trace', False) self.fail_silently = kronos_config.get('fail_silently', True)
def execute(self, node, executor): client = KronosClient(node._host, blocking=True) return client.get(node.stream, node.start_time, node.end_time, namespace=node._namespace)
from pykronos.client import TIMESTAMP_FIELD from pykronos.client import KronosClient from pykronos.client import ResultOrder from pykronos.common.time import datetime_to_kronos_time from datetime import datetime from datetime import timedelta from dateutil.tz import tzutc """ ## Creating A Client Create a Kronos client with the URL of a running server. Optionally provide a `namespace` to explicitly work with events in a particular namespace. """ kc = KronosClient('http://localhost:8151', namespace='kronos') start = datetime.now(tz=tzutc()) """ ### A Non-blocking Client Pass a `blocking=False` to the KronosClient constructor for a client that won't block on the Kronos server when you insert data. A background thread will batch up data and send it to the server. This is useful for logging/metrics collection on machines that can't wait for a write acknowledgement. An optional `sleep_block` argument, defaulting to `0.1` specifies how many seconds to wait between batches to the server. If the process running the client crashes before flushing events, those events will be lost. """ nonblocking = KronosClient('http://localhost:8151', namespace='kronos',