From 2a8d69cd2c33986c63d06ceb821c0f23e6114ae4 Mon Sep 17 00:00:00 2001 From: Seyyed Mohammad Borghei Date: Sun, 29 Dec 2024 18:09:08 +0330 Subject: [PATCH 1/2] Add path to HttpTransport --- logstash_async/transport.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/logstash_async/transport.py b/logstash_async/transport.py index e915ab7..6d60da0 100644 --- a/logstash_async/transport.py +++ b/logstash_async/transport.py @@ -43,6 +43,8 @@ class Transport(ABC): :type host: str :param port: The TCP/UDP port. :type port: int + :param path: The path for the transport. + :type path: str :param timeout: The connection timeout. :type timeout: None or float :param ssl_enable: Activates TLS. @@ -57,6 +59,7 @@ def __init__( self, host: str, port: int, + path: str, timeout: Union[None, float], ssl_enable: bool, ssl_verify: Union[bool, str], @@ -64,6 +67,7 @@ def __init__( ): self._host = host self._port = port + self._path = path self._timeout = None if timeout is TimeoutNotSet else timeout self._ssl_enable = ssl_enable self._ssl_verify = ssl_verify @@ -277,6 +281,8 @@ class HttpTransport(Transport): :type host: str :param port: The TCP port of the logstash HTTP server. :type port: int + :param path: The path of the logstash HTTP server. + :type path: str :param timeout: The connection timeout. (Default: None) :type timeout: float :param ssl_enable: Activates TLS. (Default: True) @@ -301,13 +307,14 @@ def __init__( self, host: str, port: int, + path: str = '', timeout: Union[None, float] = TimeoutNotSet, ssl_enable: bool = True, ssl_verify: Union[bool, str] = True, use_logging: bool = False, **kwargs ): - super().__init__(host, port, timeout, ssl_enable, ssl_verify, use_logging) + super().__init__(host, port, path, timeout, ssl_enable, ssl_verify, use_logging) self._username = kwargs.get('username', None) self._password = kwargs.get('password', None) self._max_content_length = kwargs.get('max_content_length', 100 * 1024 * 1024) @@ -324,7 +331,7 @@ def url(self) -> str: protocol = 'http' if self._ssl_enable: protocol = 'https' - return f'{protocol}://{self._host}:{self._port}' + return f'{protocol}://{self._host}:{self._port}/{self._path}' def __batches(self, events: list) -> Iterator[list]: """Generate dynamic sized batches based on the max content length. From 3d2fbe28604437922990a45b539ac8a8162a3f6b Mon Sep 17 00:00:00 2001 From: Seyyed Mohammad Borghei Date: Wed, 22 Jan 2025 16:32:31 +0330 Subject: [PATCH 2/2] Add path to HttpTransport - core review --- logstash_async/transport.py | 9 +++------ setup.cfg | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/logstash_async/transport.py b/logstash_async/transport.py index 6d60da0..6a1f13b 100644 --- a/logstash_async/transport.py +++ b/logstash_async/transport.py @@ -43,8 +43,6 @@ class Transport(ABC): :type host: str :param port: The TCP/UDP port. :type port: int - :param path: The path for the transport. - :type path: str :param timeout: The connection timeout. :type timeout: None or float :param ssl_enable: Activates TLS. @@ -59,7 +57,6 @@ def __init__( self, host: str, port: int, - path: str, timeout: Union[None, float], ssl_enable: bool, ssl_verify: Union[bool, str], @@ -67,7 +64,6 @@ def __init__( ): self._host = host self._port = port - self._path = path self._timeout = None if timeout is TimeoutNotSet else timeout self._ssl_enable = ssl_enable self._ssl_verify = ssl_verify @@ -307,17 +303,18 @@ def __init__( self, host: str, port: int, - path: str = '', timeout: Union[None, float] = TimeoutNotSet, ssl_enable: bool = True, ssl_verify: Union[bool, str] = True, use_logging: bool = False, + path: str = '', **kwargs ): - super().__init__(host, port, path, timeout, ssl_enable, ssl_verify, use_logging) + super().__init__(host, port, timeout, ssl_enable, ssl_verify, use_logging) self._username = kwargs.get('username', None) self._password = kwargs.get('password', None) self._max_content_length = kwargs.get('max_content_length', 100 * 1024 * 1024) + self._path = path self.__session = None @property diff --git a/setup.cfg b/setup.cfg index 7a16eef..bfd46ca 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,7 +66,8 @@ good-names=i,QUEUED_EVENTS_BATCH_SIZE [pylint.design] min-public-methods=0 max-attributes=15 -max-args=7 +max-args=8 +max-positional-arguments=13 max-parents=9 [pylint.exceptions]