libretificacaotjcore 0.1.36__tar.gz → 0.1.39__tar.gz

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.

Potentially problematic release.


This version of libretificacaotjcore might be problematic. Click here for more details.

Files changed (29) hide show
  1. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/PKG-INFO +1 -1
  2. libretificacaotjcore-0.1.39/libretificacaotjcore/services/rabbitmq_consumer.py +53 -0
  3. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore.egg-info/PKG-INFO +1 -1
  4. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/pyproject.toml +1 -1
  5. libretificacaotjcore-0.1.36/libretificacaotjcore/services/rabbitmq_consumer.py +0 -56
  6. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/README.md +0 -0
  7. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/__init__.py +0 -0
  8. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/database/__init__.py +0 -0
  9. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/database/arquivo_repository.py +0 -0
  10. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/database/certificado_repository.py +0 -0
  11. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/database/config_db.py +0 -0
  12. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/database/protocolo_repository.py +0 -0
  13. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/dtos/__init__.py +0 -0
  14. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/dtos/arquivo_dto.py +0 -0
  15. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/dtos/solicitacao_dto.py +0 -0
  16. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/enums/__init__.py +0 -0
  17. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/enums/e_eventos.py +0 -0
  18. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/enums/e_fase_retificacao.py +0 -0
  19. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/services/__init__.py +0 -0
  20. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/services/crypto_pass_service.py +0 -0
  21. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/services/file_service.py +0 -0
  22. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/services/rabbitmq_publisher.py +0 -0
  23. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/services/request_servico_api.py +0 -0
  24. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore/services/s3_service.py +0 -0
  25. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore.egg-info/SOURCES.txt +0 -0
  26. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore.egg-info/dependency_links.txt +0 -0
  27. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore.egg-info/requires.txt +0 -0
  28. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/libretificacaotjcore.egg-info/top_level.txt +0 -0
  29. {libretificacaotjcore-0.1.36 → libretificacaotjcore-0.1.39}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libretificacaotjcore
3
- Version: 0.1.36
3
+ Version: 0.1.39
4
4
  Summary: Biblioteca para centralizar conexao com filas no rabbit e banco de dados no mongodb para os servicos de retificacao da TJ
5
5
  Author-email: Jhonatan Azevedo <dev.azevedo@outlook.com>
6
6
  Project-URL: Homepage, https://github.com/seu-usuario/libretificacaotjcore
@@ -0,0 +1,53 @@
1
+ import aio_pika
2
+ import json
3
+
4
+ class RabbitMQConsumer:
5
+ def __init__(
6
+ self,
7
+ *,
8
+ host: str,
9
+ queue: str,
10
+ username: str,
11
+ password: str,
12
+ vhost: str = "/",
13
+ ):
14
+ self.host = host
15
+ self.queue = queue
16
+ self.username = username
17
+ self.password = password
18
+ self.vhost = vhost
19
+ self.connection = None
20
+ self.channel = None
21
+
22
+ async def connect(self):
23
+ self.connection = await aio_pika.connect_robust(
24
+ host=self.host,
25
+ login=self.username,
26
+ password=self.password,
27
+ virtualhost=self.vhost,
28
+ heartbeat=600,
29
+ )
30
+ self.channel = await self.connection.channel()
31
+ await self.channel.set_qos(prefetch_count=1)
32
+ await self.channel.declare_queue(self.queue, durable=True)
33
+
34
+ async def start_consuming(self, *, callback):
35
+ if not self.channel:
36
+ raise RuntimeError("❌ Canal RabbitMQ não conectado. Chame connect() antes.")
37
+
38
+ queue = await self.channel.get_queue(self.queue)
39
+
40
+ async with queue.iterator() as queue_iter:
41
+ async for message in queue_iter:
42
+ async with message.process():
43
+ try:
44
+ mensagem = json.loads(message.body.decode())
45
+ await callback(mensagem)
46
+ except Exception as e:
47
+ print(f"Erro ao processar mensagem: {e}")\
48
+
49
+ await self.close()
50
+
51
+ async def close(self):
52
+ if self.connection:
53
+ await self.connection.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libretificacaotjcore
3
- Version: 0.1.36
3
+ Version: 0.1.39
4
4
  Summary: Biblioteca para centralizar conexao com filas no rabbit e banco de dados no mongodb para os servicos de retificacao da TJ
5
5
  Author-email: Jhonatan Azevedo <dev.azevedo@outlook.com>
6
6
  Project-URL: Homepage, https://github.com/seu-usuario/libretificacaotjcore
@@ -18,7 +18,7 @@ keywords = [
18
18
  name = "libretificacaotjcore"
19
19
  readme = "README.md"
20
20
  requires-python = ">=3.12"
21
- version = "0.1.36"
21
+ version = "0.1.39"
22
22
 
23
23
  classifiers = [
24
24
  "Development Status :: 3 - Alpha",
@@ -1,56 +0,0 @@
1
- import pika
2
- import json
3
-
4
-
5
- class RabbitMQConsumer:
6
- def __init__(
7
- self,
8
- host: str,
9
- queue: str,
10
- username: str,
11
- password: str,
12
- vhost: str ="/",
13
- ):
14
- self.host = host
15
- self.queue = queue
16
- self.username = username
17
- self.password = password
18
- self.vhost = vhost
19
- self.connection = None
20
- self.channel = None
21
- self.connect()
22
-
23
- def connect(self):
24
- credentials = pika.PlainCredentials(self.username, self.password)
25
- parameters = pika.ConnectionParameters(
26
- host=self.host,
27
- credentials=credentials,
28
- virtual_host=self.vhost,
29
- heartbeat=60,
30
- blocked_connection_timeout=300,
31
- )
32
-
33
- self.connection = pika.BlockingConnection(parameters)
34
- self.channel = self.connection.channel()
35
- self.channel.queue_declare(queue=self.queue, durable=True)
36
-
37
- def start_consuming(self, callback):
38
- def on_message(ch, method, properties, body):
39
- mensagem = json.loads(body)
40
- callback(mensagem)
41
- ch.basic_ack(delivery_tag=method.delivery_tag)
42
- self.close()
43
-
44
- if not self.channel:
45
- raise RuntimeError("❌ Canal RabbitMQ não conectado. Chame connect() antes.")
46
-
47
- self.channel.basic_qos(prefetch_count=1)
48
- self.channel.basic_consume(queue=self.queue, on_message_callback=on_message)
49
- print(
50
- f'[*] Aguardando mensagens na fila "{self.queue}". Para sair pressione CTRL+C'
51
- )
52
- self.channel.start_consuming()
53
-
54
- def close(self):
55
- if self.connection:
56
- self.connection.close()