Skip to content

Commit

Permalink
meeting pipeline test requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
david committed Mar 25, 2024
1 parent 469767d commit 5ce5203
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions logprep/connector/http/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ def shut_down(self):
class HttpConnector(Input):
"""Connector to accept log messages as http post requests"""

messages: queue.Queue = queue.Queue()

_endpoint_registry: Mapping[str, HttpEndpoint] = {
"json": JSONHttpEndpoint,
"plaintext": PlaintextHttpEndpoint,
Expand Down Expand Up @@ -328,11 +330,6 @@ def __init__(self, name: str, configuration: "HttpConnector.Config", logger: Log
self.host = self._config.uvicorn_config["host"]
self.target = "http://" + self.host + ":" + str(self.port)

if not hasattr(self, "messages"):
self.messages = None
if not hasattr(self, "http_server"):
self.http_server = None

def setup(self):
super().setup()
if not hasattr(self, "pipeline_index"):
Expand All @@ -343,14 +340,16 @@ def setup(self):
if self.pipeline_index != 1:
return

self.messages = queue.Queue(self._config.message_backlog_size)
self.messages = queue.Queue(
self._config.message_backlog_size
) # pylint: disable=attribute-defined-outside-init

endpoints_config = {}
for endpoint_path, endpoint_name in self._config.endpoints.items():
endpoint_class = self._endpoint_registry.get(endpoint_name)
endpoints_config[endpoint_path] = endpoint_class(self.messages)

self.http_server = ThreadingHTTPServer(
self.http_server = ThreadingHTTPServer( # pylint: disable=attribute-defined-outside-init
connector_config=self._config,
endpoints_config=endpoints_config,
log_level=self._logger.level,
Expand All @@ -375,4 +374,7 @@ def get_server_instance(self):

def shut_down(self):
"""Raises Uvicorn HTTP Server internal stop flag and waits to join"""
self.http_server.shut_down()
try:
self.http_server.shut_down()
except:
pass

0 comments on commit 5ce5203

Please sign in to comment.