mrok 0.2.3__py3-none-any.whl → 0.4.0__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.
- mrok/agent/devtools/__init__.py +0 -0
- mrok/agent/devtools/__main__.py +34 -0
- mrok/agent/devtools/inspector/__init__.py +0 -0
- mrok/agent/devtools/inspector/__main__.py +25 -0
- mrok/agent/devtools/inspector/app.py +556 -0
- mrok/agent/devtools/inspector/server.py +18 -0
- mrok/agent/sidecar/app.py +9 -10
- mrok/agent/sidecar/main.py +35 -16
- mrok/agent/ziticorn.py +27 -18
- mrok/cli/commands/__init__.py +2 -1
- mrok/cli/commands/admin/list/instances.py +24 -4
- mrok/cli/commands/admin/register/extensions.py +2 -2
- mrok/cli/commands/admin/register/instances.py +3 -3
- mrok/cli/commands/admin/unregister/extensions.py +2 -2
- mrok/cli/commands/admin/unregister/instances.py +2 -2
- mrok/cli/commands/agent/__init__.py +2 -0
- mrok/cli/commands/agent/dev/__init__.py +7 -0
- mrok/cli/commands/agent/dev/console.py +25 -0
- mrok/cli/commands/agent/dev/web.py +37 -0
- mrok/cli/commands/agent/run/asgi.py +35 -16
- mrok/cli/commands/agent/run/sidecar.py +29 -13
- mrok/cli/commands/agent/utils.py +5 -0
- mrok/cli/commands/controller/run.py +1 -5
- mrok/cli/commands/proxy/__init__.py +6 -0
- mrok/cli/commands/proxy/run.py +49 -0
- mrok/cli/utils.py +5 -0
- mrok/conf.py +6 -0
- mrok/controller/auth.py +2 -2
- mrok/controller/routes/extensions.py +9 -7
- mrok/datastructures.py +159 -0
- mrok/http/config.py +3 -6
- mrok/http/constants.py +22 -0
- mrok/http/forwarder.py +62 -23
- mrok/http/lifespan.py +29 -0
- mrok/http/middlewares.py +143 -0
- mrok/http/types.py +43 -0
- mrok/http/utils.py +90 -0
- mrok/logging.py +22 -0
- mrok/master.py +269 -0
- mrok/metrics.py +139 -0
- mrok/proxy/__init__.py +3 -0
- mrok/proxy/app.py +73 -0
- mrok/proxy/dataclasses.py +12 -0
- mrok/proxy/main.py +58 -0
- mrok/proxy/streams.py +124 -0
- mrok/proxy/types.py +12 -0
- mrok/proxy/ziti.py +173 -0
- mrok/ziti/identities.py +50 -20
- mrok/ziti/services.py +8 -8
- {mrok-0.2.3.dist-info → mrok-0.4.0.dist-info}/METADATA +7 -1
- mrok-0.4.0.dist-info/RECORD +92 -0
- {mrok-0.2.3.dist-info → mrok-0.4.0.dist-info}/WHEEL +1 -1
- mrok/http/master.py +0 -132
- mrok-0.2.3.dist-info/RECORD +0 -66
- {mrok-0.2.3.dist-info → mrok-0.4.0.dist-info}/entry_points.txt +0 -0
- {mrok-0.2.3.dist-info → mrok-0.4.0.dist-info}/licenses/LICENSE.txt +0 -0
mrok/http/master.py
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
import signal
|
|
4
|
-
import threading
|
|
5
|
-
import time
|
|
6
|
-
from collections.abc import Callable
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
|
|
9
|
-
from watchfiles import watch
|
|
10
|
-
from watchfiles.filters import PythonFilter
|
|
11
|
-
from watchfiles.run import CombinedProcess, start_process
|
|
12
|
-
|
|
13
|
-
logger = logging.getLogger("mrok.agent")
|
|
14
|
-
|
|
15
|
-
MONITOR_THREAD_JOIN_TIMEOUT = 5
|
|
16
|
-
MONITOR_THREAD_CHECK_DELAY = 1
|
|
17
|
-
MONITOR_THREAD_ERROR_DELAY = 3
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def print_path(path):
|
|
21
|
-
try:
|
|
22
|
-
return f'"{path.relative_to(Path.cwd())}"'
|
|
23
|
-
except ValueError:
|
|
24
|
-
return f'"{path}"'
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class Master:
|
|
28
|
-
def __init__(
|
|
29
|
-
self,
|
|
30
|
-
start_fn: Callable,
|
|
31
|
-
workers: int,
|
|
32
|
-
reload: bool,
|
|
33
|
-
):
|
|
34
|
-
self.start_fn = start_fn
|
|
35
|
-
self.workers = workers
|
|
36
|
-
self.reload = reload
|
|
37
|
-
self.worker_processes: dict[int, CombinedProcess] = {}
|
|
38
|
-
self.stop_event = threading.Event()
|
|
39
|
-
self.watch_filter = PythonFilter(ignore_paths=None)
|
|
40
|
-
self.watcher = watch(
|
|
41
|
-
Path.cwd(),
|
|
42
|
-
watch_filter=self.watch_filter,
|
|
43
|
-
stop_event=self.stop_event,
|
|
44
|
-
yield_on_timeout=True,
|
|
45
|
-
)
|
|
46
|
-
self.setup_signals_handler()
|
|
47
|
-
self.monitor_thread = None
|
|
48
|
-
|
|
49
|
-
def setup_signals_handler(self):
|
|
50
|
-
for sig in (signal.SIGINT, signal.SIGTERM):
|
|
51
|
-
signal.signal(sig, self.handle_signal)
|
|
52
|
-
|
|
53
|
-
def handle_signal(self, *args, **kwargs):
|
|
54
|
-
self.stop_event.set()
|
|
55
|
-
|
|
56
|
-
def start_worker(self, worker_id: int):
|
|
57
|
-
"""Start a single worker process"""
|
|
58
|
-
p = start_process(
|
|
59
|
-
self.start_fn,
|
|
60
|
-
"function",
|
|
61
|
-
(),
|
|
62
|
-
None,
|
|
63
|
-
)
|
|
64
|
-
logger.info(f"Worker {worker_id} [{p.pid}] started")
|
|
65
|
-
return p
|
|
66
|
-
|
|
67
|
-
def start(self):
|
|
68
|
-
for i in range(self.workers):
|
|
69
|
-
p = self.start_worker(i)
|
|
70
|
-
self.worker_processes[i] = p
|
|
71
|
-
|
|
72
|
-
def stop(self):
|
|
73
|
-
for process in self.worker_processes.values():
|
|
74
|
-
process.stop(sigint_timeout=5, sigkill_timeout=1)
|
|
75
|
-
self.worker_processes.clear()
|
|
76
|
-
|
|
77
|
-
def restart(self):
|
|
78
|
-
self.stop()
|
|
79
|
-
self.start()
|
|
80
|
-
|
|
81
|
-
def monitor_workers(self):
|
|
82
|
-
while not self.stop_event.is_set():
|
|
83
|
-
try:
|
|
84
|
-
for worker_id, process in self.worker_processes.items():
|
|
85
|
-
if not process.is_alive():
|
|
86
|
-
logger.warning(f"Worker {worker_id} [{process.pid}] died unexpectedly")
|
|
87
|
-
process.stop(sigint_timeout=1, sigkill_timeout=1)
|
|
88
|
-
new_process = self.start_worker(worker_id)
|
|
89
|
-
self.worker_processes[worker_id] = new_process
|
|
90
|
-
logger.info(
|
|
91
|
-
f"Restarted worker {worker_id} [{process.pid}] -> [{new_process.pid}]"
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
time.sleep(MONITOR_THREAD_CHECK_DELAY)
|
|
95
|
-
|
|
96
|
-
except Exception as e:
|
|
97
|
-
logger.error(f"Error in worker monitoring: {e}")
|
|
98
|
-
time.sleep(MONITOR_THREAD_ERROR_DELAY)
|
|
99
|
-
|
|
100
|
-
def __iter__(self):
|
|
101
|
-
return self
|
|
102
|
-
|
|
103
|
-
def __next__(self):
|
|
104
|
-
changes = next(self.watcher)
|
|
105
|
-
if changes:
|
|
106
|
-
return list({Path(change[1]) for change in changes})
|
|
107
|
-
return None
|
|
108
|
-
|
|
109
|
-
def run(self):
|
|
110
|
-
self.start()
|
|
111
|
-
logger.info(f"Master process started: {os.getpid()}")
|
|
112
|
-
|
|
113
|
-
# Start worker monitoring thread
|
|
114
|
-
self.monitor_thread = threading.Thread(target=self.monitor_workers, daemon=True)
|
|
115
|
-
self.monitor_thread.start()
|
|
116
|
-
logger.debug("Worker monitoring thread started")
|
|
117
|
-
|
|
118
|
-
try:
|
|
119
|
-
if self.reload:
|
|
120
|
-
for files_changed in self:
|
|
121
|
-
if files_changed:
|
|
122
|
-
logger.warning(
|
|
123
|
-
f"{', '.join(map(print_path, files_changed))} changed, reloading...",
|
|
124
|
-
)
|
|
125
|
-
self.restart()
|
|
126
|
-
else:
|
|
127
|
-
self.stop_event.wait()
|
|
128
|
-
finally:
|
|
129
|
-
if self.monitor_thread and self.monitor_thread.is_alive(): # pragma: no cover
|
|
130
|
-
logger.debug("Wait for monitor worker to exit")
|
|
131
|
-
self.monitor_thread.join(timeout=MONITOR_THREAD_JOIN_TIMEOUT)
|
|
132
|
-
self.stop()
|
mrok-0.2.3.dist-info/RECORD
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
mrok/__init__.py,sha256=D1PUs3KtMCqG4bFLceVNG62L3RN53NS95uSCNXpgvzs,181
|
|
2
|
-
mrok/conf.py,sha256=iDMxJtorJWxK0mI-pGEi1TBd_064R-VLcWzHB4esUlE,661
|
|
3
|
-
mrok/errors.py,sha256=ruNMDFr2_0ezCGXuCG1OswCEv-bHOIzMMd02J_0ABcs,37
|
|
4
|
-
mrok/logging.py,sha256=4F5rviPK1-MWWMZuHfzNNQmGxg-emAPRdKz0PsWDSww,2261
|
|
5
|
-
mrok/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
mrok/agent/ziticorn.py,sha256=sWtX7cyaIks8_Re3RmLlcgFPGOZ7-xBqdv6TZ50I1ac,765
|
|
7
|
-
mrok/agent/sidecar/__init__.py,sha256=DrjJGhqFyxsVODW06KI20Wpr6HsD2lD6qFCKUXc7GIE,59
|
|
8
|
-
mrok/agent/sidecar/app.py,sha256=QEfPdeFwlerxDbjAqUNtMsnslVUu2h4nCoOVCBFVsy0,992
|
|
9
|
-
mrok/agent/sidecar/main.py,sha256=6HVJRqtxNOKrCQ0XQhQdfWCfjzHJMgBn_zPqtLsIxWw,798
|
|
10
|
-
mrok/cli/__init__.py,sha256=mtFEa8IeS1x6Gm4dUYoSnAxyEzNqbUVSmWxtuZUMR84,61
|
|
11
|
-
mrok/cli/main.py,sha256=DFcYPwDskXi8SKAgEsuP4GMFzaniIf_6bZaSDWvYKDk,2724
|
|
12
|
-
mrok/cli/rich.py,sha256=P3Dyu8EArUR9_0j7DPK7LRx85TWdYdZ1SaJzD_S1ZCE,511
|
|
13
|
-
mrok/cli/commands/__init__.py,sha256=M6Sypb2vAh6qxQQJNIO9xop2DrD6zt6TEp8rbbD7LS0,114
|
|
14
|
-
mrok/cli/commands/admin/__init__.py,sha256=WU49jpMF9p18UONjYywWEFzjF57zLpLKJ0qAZvrzcR4,414
|
|
15
|
-
mrok/cli/commands/admin/bootstrap.py,sha256=iOnHctYajgcHrG_Idjn5Y7VVSaWYRIhdgqKSw9TWq9I,1680
|
|
16
|
-
mrok/cli/commands/admin/utils.py,sha256=wQ-qQJGFyhikMJY_CWT-G6sTEIZb-LUdj1AUZisLPBw,1363
|
|
17
|
-
mrok/cli/commands/admin/list/__init__.py,sha256=kjCMcpn1gopcrQaaHxfFh8Kyngldepnle8R2br5dJ_0,195
|
|
18
|
-
mrok/cli/commands/admin/list/extensions.py,sha256=16fhDB5ucL8su2WQnSaQ1E6MhgC4vkP9-nuHAcPpzyE,4405
|
|
19
|
-
mrok/cli/commands/admin/list/instances.py,sha256=HpEXk7DfeAXeUwi8Z4qnOmQCB1_lPm2JVBl8k0tjvUk,5179
|
|
20
|
-
mrok/cli/commands/admin/register/__init__.py,sha256=5Jb_bc2L47MEpQIrOcquzduTFWQ01Jd1U1MpqaR-Ekw,209
|
|
21
|
-
mrok/cli/commands/admin/register/extensions.py,sha256=nX2PUX8hmsWjyp2dGgge2YmkfeGgGXhqk7fwUx99o9o,1489
|
|
22
|
-
mrok/cli/commands/admin/register/instances.py,sha256=_9xpa4rZYmf7SZ58hx103EuEbA3o2FZYbAVmpT8oRhM,1930
|
|
23
|
-
mrok/cli/commands/admin/unregister/__init__.py,sha256=-GjjCPX1pISbWmJK6GpKO3ijGsDQb21URjU1hNu99O4,215
|
|
24
|
-
mrok/cli/commands/admin/unregister/extensions.py,sha256=AVBjHu-Zc7bUZ_YSbvEk41fKByvRl2Hggip1E2c11Mk,1020
|
|
25
|
-
mrok/cli/commands/admin/unregister/instances.py,sha256=UvMEDOw7FhZYz2AZci79sSVKfDxOS7d5GY5iCUtUZRM,1128
|
|
26
|
-
mrok/cli/commands/agent/__init__.py,sha256=Jr9RDSDdRPjbVJ7NhzgjRD-jtr5hD2vvKzDe7XsLnVo,140
|
|
27
|
-
mrok/cli/commands/agent/run/__init__.py,sha256=E_IJCl3BfMffqFASe8gzJwhhQgt5bQfjhuyekVwdEBA,164
|
|
28
|
-
mrok/cli/commands/agent/run/asgi.py,sha256=aqwu_h9WyCDI2Ts8D4zTvawCETNmcke7cX3zIUyRww4,1265
|
|
29
|
-
mrok/cli/commands/agent/run/sidecar.py,sha256=VC6o1Xw6XXB25xh5F2PyPsDe5Sii0cWLVLDrpNIC5hU,1490
|
|
30
|
-
mrok/cli/commands/controller/__init__.py,sha256=2xw-YVN0akiLiuGUU3XbYyZZ0ugOjQ6XhtTkzEKSmMA,161
|
|
31
|
-
mrok/cli/commands/controller/openapi.py,sha256=QLjVao9UkB2vBaGkFi_q_jrlg4Np4ldMRwDIJsrJ7A8,1175
|
|
32
|
-
mrok/cli/commands/controller/run.py,sha256=osyjssb81xNMYZLPb6dfPR4W_BQlCxKDfvl-BIhG_1A,2460
|
|
33
|
-
mrok/controller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
|
-
mrok/controller/app.py,sha256=XxCIB7N1YE52vSYfvGW2UPgEEOZ9jxDMe2l9D2SfXi8,1866
|
|
35
|
-
mrok/controller/auth.py,sha256=Kg94W8yNMs6TvUmLRYv1QeUjDy4qlGZ-_6OHa4KH1zg,2648
|
|
36
|
-
mrok/controller/pagination.py,sha256=raYpYa34q8Ckl4BXBOEdpWlKkFj6z7e6QLWr2HT7dzI,2187
|
|
37
|
-
mrok/controller/schemas.py,sha256=AaF8_bEwZTHM02apVEBAzlUb2t71zoxYaG-VHtPNeMk,1705
|
|
38
|
-
mrok/controller/dependencies/__init__.py,sha256=voewk6gjkA0OarL6HFmfT_RLqBns0Fpl-VIqK5xVAEI,202
|
|
39
|
-
mrok/controller/dependencies/conf.py,sha256=2Pa8fxJHkZ29q6UL-w6hUP_wr7WnNELfw5LlzWg1Tec,162
|
|
40
|
-
mrok/controller/dependencies/ziti.py,sha256=fYoxeJb4s6p2_3gxbExbFSRabjpvp_gZMBb3ocXZV3Y,702
|
|
41
|
-
mrok/controller/openapi/__init__.py,sha256=U1dw45w76CcoQagyqg_FXdMuJF3qJZZM6wG8TeTe3Zo,101
|
|
42
|
-
mrok/controller/openapi/examples.py,sha256=ZI0BP7L6sI0z7Mq1I3uc2UrweGpzpPeGSIuf1bUKkgg,1419
|
|
43
|
-
mrok/controller/openapi/utils.py,sha256=Kn55ISAWlMJNwrJTum7iFrBvJvr81To76pCK8W-s79Q,1114
|
|
44
|
-
mrok/controller/routes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
-
mrok/controller/routes/extensions.py,sha256=jd3OGsJ_ESLQbOJ1mkzU8F44QgPe3R23dIapkNjmYDY,9126
|
|
46
|
-
mrok/controller/routes/instances.py,sha256=v-fn_F6JHbDZ4YUNCIZzClgHp6aC1Eu5HB7k7qBG5pk,2202
|
|
47
|
-
mrok/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
|
-
mrok/http/config.py,sha256=k8mjvD3ninJn-v1t-co-GSa3upm4b70bWyk3fwdcOh8,2161
|
|
49
|
-
mrok/http/forwarder.py,sha256=mo-Z8B8Zg6kdDX-lWEiptRv-9kJU9cEdmg6gt6eF0cc,11374
|
|
50
|
-
mrok/http/lifespan.py,sha256=9qevhD_5Y0f8fGTh2axdfWx7v1K4vnWtiUNyJLesOHE,262
|
|
51
|
-
mrok/http/master.py,sha256=TwU78yE_GQecogBs_PDpl3gY7_jWYNIRNaAXRzi0rvY,4152
|
|
52
|
-
mrok/http/protocol.py,sha256=ap8jbLUvgbAH81ZJZCBkQiYR7mkV_eL3rpfwEkoE8sU,392
|
|
53
|
-
mrok/http/server.py,sha256=Mj7C85fc-DXp-WTBWaOd7ag808oliLmFBH5bf-G2FHg,370
|
|
54
|
-
mrok/ziti/__init__.py,sha256=20OWMiexRhOovZOX19zlX87-V78QyWnEnSZfyAftUdE,263
|
|
55
|
-
mrok/ziti/api.py,sha256=KvGiT9d4oSgC3JbFWLDQyuHcLX2HuZJoJ8nHmWtCDkY,16154
|
|
56
|
-
mrok/ziti/bootstrap.py,sha256=QIDhlkIxPW2QRuumFq2D1WDbD003P5f3z24pAUsyeBI,2696
|
|
57
|
-
mrok/ziti/constants.py,sha256=Urq1X3bCBQZfw8NbnEa1pqmY4oq1wmzkwPfzam3kbTw,339
|
|
58
|
-
mrok/ziti/errors.py,sha256=yYCbVDwktnR0AYduqtynIjo73K3HOhIrwA_vQimvEd4,368
|
|
59
|
-
mrok/ziti/identities.py,sha256=oE_3j6Y4xCr6uKNdprW55bxGsyKnmJt-MrxrylB2Ey4,5388
|
|
60
|
-
mrok/ziti/pki.py,sha256=o2tySqHC8-7bvFuI2Tqxg9vX6H6ZSxWxfP_9x29e19M,1954
|
|
61
|
-
mrok/ziti/services.py,sha256=JnznLTHNZjgbFwnBtv7y2XIp4NiQxLVawwP9EfWdVuM,3208
|
|
62
|
-
mrok-0.2.3.dist-info/METADATA,sha256=HCW-FucwR1yddkxR12eUY63wEXxTiaeNlEIMKpORVUo,15546
|
|
63
|
-
mrok-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
64
|
-
mrok-0.2.3.dist-info/entry_points.txt,sha256=tloXwvU1uJicBJR2h-8HoVclPgwJWDwuREMHN8Zq-nU,38
|
|
65
|
-
mrok-0.2.3.dist-info/licenses/LICENSE.txt,sha256=6PaICaoA3yNsZKLv5G6OKqSfLSoX7MakYqTDgJoTCBs,11346
|
|
66
|
-
mrok-0.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|