Skip to content

Commit 7f9a507

Browse files
authored
Support url path in HttpTransport (#103)
* Add path to HttpTransport
1 parent 25254d4 commit 7f9a507

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

logstash_async/transport.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ class HttpTransport(Transport):
277277
:type host: str
278278
:param port: The TCP port of the logstash HTTP server.
279279
:type port: int
280+
:param path: The path of the logstash HTTP server.
281+
:type path: str
280282
:param timeout: The connection timeout. (Default: None)
281283
:type timeout: float
282284
:param ssl_enable: Activates TLS. (Default: True)
@@ -305,12 +307,14 @@ def __init__(
305307
ssl_enable: bool = True,
306308
ssl_verify: Union[bool, str] = True,
307309
use_logging: bool = False,
310+
path: str = '',
308311
**kwargs
309312
):
310313
super().__init__(host, port, timeout, ssl_enable, ssl_verify, use_logging)
311314
self._username = kwargs.get('username', None)
312315
self._password = kwargs.get('password', None)
313316
self._max_content_length = kwargs.get('max_content_length', 100 * 1024 * 1024)
317+
self._path = path
314318
self.__session = None
315319

316320
@property
@@ -324,7 +328,7 @@ def url(self) -> str:
324328
protocol = 'http'
325329
if self._ssl_enable:
326330
protocol = 'https'
327-
return f'{protocol}://{self._host}:{self._port}'
331+
return f'{protocol}://{self._host}:{self._port}/{self._path}'
328332

329333
def __batches(self, events: list) -> Iterator[list]:
330334
"""Generate dynamic sized batches based on the max content length.

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ good-names=i,QUEUED_EVENTS_BATCH_SIZE
6666
[pylint.design]
6767
min-public-methods=0
6868
max-attributes=15
69-
max-args=7
69+
max-args=8
70+
max-positional-arguments=13
7071
max-parents=9
7172

7273
[pylint.exceptions]

0 commit comments

Comments
 (0)