haraka 0.2.53__py3-none-any.whl → 0.2.55__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.
- haraka/PyFast/Runtime.py +25 -23
- haraka/utils/manifests/PyFast.yml +2 -2
- {haraka-0.2.53.dist-info → haraka-0.2.55.dist-info}/METADATA +1 -1
- {haraka-0.2.53.dist-info → haraka-0.2.55.dist-info}/RECORD +6 -6
- {haraka-0.2.53.dist-info → haraka-0.2.55.dist-info}/WHEEL +0 -0
- {haraka-0.2.53.dist-info → haraka-0.2.55.dist-info}/top_level.txt +0 -0
haraka/PyFast/Runtime.py
CHANGED
@@ -1,47 +1,49 @@
|
|
1
|
+
from enum import Enum, auto
|
1
2
|
from fastapi import FastAPI
|
2
3
|
import socket
|
3
4
|
from haraka.utils import Logger
|
4
5
|
|
6
|
+
|
7
|
+
class LifecycleState(Enum):
|
8
|
+
UNINITIALIZED = auto()
|
9
|
+
STARTED = auto()
|
10
|
+
DESTROYED = auto()
|
11
|
+
|
12
|
+
|
5
13
|
class Lifecycle:
|
6
14
|
"""
|
7
15
|
A helper class to handle initialization and shutdown messaging for a FastAPI application.
|
16
|
+
Tracks internal state to guard against invalid transitions.
|
8
17
|
"""
|
9
18
|
def __init__(self, variant: str = "PyFast"):
|
10
|
-
"""
|
11
|
-
Initializes the PyFast instance with a logger.
|
12
|
-
|
13
|
-
Args:
|
14
|
-
variant (str): A string identifier for the application. Default is 'PyFast'.
|
15
|
-
"""
|
16
19
|
self.variant = variant
|
17
20
|
self.logger = Logger(self.variant).start_logger()
|
21
|
+
self.state = LifecycleState.UNINITIALIZED
|
18
22
|
|
19
|
-
def start(self, settings, app: FastAPI):
|
20
|
-
|
21
|
-
|
23
|
+
async def start(self, settings, app: FastAPI):
|
24
|
+
if self.state != LifecycleState.UNINITIALIZED:
|
25
|
+
self.logger.warn(f"🟡 Attempted to start, but state is already {self.state.name}")
|
26
|
+
return
|
22
27
|
|
23
|
-
Args:
|
24
|
-
settings: A settings object containing application configuration (e.g., port).
|
25
|
-
app (FastAPI): The FastAPI application instance.
|
26
|
-
"""
|
27
28
|
try:
|
28
29
|
port = settings.port
|
29
|
-
docs_path = app.docs_url or "/docs"
|
30
|
+
docs_path = app.docs_url or "/docs"
|
30
31
|
local_url = f"http://localhost:{port}{docs_path}"
|
31
32
|
|
32
|
-
# Resolve the network-accessible hostname
|
33
33
|
host = socket.gethostbyname(socket.gethostname())
|
34
34
|
network_url = f"http://{host}:{port}{docs_path}"
|
35
35
|
|
36
|
-
|
37
|
-
self.logger.info(f"Swagger UI available at: {
|
38
|
-
self.
|
36
|
+
self.logger.info(f"✅ Swagger UI available at: {local_url}")
|
37
|
+
self.logger.info(f"🌐 Network Swagger UI available at: {network_url}")
|
38
|
+
self.state = LifecycleState.STARTED
|
39
39
|
|
40
40
|
except Exception as e:
|
41
|
-
self.logger.warn(f"Failed to determine network URL: {e}")
|
41
|
+
self.logger.warn(f"⚠️ Failed to determine network URL: {e}")
|
42
|
+
|
43
|
+
async def destroy(self):
|
44
|
+
if self.state == LifecycleState.DESTROYED:
|
45
|
+
self.logger.warn("🟡 destroy() called, but app is already shut down.")
|
46
|
+
return
|
42
47
|
|
43
|
-
def destroy(self):
|
44
|
-
"""
|
45
|
-
Logs a shutdown message when the application is shutting down.
|
46
|
-
"""
|
47
48
|
self.logger.info("🛑 Application is shutting down!")
|
49
|
+
self.state = LifecycleState.DESTROYED
|
@@ -17,8 +17,8 @@ keep:
|
|
17
17
|
- README.md
|
18
18
|
|
19
19
|
# ── IDE / run configs ──────────────────────────────
|
20
|
-
- runConfigurations/
|
21
|
-
- runConfigurations/
|
20
|
+
- runConfigurations/FastAPI/
|
21
|
+
- runConfigurations/FastAPI/FastAPI.run.xml
|
22
22
|
|
23
23
|
# ── deployment & infra (shared) ────────────────────
|
24
24
|
- skaffold.yaml
|
@@ -1,5 +1,5 @@
|
|
1
1
|
haraka/__init__.py,sha256=b8t9TwJ3drfLFkYAsiXvKuyat7ppKnhRkAtMlb1kt_A,221
|
2
|
-
haraka/PyFast/Runtime.py,sha256=
|
2
|
+
haraka/PyFast/Runtime.py,sha256=eZXLdL2gw3pQd6gX2l8ydeWXsEN6-WdOprk49h2LwC0,1700
|
3
3
|
haraka/PyFast/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
haraka/art/__init__.py,sha256=-b1KHQiLkaI2sXaHS05XDaE27tZfXvVLitILjJfSiKs,112
|
5
5
|
haraka/art/create.py,sha256=D2VPJtuwI0Ed7CcreHRHhxSN1VzV7PQfC1q-NW8l0DY,631
|
@@ -29,9 +29,9 @@ haraka/utils/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
29
29
|
haraka/utils/logging/log_util.py,sha256=Atlhutx4tKTtme9nj0JjObZNiCkwpEixGjhsGvI9544,1143
|
30
30
|
haraka/utils/manifests/GoUltraFast.yml,sha256=LBSlT2QyOi_reUfZ7AAvs0U6Ju47K94eG_fjs7SNuN8,975
|
31
31
|
haraka/utils/manifests/JavaFein.yml,sha256=TSTo45Q-NMMqaDS4ogYwU0PpxW-sl0MCYj-RG-Hc_M0,989
|
32
|
-
haraka/utils/manifests/PyFast.yml,sha256=
|
32
|
+
haraka/utils/manifests/PyFast.yml,sha256=q2UXbBEGYfxP-BSqx-zmWnp_YoAN7Z4hjAHEVK6KdKo,926
|
33
33
|
haraka/utils/manifests/go-grpc-gateway-buf.yml,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
|
-
haraka-0.2.
|
35
|
-
haraka-0.2.
|
36
|
-
haraka-0.2.
|
37
|
-
haraka-0.2.
|
34
|
+
haraka-0.2.55.dist-info/METADATA,sha256=GIgAH_G45cxHgJaU17Mgzep8P-EqdOw-ipAXW2iRY6A,937
|
35
|
+
haraka-0.2.55.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
36
|
+
haraka-0.2.55.dist-info/top_level.txt,sha256=1khpwypLKWoklVd_CgFiwAfcctVSXRoRPc3BI9lyIXo,7
|
37
|
+
haraka-0.2.55.dist-info/RECORD,,
|
File without changes
|
File without changes
|