fleet-framework 0.1.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.
- fleet/__init__.py +1 -0
- fleet/cli.py +290 -0
- fleet/core/__init__.py +69 -0
- fleet/core/automation.py +125 -0
- fleet/core/backend.py +736 -0
- fleet/core/config.py +38 -0
- fleet/core/context.py +102 -0
- fleet/core/contract.py +87 -0
- fleet/core/country_presets.py +50 -0
- fleet/core/events.py +55 -0
- fleet/core/logging.py +97 -0
- fleet/core/memory_backend.py +492 -0
- fleet/core/metrics.py +61 -0
- fleet/core/otel.py +97 -0
- fleet/core/primitives.py +310 -0
- fleet/core/protocol.py +171 -0
- fleet/core/proxy.py +166 -0
- fleet/core/reconcile.py +75 -0
- fleet/core/sqlite_backend.py +1117 -0
- fleet/core/store.py +104 -0
- fleet/master/__init__.py +3 -0
- fleet/master/api.py +324 -0
- fleet/master/app.py +105 -0
- fleet/master/auth.py +132 -0
- fleet/master/broadcaster.py +37 -0
- fleet/master/dashboard/__init__.py +4 -0
- fleet/master/dashboard/router.py +36 -0
- fleet/master/dashboard/static/style.css +97 -0
- fleet/master/dashboard/templates/index.html +372 -0
- fleet/master/metrics_route.py +141 -0
- fleet/master/ratelimit.py +55 -0
- fleet/master/ws_router.py +142 -0
- fleet/worker/__init__.py +3 -0
- fleet/worker/agent.py +173 -0
- fleet/worker/reconcile_loop.py +246 -0
- fleet/worker/slot_runner.py +256 -0
- fleet/worker/ws_client.py +164 -0
- fleet_browser/__init__.py +21 -0
- fleet_browser/browser.py +277 -0
- fleet_browser/cert.py +68 -0
- fleet_browser/fingerprint.py +327 -0
- fleet_browser/humanizer.py +157 -0
- fleet_browser/pool.py +241 -0
- fleet_browser/proxy_extension.py +122 -0
- fleet_browser/solver.py +51 -0
- fleet_browser/stealth.py +80 -0
- fleet_cloudflare/__init__.py +22 -0
- fleet_cloudflare/bypasser.py +168 -0
- fleet_cloudflare/harvest.py +266 -0
- fleet_cloudflare/replay.py +82 -0
- fleet_cloudflare/solver.py +28 -0
- fleet_content/__init__.py +24 -0
- fleet_content/automation.py +43 -0
- fleet_content/contracts.py +76 -0
- fleet_detect/__init__.py +26 -0
- fleet_detect/contracts.py +67 -0
- fleet_detect/detect.py +126 -0
- fleet_framework-0.1.0.dist-info/METADATA +160 -0
- fleet_framework-0.1.0.dist-info/RECORD +85 -0
- fleet_framework-0.1.0.dist-info/WHEEL +5 -0
- fleet_framework-0.1.0.dist-info/entry_points.txt +9 -0
- fleet_framework-0.1.0.dist-info/licenses/LICENSE +21 -0
- fleet_framework-0.1.0.dist-info/top_level.txt +14 -0
- fleet_headers/__init__.py +28 -0
- fleet_headers/profiles.py +131 -0
- fleet_jobs/__init__.py +28 -0
- fleet_jobs/automation.py +34 -0
- fleet_jobs/contracts.py +143 -0
- fleet_marketplace/__init__.py +33 -0
- fleet_marketplace/automation.py +32 -0
- fleet_marketplace/contracts.py +151 -0
- fleet_news/__init__.py +21 -0
- fleet_news/automation.py +51 -0
- fleet_news/contracts.py +59 -0
- fleet_place/__init__.py +33 -0
- fleet_place/automation.py +37 -0
- fleet_place/contracts.py +156 -0
- fleet_provider_dataimpulse/__init__.py +82 -0
- fleet_provider_evomi/__init__.py +76 -0
- fleet_serp/__init__.py +30 -0
- fleet_serp/automation.py +47 -0
- fleet_serp/contracts.py +100 -0
- fleet_social/__init__.py +34 -0
- fleet_social/automation.py +44 -0
- fleet_social/contracts.py +172 -0
fleet/core/reconcile.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Any, Literal
|
|
5
|
+
|
|
6
|
+
from fleet.core.config import BaseConfig
|
|
7
|
+
|
|
8
|
+
# pure-functional diff between observed and desired config. no I/O.
|
|
9
|
+
# applied by fleet.worker.reconcile_loop.
|
|
10
|
+
|
|
11
|
+
ActionKind = Literal[
|
|
12
|
+
"stop_all",
|
|
13
|
+
"cold_start",
|
|
14
|
+
"restart",
|
|
15
|
+
"scale_up",
|
|
16
|
+
"scale_down",
|
|
17
|
+
"restart_pages",
|
|
18
|
+
"noop",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class Action:
|
|
24
|
+
kind: ActionKind
|
|
25
|
+
detail: dict[str, Any] = field(default_factory=dict, hash=False, compare=True)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_BASE_REBOOT = frozenset() # populated per-config-class via BaseConfig.reboot_fields()
|
|
29
|
+
_BASE_RESTART = frozenset({"proxy_url"})
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _diff_fields(observed: BaseConfig, desired: BaseConfig, names: frozenset[str]) -> list[str]:
|
|
33
|
+
return [f for f in names if getattr(observed, f) != getattr(desired, f)]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def diff(observed: BaseConfig, desired: BaseConfig) -> list[Action]:
|
|
37
|
+
# rule 1: disabled wins.
|
|
38
|
+
if not desired.enabled:
|
|
39
|
+
return [Action(kind="stop_all", detail={})]
|
|
40
|
+
|
|
41
|
+
# rule 2: cold start.
|
|
42
|
+
if not observed.enabled:
|
|
43
|
+
return [Action(kind="cold_start", detail={"desired": desired})]
|
|
44
|
+
|
|
45
|
+
cls = type(desired)
|
|
46
|
+
reboot_fields = _BASE_REBOOT | cls.reboot_fields()
|
|
47
|
+
restart_fields = _BASE_RESTART | cls.restart_fields()
|
|
48
|
+
|
|
49
|
+
# rule 3: reboot-class change → full cold restart of the worker (token server etc).
|
|
50
|
+
reboot_changes = _diff_fields(observed, desired, reboot_fields)
|
|
51
|
+
if reboot_changes:
|
|
52
|
+
return [Action(kind="restart", detail={"desired": desired, "changed": reboot_changes})]
|
|
53
|
+
|
|
54
|
+
# rule 4 / 5: scale by slot delta.
|
|
55
|
+
delta = desired.slots - observed.slots
|
|
56
|
+
if delta > 0:
|
|
57
|
+
return [Action(kind="scale_up", detail={"delta": delta})]
|
|
58
|
+
if delta < 0:
|
|
59
|
+
return [Action(kind="scale_down", detail={"delta": -delta})]
|
|
60
|
+
|
|
61
|
+
# rule 6: restart-class (page-level) change → recycle each slot.
|
|
62
|
+
restart_changes = _diff_fields(observed, desired, restart_fields)
|
|
63
|
+
if restart_changes:
|
|
64
|
+
return [
|
|
65
|
+
Action(kind="restart_pages", detail={"desired": desired, "changed": restart_changes})
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
return [Action(kind="noop", detail={})]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def is_noop(plan: list[Action]) -> bool:
|
|
72
|
+
return len(plan) == 1 and plan[0].kind == "noop"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
__all__ = ["Action", "ActionKind", "diff", "is_noop"]
|