def __init__(self, url, last_id=None, retry=3000, connect_timeout=10, read_timeout=300, chunk_size=10000, verify_ssl=False, http=None, http_proxy=None, **kwargs): self.url = url self.last_id = last_id self.retry = retry self._connect_timeout = connect_timeout self._read_timeout = read_timeout self._chunk_size = chunk_size # Optional support for passing in an HTTP client self.http = create_http_pool_manager(num_pools=1, verify_ssl=verify_ssl, target_base_uri=url, force_proxy=http_proxy) # Any extra kwargs will be fed into the request call later. self.requests_kwargs = kwargs # The SSE spec requires making requests with Cache-Control: nocache if 'headers' not in self.requests_kwargs: self.requests_kwargs['headers'] = {} self.requests_kwargs['headers']['Cache-Control'] = 'no-cache' # The 'Accept' header is not required, but explicit > implicit self.requests_kwargs['headers']['Accept'] = 'text/event-stream' # Keep data here as it streams in self.buf = u'' self._connect()
def __init__(self, inbox, config, http_client, diagnostic_accumulator=None): self._inbox = inbox self._config = config self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl, target_base_uri=config.events_uri, force_proxy=config.http_proxy) if http_client is None else http_client self._close_http = (http_client is None) # so we know whether to close it later self._disabled = False self._outbox = EventBuffer(config.events_max_pending) self._user_keys = SimpleLRUCache(config.user_keys_capacity) self._formatter = EventOutputFormatter(config) self._last_known_past_time = 0 self._deduplicated_users = 0 self._diagnostic_accumulator = None if config.diagnostic_opt_out else diagnostic_accumulator self._flush_workers = FixedThreadPool(__MAX_FLUSH_THREADS__, "ldclient.flush") self._diagnostic_flush_workers = None if self._diagnostic_accumulator is None else FixedThreadPool(1, "ldclient.diag_flush") if self._diagnostic_accumulator is not None: init_event = create_diagnostic_init(self._diagnostic_accumulator.data_since_date, self._diagnostic_accumulator.diagnostic_id, config) task = DiagnosticEventSendTask(self._http, self._config, init_event) self._diagnostic_flush_workers.execute(task.run) self._main_thread = Thread(target=self._run_main_loop) self._main_thread.daemon = True self._main_thread.start()
def __init__(self, queue, config, http_client): self._queue = queue self._config = config self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl) if http_client is None else http_client self._close_http = (http_client is None) # so we know whether to close it later self._disabled = False self._buffer = EventBuffer(config.events_max_pending) self._user_keys = SimpleLRUCache(config.user_keys_capacity) self._formatter = EventOutputFormatter(config) self._last_known_past_time = 0 self._flush_workers = FixedThreadPool(__MAX_FLUSH_THREADS__, "ldclient.flush") self._main_thread = Thread(target=self._run_main_loop) self._main_thread.daemon = True self._main_thread.start()
def __init__(self, config): self._cache = dict() self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl) self._config = config
def __init__(self, config): self._cache = dict() self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl, target_base_uri=config.base_uri, force_proxy=config.http_proxy) self._config = config
def __init__(self, config): self._cache = dict() self._http = create_http_pool_manager(num_pools=1, verify_ssl=config.verify_ssl) self._config = config