qena-shared-lib 0.1.12__py3-none-any.whl → 0.1.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qena_shared_lib/__init__.py +2 -2
- qena_shared_lib/application.py +71 -29
- qena_shared_lib/background.py +6 -5
- qena_shared_lib/exception_handlers.py +203 -175
- qena_shared_lib/exceptions.py +10 -10
- qena_shared_lib/http.py +16 -16
- qena_shared_lib/rabbitmq/__init__.py +8 -6
- qena_shared_lib/rabbitmq/_base.py +96 -127
- qena_shared_lib/rabbitmq/_channel.py +4 -1
- qena_shared_lib/rabbitmq/_exception_handlers.py +154 -119
- qena_shared_lib/rabbitmq/_listener.py +94 -38
- qena_shared_lib/rabbitmq/_rpc_client.py +4 -4
- qena_shared_lib/remotelogging/__init__.py +15 -0
- qena_shared_lib/{logstash → remotelogging}/_base.py +47 -67
- qena_shared_lib/remotelogging/logstash/__init__.py +9 -0
- qena_shared_lib/remotelogging/logstash/_base.py +32 -0
- qena_shared_lib/{logstash → remotelogging/logstash}/_http_sender.py +5 -4
- qena_shared_lib/{logstash → remotelogging/logstash}/_tcp_sender.py +7 -5
- qena_shared_lib/scheduler.py +49 -24
- qena_shared_lib/security.py +2 -2
- qena_shared_lib/utils.py +9 -3
- {qena_shared_lib-0.1.12.dist-info → qena_shared_lib-0.1.14.dist-info}/METADATA +23 -20
- qena_shared_lib-0.1.14.dist-info/RECORD +31 -0
- qena_shared_lib/logstash/__init__.py +0 -17
- qena_shared_lib-0.1.12.dist-info/RECORD +0 -29
- {qena_shared_lib-0.1.12.dist-info → qena_shared_lib-0.1.14.dist-info}/WHEEL +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: qena-shared-lib
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.14
|
4
4
|
Summary: A shared tools for other services
|
5
5
|
Requires-Python: >=3.10
|
6
6
|
Requires-Dist: cronsim==2.6
|
@@ -21,7 +21,8 @@ A shared tools for other services. It includes.
|
|
21
21
|
- FastAPI app builder
|
22
22
|
- A wrapper around fastapi to make it class based.
|
23
23
|
- RabbitMQ utility class to listen, respond, publish and make rpc request.
|
24
|
-
-
|
24
|
+
- Remote logging
|
25
|
+
- Logstash utility class to log message in `ecs` ( elastic common schema ).
|
25
26
|
- A simple task scheduler, to schedule task to run in specific time.
|
26
27
|
- Background task runner.
|
27
28
|
- Security tools ( password hasher, jwt, acl ).
|
@@ -178,41 +179,43 @@ def main() -> FastAPI:
|
|
178
179
|
...
|
179
180
|
```
|
180
181
|
|
181
|
-
##
|
182
|
+
## Remote logging
|
182
183
|
|
184
|
+
### Logstash
|
183
185
|
``` py
|
184
|
-
from qena_shared_lib.
|
186
|
+
from qena_shared_lib.remotelogging import BaseRemoteLogSender
|
187
|
+
from qena_shared_lib.remotelogging.logstash import HTTPSender, # TCPSender
|
185
188
|
|
186
189
|
|
187
190
|
@asynccontextmanager
|
188
191
|
async def lifespan(app: FastAPI):
|
189
|
-
|
192
|
+
remote_logger = get_service(BaseRemoteLogSender)
|
190
193
|
|
191
|
-
await
|
194
|
+
await remote_logger.start()
|
192
195
|
|
193
196
|
yield
|
194
197
|
|
195
|
-
await
|
198
|
+
await remote_logger.stop()
|
196
199
|
|
197
200
|
|
198
201
|
def main() -> FastAPI:
|
199
202
|
...
|
200
203
|
|
201
|
-
|
204
|
+
remote_logger = HTTPSender(
|
202
205
|
service_name="qena-shared-lib",
|
203
206
|
url="http://127.0.0.1:18080",
|
204
207
|
user="logstash",
|
205
208
|
password="logstash",
|
206
209
|
)
|
207
210
|
# or
|
208
|
-
#
|
211
|
+
# remote_logger = TCPSender(
|
209
212
|
# service_name="qena-shared-lib",
|
210
213
|
# host="127.0.0.1",
|
211
214
|
# port=18090
|
212
215
|
# )
|
213
216
|
builder.with_singleton(
|
214
|
-
service=
|
215
|
-
instance=
|
217
|
+
service=BaseRemoteLogSender,
|
218
|
+
instance=remote_logger,
|
216
219
|
)
|
217
220
|
|
218
221
|
...
|
@@ -220,13 +223,13 @@ def main() -> FastAPI:
|
|
220
223
|
|
221
224
|
@router.get("")
|
222
225
|
def log_message(
|
223
|
-
|
224
|
-
|
225
|
-
DependsOn(
|
226
|
+
remote_logger: Annotated[
|
227
|
+
BaseRemoteLogSender,
|
228
|
+
DependsOn(BaseRemoteLogSender),
|
226
229
|
],
|
227
230
|
message: str,
|
228
231
|
):
|
229
|
-
|
232
|
+
remote_logger.info(message)
|
230
233
|
```
|
231
234
|
|
232
235
|
## Rabbitmq
|
@@ -263,7 +266,7 @@ def main() -> FastAPI:
|
|
263
266
|
...
|
264
267
|
|
265
268
|
rabbitmq = RabbitMqManager(
|
266
|
-
|
269
|
+
remote_logger=remote_logger,
|
267
270
|
container=builder.container,
|
268
271
|
)
|
269
272
|
|
@@ -402,7 +405,7 @@ def main() -> FastAPI:
|
|
402
405
|
...
|
403
406
|
|
404
407
|
rabbitmq = RabbitMqManager(
|
405
|
-
|
408
|
+
remote_logger=remote_logger,
|
406
409
|
container=builder.container,
|
407
410
|
# or globally for all consumers
|
408
411
|
listener_global_retry_policy=RetryPolicy(
|
@@ -473,7 +476,7 @@ def main() -> FastAPI:
|
|
473
476
|
...
|
474
477
|
|
475
478
|
schedule_manager = ScheduleManager(
|
476
|
-
|
479
|
+
remote_logger=remote_logger,
|
477
480
|
container=builder.container
|
478
481
|
)
|
479
482
|
|
@@ -507,8 +510,8 @@ def main() -> FastAPI:
|
|
507
510
|
...
|
508
511
|
|
509
512
|
builder.with_singleton(
|
510
|
-
service=
|
511
|
-
instance=
|
513
|
+
service=BaseRemoteLogSender,
|
514
|
+
instance=remote_logger,
|
512
515
|
)
|
513
516
|
builder.with_singleton(Background)
|
514
517
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
qena_shared_lib/__init__.py,sha256=oyuCR9Pca8aiRka0CXxV2JqO9FWANapkT2NU3VWBrIE,381
|
2
|
+
qena_shared_lib/application.py,sha256=4a1RfI9ZqM5iVHCykjQ_zeDfb7lwqqP5uThS1wYWOAU,7111
|
3
|
+
qena_shared_lib/background.py,sha256=A6ohscchVpBzT2igDnAV6WgbJoQtmjqJYLxZBl6HiNE,3323
|
4
|
+
qena_shared_lib/exception_handlers.py,sha256=wEnmWyLZZBnl1zJpkRNr_m_VNdGr85IBWZxhGdlHe-E,7715
|
5
|
+
qena_shared_lib/exceptions.py,sha256=D9Vs2q03VW_Eo7pD_8RYsZGNkVOOQ4Aq9HpUcnxeRlA,11031
|
6
|
+
qena_shared_lib/http.py,sha256=2u5T9aXmUrg5WoRb3uaKUqG_m_mWey_O-KXi_ANVfz4,25047
|
7
|
+
qena_shared_lib/logging.py,sha256=NyaKgbaBknti9aYxqrhGhIBuAbybCTmYXrRZtI-Mils,1625
|
8
|
+
qena_shared_lib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
+
qena_shared_lib/scheduler.py,sha256=_qQ7ugxZi_KBAzdKv6bwxJ_5z7dSsfNxmjk0Y7SO7wo,13111
|
10
|
+
qena_shared_lib/security.py,sha256=ZWs_XXkLAk6dvToC8pDyEUareb8mScvPbbHN3SPlZio,6128
|
11
|
+
qena_shared_lib/utils.py,sha256=BGlQjozpR72WuF7wdeim8LjG2j6gSOrmXbcxNPvydN8,850
|
12
|
+
qena_shared_lib/dependencies/__init__.py,sha256=W12RgJbhqZ9GiSV1nLlHmpwPzvQv8t7f4JEoazM_WYg,350
|
13
|
+
qena_shared_lib/dependencies/http.py,sha256=IBsMnRr8Jh8ixf2IcU6n1aYRMazI3fF9GLZxHM2dsXk,1492
|
14
|
+
qena_shared_lib/dependencies/miscellaneous.py,sha256=iGwAjatXb_JVSF13n1vdTRAgSKv19VtHo9ZbjjbkIco,753
|
15
|
+
qena_shared_lib/rabbitmq/__init__.py,sha256=1Rw7OP-A9UacuQWHzKbSOa9zFHa4FsEyFTVgAps01tw,1267
|
16
|
+
qena_shared_lib/rabbitmq/_base.py,sha256=JYdW-gchL82wGCaRR3mjSAXPUUYd8CAxioZqIBhMc6I,22670
|
17
|
+
qena_shared_lib/rabbitmq/_channel.py,sha256=yb3pCv6i7D5zXAvusOM3aSw-MWy-wfbEym4mOlKZV9E,5882
|
18
|
+
qena_shared_lib/rabbitmq/_exception_handlers.py,sha256=Gc8IXWLddl0qr7KHXWjyq_Rl52zMlb8iQiLO-2zwvlk,5757
|
19
|
+
qena_shared_lib/rabbitmq/_listener.py,sha256=i3Y8pqUuVl_I5Fxt8o-KFEPIbZSL9_oj8pFhUCwOcgo,48346
|
20
|
+
qena_shared_lib/rabbitmq/_pool.py,sha256=GZcJJygMfXEo5LLxaPB_qCDtgEElPCovHWTvY1VYfIM,1968
|
21
|
+
qena_shared_lib/rabbitmq/_publisher.py,sha256=vAWLrR4rS6aL2C4iHEk2jG69imoNuzbtzIW4zydqO2U,2468
|
22
|
+
qena_shared_lib/rabbitmq/_rpc_client.py,sha256=PvEnd-Lr1pDaEFC_eqhF9RIaTp_IjbCRa1uS2bGPTAE,9257
|
23
|
+
qena_shared_lib/remotelogging/__init__.py,sha256=DEmzWGadTT9-utyEAAmyVDkWFhsonY4wbWIy1J34C14,245
|
24
|
+
qena_shared_lib/remotelogging/_base.py,sha256=XYd_4iGkXJNT5HC_vLoj5wP4QQp6PCJreVnFv8rQHps,15394
|
25
|
+
qena_shared_lib/remotelogging/logstash/__init__.py,sha256=-sg2V8gYuAKtnHSXfLorpdu_LUB_Gpldw0pCuWIsSc0,186
|
26
|
+
qena_shared_lib/remotelogging/logstash/_base.py,sha256=ZNxE9SjZJW3sWKUUn3i52__X0mZuykaZLL3mp-52EOQ,961
|
27
|
+
qena_shared_lib/remotelogging/logstash/_http_sender.py,sha256=kTUdHE1OOSI72tDbIxmwv1-g8shHldfZ0-nBoSu8TyU,1810
|
28
|
+
qena_shared_lib/remotelogging/logstash/_tcp_sender.py,sha256=hIxDW2zEM07rr7BtgmJ5gR9Cs-MXiPD9qtQoVnrmNJ8,2467
|
29
|
+
qena_shared_lib-0.1.14.dist-info/METADATA,sha256=GWGe51QzF_Jixj796LMl2DUSqlV6ERObFO4YERFaEzY,11413
|
30
|
+
qena_shared_lib-0.1.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
31
|
+
qena_shared_lib-0.1.14.dist-info/RECORD,,
|
@@ -1,17 +0,0 @@
|
|
1
|
-
from ._base import (
|
2
|
-
BaseLogstashSender,
|
3
|
-
LogLevel,
|
4
|
-
LogstashLogRecord,
|
5
|
-
SenderResponse,
|
6
|
-
)
|
7
|
-
from ._http_sender import HTTPSender
|
8
|
-
from ._tcp_sender import TCPSender
|
9
|
-
|
10
|
-
__all__ = [
|
11
|
-
"BaseLogstashSender",
|
12
|
-
"HTTPSender",
|
13
|
-
"LogLevel",
|
14
|
-
"LogstashLogRecord",
|
15
|
-
"SenderResponse",
|
16
|
-
"TCPSender",
|
17
|
-
]
|
@@ -1,29 +0,0 @@
|
|
1
|
-
qena_shared_lib/__init__.py,sha256=WokKEFaMNow6h2ZY_fyB-tiYnic-Ed6K6kyzKgg3Rlw,371
|
2
|
-
qena_shared_lib/application.py,sha256=CY4RKRe1EcykBYZkLUUFhjLSY9Oriqbg6llqciCSsvU,5660
|
3
|
-
qena_shared_lib/background.py,sha256=QSwvJODQrkFpzDOOmGQVpuLXd3Ib-jcAd-Z8VIo2gvg,3268
|
4
|
-
qena_shared_lib/exception_handlers.py,sha256=NlJrhpovP5UaLa2Om2NradURMZf_UtGngeDGz6jm7C0,6382
|
5
|
-
qena_shared_lib/exceptions.py,sha256=GvRLuiLEJTwobWPWHwSNlIblLAG3hSX6FbHGfXzFjgg,11057
|
6
|
-
qena_shared_lib/http.py,sha256=59_XW-cMFGjOfp5j4UAcwjne_9a7vKk6JiknHB1juZc,24727
|
7
|
-
qena_shared_lib/logging.py,sha256=NyaKgbaBknti9aYxqrhGhIBuAbybCTmYXrRZtI-Mils,1625
|
8
|
-
qena_shared_lib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
qena_shared_lib/scheduler.py,sha256=-m5ngBN_hC9eotmOP_WjqK6DwwNgtLNart3jefXTSa4,12125
|
10
|
-
qena_shared_lib/security.py,sha256=x3aPGdey6_5nDxtWKXIyD9EySyhwoPgiitFHNG1KqWU,6106
|
11
|
-
qena_shared_lib/utils.py,sha256=rgaaxpUAHV_ZGKwxDkX8P0DISml4sgCcgTMSZ7RwneU,716
|
12
|
-
qena_shared_lib/dependencies/__init__.py,sha256=W12RgJbhqZ9GiSV1nLlHmpwPzvQv8t7f4JEoazM_WYg,350
|
13
|
-
qena_shared_lib/dependencies/http.py,sha256=IBsMnRr8Jh8ixf2IcU6n1aYRMazI3fF9GLZxHM2dsXk,1492
|
14
|
-
qena_shared_lib/dependencies/miscellaneous.py,sha256=iGwAjatXb_JVSF13n1vdTRAgSKv19VtHo9ZbjjbkIco,753
|
15
|
-
qena_shared_lib/logstash/__init__.py,sha256=KlWFXqwPGwKM3yWnz0lTmeZymkobxFPPNeOgyfdGu4g,315
|
16
|
-
qena_shared_lib/logstash/_base.py,sha256=bp6rPjEFvNzhjxVc6qwAZ7hi2DnTpcAw-TnIONEVQ2M,16073
|
17
|
-
qena_shared_lib/logstash/_http_sender.py,sha256=2LgVW17sicQ-oaFeKUwZhmQQQq8s1EQXd2ztpRu4UQc,1773
|
18
|
-
qena_shared_lib/logstash/_tcp_sender.py,sha256=CMPCycMq3Ts0vr2r5JvP3bmGMFJFl2un9HbpUWhyAyA,2397
|
19
|
-
qena_shared_lib/rabbitmq/__init__.py,sha256=lCP2qiXwdEBI81eeLQA5x54AizY0pTBk-1RYvP_Nqzs,1201
|
20
|
-
qena_shared_lib/rabbitmq/_base.py,sha256=Ab3CdbjT6WGngDzg-N6-8nraTbBslQXmtAECEC6aDY8,23424
|
21
|
-
qena_shared_lib/rabbitmq/_channel.py,sha256=amQH5vavNEYRBgqA7Hb76qA7fkj7Nfn-EX0Jfx3IH2Y,5812
|
22
|
-
qena_shared_lib/rabbitmq/_exception_handlers.py,sha256=2vAkJB-yJIWzDJWoZS-giAPtFtIamiyg_YUCnwowcxc,4553
|
23
|
-
qena_shared_lib/rabbitmq/_listener.py,sha256=f3OuJCoU5-_tZ8PDiO2dLqUdyVZLr99pD5zTNFlAjjw,46429
|
24
|
-
qena_shared_lib/rabbitmq/_pool.py,sha256=GZcJJygMfXEo5LLxaPB_qCDtgEElPCovHWTvY1VYfIM,1968
|
25
|
-
qena_shared_lib/rabbitmq/_publisher.py,sha256=vAWLrR4rS6aL2C4iHEk2jG69imoNuzbtzIW4zydqO2U,2468
|
26
|
-
qena_shared_lib/rabbitmq/_rpc_client.py,sha256=7eTs8svTuFFHqZrf2aHbHzWZoPHMicArEgtw0mSS_Ik,9231
|
27
|
-
qena_shared_lib-0.1.12.dist-info/METADATA,sha256=M4wZ3GtI_eqxIcabl_pahhhHH1phI0svnCDcJS2f4sA,11237
|
28
|
-
qena_shared_lib-0.1.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
29
|
-
qena_shared_lib-0.1.12.dist-info/RECORD,,
|
File without changes
|