Skip to content

Commit

Permalink
Support url path in HttpTransport (#103)
Browse files Browse the repository at this point in the history
* Add path to HttpTransport
  • Loading branch information
memlucky71 authored Jan 26, 2025
1 parent 25254d4 commit 7f9a507
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion logstash_async/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,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)
Expand Down Expand Up @@ -305,12 +307,14 @@ def __init__(
ssl_enable: bool = True,
ssl_verify: Union[bool, str] = True,
use_logging: bool = False,
path: str = '',
**kwargs
):
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
Expand All @@ -324,7 +328,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.
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 7f9a507

Please sign in to comment.