port-ocean 0.12.2.dev20__py3-none-any.whl → 0.12.2.dev22__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.
Potentially problematic release.
This version of port-ocean might be problematic. Click here for more details.
- port_ocean/context/ocean.py +5 -0
- port_ocean/ocean.py +32 -26
- {port_ocean-0.12.2.dev20.dist-info → port_ocean-0.12.2.dev22.dist-info}/METADATA +1 -1
- {port_ocean-0.12.2.dev20.dist-info → port_ocean-0.12.2.dev22.dist-info}/RECORD +7 -7
- {port_ocean-0.12.2.dev20.dist-info → port_ocean-0.12.2.dev22.dist-info}/LICENSE.md +0 -0
- {port_ocean-0.12.2.dev20.dist-info → port_ocean-0.12.2.dev22.dist-info}/WHEEL +0 -0
- {port_ocean-0.12.2.dev20.dist-info → port_ocean-0.12.2.dev22.dist-info}/entry_points.txt +0 -0
port_ocean/context/ocean.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from typing import Callable, TYPE_CHECKING, Any, Literal, Union
|
|
2
2
|
|
|
3
3
|
from pydantic.main import BaseModel
|
|
4
|
+
from starlette.routing import Router
|
|
4
5
|
from werkzeug.local import LocalProxy
|
|
5
6
|
|
|
6
7
|
from port_ocean.clients.port.types import UserAgentType
|
|
@@ -43,6 +44,10 @@ class PortOceanContext:
|
|
|
43
44
|
def config(self) -> "IntegrationConfiguration":
|
|
44
45
|
return self.app.config
|
|
45
46
|
|
|
47
|
+
@property
|
|
48
|
+
def router(self) -> Router:
|
|
49
|
+
return self.app.integration_router
|
|
50
|
+
|
|
46
51
|
@property
|
|
47
52
|
def integration(self) -> "BaseIntegration":
|
|
48
53
|
return self.app.integration
|
port_ocean/ocean.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import contextlib
|
|
2
3
|
import sys
|
|
3
4
|
import threading
|
|
4
|
-
from typing import Callable, Any, Dict, Type
|
|
5
|
+
from typing import Callable, Any, Dict, AsyncIterator, Type
|
|
5
6
|
|
|
7
|
+
from fastapi import FastAPI, APIRouter
|
|
6
8
|
from loguru import logger
|
|
7
9
|
from pydantic import BaseModel
|
|
10
|
+
from starlette.applications import Starlette
|
|
8
11
|
from starlette.middleware import Middleware
|
|
9
12
|
from starlette.responses import JSONResponse
|
|
10
|
-
from starlette.routing import Route
|
|
13
|
+
from starlette.routing import Route, Mount, Router
|
|
11
14
|
from starlette.types import Scope, Receive, Send
|
|
12
15
|
|
|
13
16
|
from port_ocean.clients.port.client import PortClient
|
|
@@ -27,9 +30,6 @@ from port_ocean.middlewares import RequestHandlerMiddleware
|
|
|
27
30
|
from port_ocean.utils.repeat import repeat_every
|
|
28
31
|
from port_ocean.utils.signal import signal_handler
|
|
29
32
|
from port_ocean.version import __integration_version__
|
|
30
|
-
import contextlib
|
|
31
|
-
|
|
32
|
-
from starlette.applications import Starlette
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class Ocean:
|
|
@@ -37,32 +37,14 @@ class Ocean:
|
|
|
37
37
|
self,
|
|
38
38
|
app: Starlette | None = None,
|
|
39
39
|
integration_class: Callable[[PortOceanContext], BaseIntegration] | None = None,
|
|
40
|
-
integration_router: None = None,
|
|
40
|
+
integration_router: Router | None = None,
|
|
41
41
|
config_factory: Type[BaseModel] | None = None,
|
|
42
42
|
config_override: Dict[str, Any] | None = None,
|
|
43
43
|
):
|
|
44
44
|
initialize_port_ocean_context(self)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
try:
|
|
49
|
-
await self.integration.start()
|
|
50
|
-
await self._setup_scheduled_resync()
|
|
51
|
-
yield None
|
|
52
|
-
except Exception:
|
|
53
|
-
logger.exception("Integration had a fatal error. Shutting down.")
|
|
54
|
-
sys.exit("Server stopped")
|
|
55
|
-
finally:
|
|
56
|
-
signal_handler.exit()
|
|
57
|
-
|
|
58
|
-
async def handle_webhook_request(data: dict[str, Any]) -> dict[str, Any]:
|
|
59
|
-
return JSONResponse({"ok": True})
|
|
60
|
-
|
|
61
|
-
self.starlette_app = Starlette(
|
|
62
|
-
routes=[Route("/integration/webhook", endpoint=handle_webhook_request)],
|
|
63
|
-
middleware=[Middleware(RequestHandlerMiddleware)],
|
|
64
|
-
lifespan=lifespan,
|
|
65
|
-
)
|
|
46
|
+
self.starlette_app = app or Starlette()
|
|
47
|
+
self.integration_router = integration_router or Router()
|
|
66
48
|
|
|
67
49
|
self.config = IntegrationConfiguration(
|
|
68
50
|
# type: ignore
|
|
@@ -134,4 +116,28 @@ class Ocean:
|
|
|
134
116
|
await repeated_function()
|
|
135
117
|
|
|
136
118
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
119
|
+
@contextlib.asynccontextmanager
|
|
120
|
+
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
|
|
121
|
+
try:
|
|
122
|
+
await self.integration.start()
|
|
123
|
+
await self._setup_scheduled_resync()
|
|
124
|
+
yield None
|
|
125
|
+
except Exception:
|
|
126
|
+
logger.exception("Integration had a fatal error. Shutting down.")
|
|
127
|
+
sys.exit("Server stopped")
|
|
128
|
+
finally:
|
|
129
|
+
signal_handler.exit()
|
|
130
|
+
|
|
131
|
+
async def health() -> JSONResponse:
|
|
132
|
+
return JSONResponse({"ok": True})
|
|
133
|
+
|
|
134
|
+
self.starlette_app = Starlette(
|
|
135
|
+
routes=[
|
|
136
|
+
Route("/docs", endpoint=health),
|
|
137
|
+
Mount("/integration", routes=self.integration_router.routes),
|
|
138
|
+
],
|
|
139
|
+
middleware=[Middleware(RequestHandlerMiddleware)],
|
|
140
|
+
lifespan=lifespan,
|
|
141
|
+
)
|
|
142
|
+
|
|
137
143
|
await self.starlette_app(scope, receive, send)
|
|
@@ -57,7 +57,7 @@ port_ocean/consumers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
|
57
57
|
port_ocean/consumers/kafka_consumer.py,sha256=N8KocjBi9aR0BOPG8hgKovg-ns_ggpEjrSxqSqF_BSo,4710
|
|
58
58
|
port_ocean/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
59
59
|
port_ocean/context/event.py,sha256=WduGbCPgm2J2a63EY4J3XWwFGSt3ja1acBVpyI_ciMo,5430
|
|
60
|
-
port_ocean/context/ocean.py,sha256=
|
|
60
|
+
port_ocean/context/ocean.py,sha256=UDlsk6CUCRLb0Oc01piU3CdtG9LpBcw-yswk8DtiDAw,4661
|
|
61
61
|
port_ocean/context/resource.py,sha256=yDj63URzQelj8zJPh4BAzTtPhpKr9Gw9DRn7I_0mJ1s,1692
|
|
62
62
|
port_ocean/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
63
63
|
port_ocean/core/defaults/__init__.py,sha256=8qCZg8n06WAdMu9s_FiRtDYLGPGHbOuS60vapeUoAks,142
|
|
@@ -115,7 +115,7 @@ port_ocean/log/handlers.py,sha256=k9G_Mb4ga2-Jke9irpdlYqj6EYiwv0gEsh4TgyqqOmI,28
|
|
|
115
115
|
port_ocean/log/logger_setup.py,sha256=qSeVwnivV4WoLx_4SfBwn2PtmUpNdkSEgfm0C8B3yUw,2332
|
|
116
116
|
port_ocean/log/sensetive.py,sha256=lVKiZH6b7TkrZAMmhEJRhcl67HNM94e56x12DwFgCQk,2920
|
|
117
117
|
port_ocean/middlewares.py,sha256=K_FGt39YgiC0397W3ON1Z0n0bRIke95sZkw7a0xOiII,2737
|
|
118
|
-
port_ocean/ocean.py,sha256=
|
|
118
|
+
port_ocean/ocean.py,sha256=Vcc2x2d8-JiipX0xLeMX8p30SUzXfrRMlylwjFZY0pM,5394
|
|
119
119
|
port_ocean/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
120
120
|
port_ocean/run.py,sha256=rTxBlrQd4yyrtgErCFJCHCEHs7d1OXrRiJehUYmIbN0,2212
|
|
121
121
|
port_ocean/sonar-project.properties,sha256=X_wLzDOkEVmpGLRMb2fg9Rb0DxWwUFSvESId8qpvrPI,73
|
|
@@ -140,8 +140,8 @@ port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,32
|
|
|
140
140
|
port_ocean/utils/signal.py,sha256=K-6kKFQTltcmKDhtyZAcn0IMa3sUpOHGOAUdWKgx0_E,1369
|
|
141
141
|
port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
|
|
142
142
|
port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
|
|
143
|
-
port_ocean-0.12.2.
|
|
144
|
-
port_ocean-0.12.2.
|
|
145
|
-
port_ocean-0.12.2.
|
|
146
|
-
port_ocean-0.12.2.
|
|
147
|
-
port_ocean-0.12.2.
|
|
143
|
+
port_ocean-0.12.2.dev22.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
144
|
+
port_ocean-0.12.2.dev22.dist-info/METADATA,sha256=l5UuI6nWegX85qi5OXaFjyA7kllf6sI-uhzr8fPpCr4,6671
|
|
145
|
+
port_ocean-0.12.2.dev22.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
146
|
+
port_ocean-0.12.2.dev22.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
|
|
147
|
+
port_ocean-0.12.2.dev22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|