falcon-interface 0.1.0__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.
- falcon_interface-0.1.0/PKG-INFO +167 -0
- falcon_interface-0.1.0/README.md +158 -0
- falcon_interface-0.1.0/falcon_interface/__init__.py +43 -0
- falcon_interface-0.1.0/falcon_interface/contracts/__init__.py +29 -0
- falcon_interface-0.1.0/falcon_interface/contracts/command.py +93 -0
- falcon_interface-0.1.0/falcon_interface/contracts/metrics.py +56 -0
- falcon_interface-0.1.0/falcon_interface/contracts/task.py +78 -0
- falcon_interface-0.1.0/falcon_interface/contracts/worker.py +65 -0
- falcon_interface-0.1.0/falcon_interface/enums.py +37 -0
- falcon_interface-0.1.0/falcon_interface/grpc/__init__.py +1 -0
- falcon_interface-0.1.0/falcon_interface/grpc/generated/__init__.py +1 -0
- falcon_interface-0.1.0/falcon_interface/grpc/generated/worker_runtime_pb2.py +58 -0
- falcon_interface-0.1.0/falcon_interface/grpc/generated/worker_runtime_pb2_grpc.py +227 -0
- falcon_interface-0.1.0/falcon_interface/runtime_enums.py +50 -0
- falcon_interface-0.1.0/falcon_interface/task_contracts.py +51 -0
- falcon_interface-0.1.0/falcon_interface/version.py +2 -0
- falcon_interface-0.1.0/falcon_interface.egg-info/PKG-INFO +167 -0
- falcon_interface-0.1.0/falcon_interface.egg-info/SOURCES.txt +37 -0
- falcon_interface-0.1.0/falcon_interface.egg-info/dependency_links.txt +1 -0
- falcon_interface-0.1.0/falcon_interface.egg-info/requires.txt +2 -0
- falcon_interface-0.1.0/falcon_interface.egg-info/top_level.txt +1 -0
- falcon_interface-0.1.0/pyproject.toml +21 -0
- falcon_interface-0.1.0/setup.cfg +4 -0
- falcon_interface-0.1.0/tests/test_compat_task_contracts.py +26 -0
- falcon_interface-0.1.0/tests/test_contracts_smoke.py +66 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: falcon-interface
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Stable external contracts and protocol definitions for Falcon.
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: pydantic<3,>=2.12
|
|
8
|
+
Requires-Dist: grpcio>=1.78.0
|
|
9
|
+
|
|
10
|
+
# falcon-interface
|
|
11
|
+
|
|
12
|
+
`falcon-interface` is the stable external contract package for Falcon.
|
|
13
|
+
|
|
14
|
+
It is intended to hold only versioned, backward-compatible protocol definitions and
|
|
15
|
+
cross-boundary data contracts shared by:
|
|
16
|
+
|
|
17
|
+
- `falcon-master`
|
|
18
|
+
- `falcon-worker`
|
|
19
|
+
- future Falcon SDKs
|
|
20
|
+
- third-party workers and adapters
|
|
21
|
+
|
|
22
|
+
This package should not depend on internal ORM models, service-layer logic, or
|
|
23
|
+
platform-only implementation details.
|
|
24
|
+
|
|
25
|
+
## Stability policy
|
|
26
|
+
|
|
27
|
+
`falcon-interface` is divided into two categories:
|
|
28
|
+
|
|
29
|
+
- Stable core: fields and contracts that are expected to remain backward compatible
|
|
30
|
+
across master, worker, SDK, and third-party adapters.
|
|
31
|
+
- Experimental surface: fields kept for current implementation compatibility but not
|
|
32
|
+
yet considered frozen.
|
|
33
|
+
|
|
34
|
+
### Stable first candidates
|
|
35
|
+
|
|
36
|
+
- Worker core identity and capacity:
|
|
37
|
+
- `worker_id`
|
|
38
|
+
- `host`
|
|
39
|
+
- `port`
|
|
40
|
+
- `address`
|
|
41
|
+
- `status`
|
|
42
|
+
- `capacity`
|
|
43
|
+
- `running_tasks`
|
|
44
|
+
- Protocol and worker status enums
|
|
45
|
+
- Minimal command acknowledgement fields
|
|
46
|
+
- Common metrics envelope fields
|
|
47
|
+
|
|
48
|
+
### Protocol typing rule
|
|
49
|
+
|
|
50
|
+
`ProtocolType` is intentionally kept coarse and stable:
|
|
51
|
+
|
|
52
|
+
- `http`
|
|
53
|
+
- `rpc`
|
|
54
|
+
- `stream`
|
|
55
|
+
- `message`
|
|
56
|
+
- `database`
|
|
57
|
+
- `transport`
|
|
58
|
+
- `custom`
|
|
59
|
+
|
|
60
|
+
Concrete protocol or engine names should be expressed through explicit fields such as:
|
|
61
|
+
|
|
62
|
+
- `protocol_name`
|
|
63
|
+
- `engine_name`
|
|
64
|
+
- `adapter_name`
|
|
65
|
+
|
|
66
|
+
This avoids expanding the stable enum every time a new protocol, adapter, or engine is added.
|
|
67
|
+
|
|
68
|
+
### Naming examples
|
|
69
|
+
|
|
70
|
+
- HTTP builtin worker
|
|
71
|
+
- `protocol = "http"`
|
|
72
|
+
- `protocol_name = "http"`
|
|
73
|
+
- `engine_name = "builtin"`
|
|
74
|
+
|
|
75
|
+
- gRPC builtin worker
|
|
76
|
+
- `protocol = "rpc"`
|
|
77
|
+
- `protocol_name = "grpc"`
|
|
78
|
+
- `engine_name = "builtin"`
|
|
79
|
+
|
|
80
|
+
- MQTT adapter
|
|
81
|
+
- `protocol = "message"`
|
|
82
|
+
- `protocol_name = "mqtt"`
|
|
83
|
+
- `engine_name = "builtin"`
|
|
84
|
+
- `adapter_name = "falcon-adapter-mqtt"`
|
|
85
|
+
|
|
86
|
+
- Locust-based HTTP worker
|
|
87
|
+
- `protocol = "http"`
|
|
88
|
+
- `protocol_name = "http"`
|
|
89
|
+
- `engine_name = "locust"`
|
|
90
|
+
- `adapter_name = "falcon-adapter-locust"`
|
|
91
|
+
|
|
92
|
+
- MySQL pressure worker
|
|
93
|
+
- `protocol = "database"`
|
|
94
|
+
- `protocol_name = "mysql"`
|
|
95
|
+
- `engine_name = "builtin"`
|
|
96
|
+
|
|
97
|
+
### Experimental fields
|
|
98
|
+
|
|
99
|
+
- Worker capability details
|
|
100
|
+
- Worker runtime snapshot structure
|
|
101
|
+
- Task execution plan structure
|
|
102
|
+
- Protocol-specific metric extension payloads
|
|
103
|
+
- Event summary payload shape
|
|
104
|
+
|
|
105
|
+
## Package boundary
|
|
106
|
+
|
|
107
|
+
`falcon-interface` should be the only shared dependency between:
|
|
108
|
+
|
|
109
|
+
- `falcon-master`
|
|
110
|
+
- `falcon-worker`
|
|
111
|
+
- future Falcon SDK packages
|
|
112
|
+
- third-party workers and protocol adapters
|
|
113
|
+
|
|
114
|
+
It should not depend on, or expose, any of the following:
|
|
115
|
+
|
|
116
|
+
- ORM models
|
|
117
|
+
- database identifiers and audit fields
|
|
118
|
+
- service-layer exceptions
|
|
119
|
+
- platform-specific scheduler internals
|
|
120
|
+
- UI/report DTOs
|
|
121
|
+
|
|
122
|
+
## Public surface
|
|
123
|
+
|
|
124
|
+
Preferred public imports:
|
|
125
|
+
|
|
126
|
+
- `falcon_interface.enums`
|
|
127
|
+
- `falcon_interface.contracts`
|
|
128
|
+
- `falcon_interface.grpc.generated`
|
|
129
|
+
|
|
130
|
+
Compatibility-only modules kept during migration:
|
|
131
|
+
|
|
132
|
+
- `falcon_interface.runtime_enums`
|
|
133
|
+
- `falcon_interface.task_contracts`
|
|
134
|
+
|
|
135
|
+
These compatibility modules exist to let the current built-in master/worker run
|
|
136
|
+
without forcing a one-shot refactor. They should not be treated as the long-term
|
|
137
|
+
SDK surface for external integrators.
|
|
138
|
+
|
|
139
|
+
## Proto source of truth
|
|
140
|
+
|
|
141
|
+
- `proto/worker_runtime.proto` is the source of truth for the current runtime gRPC contract
|
|
142
|
+
- `falcon_interface/grpc/generated/` contains generated Python bindings
|
|
143
|
+
- Generated files should be replaced from proto, not edited by hand during normal evolution
|
|
144
|
+
|
|
145
|
+
## Current freezing strategy
|
|
146
|
+
|
|
147
|
+
Freeze first:
|
|
148
|
+
|
|
149
|
+
- `WorkerInfo` stable identity and capacity fields
|
|
150
|
+
- `WorkerStatus`
|
|
151
|
+
- `ProtocolType`
|
|
152
|
+
- minimal command acknowledgement shape
|
|
153
|
+
- metrics common envelope core
|
|
154
|
+
|
|
155
|
+
Keep experimental for now:
|
|
156
|
+
|
|
157
|
+
- task execution plan details
|
|
158
|
+
- protocol-specific metrics extensions
|
|
159
|
+
- event summary payload structure
|
|
160
|
+
- capability and runtime snapshot detail payloads
|
|
161
|
+
|
|
162
|
+
### Design rules
|
|
163
|
+
|
|
164
|
+
- Only add fields, never rename or remove stable fields in-place
|
|
165
|
+
- Do not leak ORM, database, or service-layer implementation concepts
|
|
166
|
+
- Keep protocol-neutral contracts in the stable core
|
|
167
|
+
- Move protocol-specific or engine-specific details into explicit extension blocks
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# falcon-interface
|
|
2
|
+
|
|
3
|
+
`falcon-interface` is the stable external contract package for Falcon.
|
|
4
|
+
|
|
5
|
+
It is intended to hold only versioned, backward-compatible protocol definitions and
|
|
6
|
+
cross-boundary data contracts shared by:
|
|
7
|
+
|
|
8
|
+
- `falcon-master`
|
|
9
|
+
- `falcon-worker`
|
|
10
|
+
- future Falcon SDKs
|
|
11
|
+
- third-party workers and adapters
|
|
12
|
+
|
|
13
|
+
This package should not depend on internal ORM models, service-layer logic, or
|
|
14
|
+
platform-only implementation details.
|
|
15
|
+
|
|
16
|
+
## Stability policy
|
|
17
|
+
|
|
18
|
+
`falcon-interface` is divided into two categories:
|
|
19
|
+
|
|
20
|
+
- Stable core: fields and contracts that are expected to remain backward compatible
|
|
21
|
+
across master, worker, SDK, and third-party adapters.
|
|
22
|
+
- Experimental surface: fields kept for current implementation compatibility but not
|
|
23
|
+
yet considered frozen.
|
|
24
|
+
|
|
25
|
+
### Stable first candidates
|
|
26
|
+
|
|
27
|
+
- Worker core identity and capacity:
|
|
28
|
+
- `worker_id`
|
|
29
|
+
- `host`
|
|
30
|
+
- `port`
|
|
31
|
+
- `address`
|
|
32
|
+
- `status`
|
|
33
|
+
- `capacity`
|
|
34
|
+
- `running_tasks`
|
|
35
|
+
- Protocol and worker status enums
|
|
36
|
+
- Minimal command acknowledgement fields
|
|
37
|
+
- Common metrics envelope fields
|
|
38
|
+
|
|
39
|
+
### Protocol typing rule
|
|
40
|
+
|
|
41
|
+
`ProtocolType` is intentionally kept coarse and stable:
|
|
42
|
+
|
|
43
|
+
- `http`
|
|
44
|
+
- `rpc`
|
|
45
|
+
- `stream`
|
|
46
|
+
- `message`
|
|
47
|
+
- `database`
|
|
48
|
+
- `transport`
|
|
49
|
+
- `custom`
|
|
50
|
+
|
|
51
|
+
Concrete protocol or engine names should be expressed through explicit fields such as:
|
|
52
|
+
|
|
53
|
+
- `protocol_name`
|
|
54
|
+
- `engine_name`
|
|
55
|
+
- `adapter_name`
|
|
56
|
+
|
|
57
|
+
This avoids expanding the stable enum every time a new protocol, adapter, or engine is added.
|
|
58
|
+
|
|
59
|
+
### Naming examples
|
|
60
|
+
|
|
61
|
+
- HTTP builtin worker
|
|
62
|
+
- `protocol = "http"`
|
|
63
|
+
- `protocol_name = "http"`
|
|
64
|
+
- `engine_name = "builtin"`
|
|
65
|
+
|
|
66
|
+
- gRPC builtin worker
|
|
67
|
+
- `protocol = "rpc"`
|
|
68
|
+
- `protocol_name = "grpc"`
|
|
69
|
+
- `engine_name = "builtin"`
|
|
70
|
+
|
|
71
|
+
- MQTT adapter
|
|
72
|
+
- `protocol = "message"`
|
|
73
|
+
- `protocol_name = "mqtt"`
|
|
74
|
+
- `engine_name = "builtin"`
|
|
75
|
+
- `adapter_name = "falcon-adapter-mqtt"`
|
|
76
|
+
|
|
77
|
+
- Locust-based HTTP worker
|
|
78
|
+
- `protocol = "http"`
|
|
79
|
+
- `protocol_name = "http"`
|
|
80
|
+
- `engine_name = "locust"`
|
|
81
|
+
- `adapter_name = "falcon-adapter-locust"`
|
|
82
|
+
|
|
83
|
+
- MySQL pressure worker
|
|
84
|
+
- `protocol = "database"`
|
|
85
|
+
- `protocol_name = "mysql"`
|
|
86
|
+
- `engine_name = "builtin"`
|
|
87
|
+
|
|
88
|
+
### Experimental fields
|
|
89
|
+
|
|
90
|
+
- Worker capability details
|
|
91
|
+
- Worker runtime snapshot structure
|
|
92
|
+
- Task execution plan structure
|
|
93
|
+
- Protocol-specific metric extension payloads
|
|
94
|
+
- Event summary payload shape
|
|
95
|
+
|
|
96
|
+
## Package boundary
|
|
97
|
+
|
|
98
|
+
`falcon-interface` should be the only shared dependency between:
|
|
99
|
+
|
|
100
|
+
- `falcon-master`
|
|
101
|
+
- `falcon-worker`
|
|
102
|
+
- future Falcon SDK packages
|
|
103
|
+
- third-party workers and protocol adapters
|
|
104
|
+
|
|
105
|
+
It should not depend on, or expose, any of the following:
|
|
106
|
+
|
|
107
|
+
- ORM models
|
|
108
|
+
- database identifiers and audit fields
|
|
109
|
+
- service-layer exceptions
|
|
110
|
+
- platform-specific scheduler internals
|
|
111
|
+
- UI/report DTOs
|
|
112
|
+
|
|
113
|
+
## Public surface
|
|
114
|
+
|
|
115
|
+
Preferred public imports:
|
|
116
|
+
|
|
117
|
+
- `falcon_interface.enums`
|
|
118
|
+
- `falcon_interface.contracts`
|
|
119
|
+
- `falcon_interface.grpc.generated`
|
|
120
|
+
|
|
121
|
+
Compatibility-only modules kept during migration:
|
|
122
|
+
|
|
123
|
+
- `falcon_interface.runtime_enums`
|
|
124
|
+
- `falcon_interface.task_contracts`
|
|
125
|
+
|
|
126
|
+
These compatibility modules exist to let the current built-in master/worker run
|
|
127
|
+
without forcing a one-shot refactor. They should not be treated as the long-term
|
|
128
|
+
SDK surface for external integrators.
|
|
129
|
+
|
|
130
|
+
## Proto source of truth
|
|
131
|
+
|
|
132
|
+
- `proto/worker_runtime.proto` is the source of truth for the current runtime gRPC contract
|
|
133
|
+
- `falcon_interface/grpc/generated/` contains generated Python bindings
|
|
134
|
+
- Generated files should be replaced from proto, not edited by hand during normal evolution
|
|
135
|
+
|
|
136
|
+
## Current freezing strategy
|
|
137
|
+
|
|
138
|
+
Freeze first:
|
|
139
|
+
|
|
140
|
+
- `WorkerInfo` stable identity and capacity fields
|
|
141
|
+
- `WorkerStatus`
|
|
142
|
+
- `ProtocolType`
|
|
143
|
+
- minimal command acknowledgement shape
|
|
144
|
+
- metrics common envelope core
|
|
145
|
+
|
|
146
|
+
Keep experimental for now:
|
|
147
|
+
|
|
148
|
+
- task execution plan details
|
|
149
|
+
- protocol-specific metrics extensions
|
|
150
|
+
- event summary payload structure
|
|
151
|
+
- capability and runtime snapshot detail payloads
|
|
152
|
+
|
|
153
|
+
### Design rules
|
|
154
|
+
|
|
155
|
+
- Only add fields, never rename or remove stable fields in-place
|
|
156
|
+
- Do not leak ORM, database, or service-layer implementation concepts
|
|
157
|
+
- Keep protocol-neutral contracts in the stable core
|
|
158
|
+
- Move protocol-specific or engine-specific details into explicit extension blocks
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from falcon_interface.contracts import (
|
|
2
|
+
CommandAck,
|
|
3
|
+
CommonMetrics,
|
|
4
|
+
ExecutionPlanItem,
|
|
5
|
+
HeartbeatWorkerCommand,
|
|
6
|
+
MetricEnvelope,
|
|
7
|
+
ProtocolMetricsExtension,
|
|
8
|
+
RegisterWorkerCommand,
|
|
9
|
+
ReportTaskEventCommand,
|
|
10
|
+
StartTaskCommand,
|
|
11
|
+
StopTaskCommand,
|
|
12
|
+
TaskContext,
|
|
13
|
+
TaskDefinition,
|
|
14
|
+
WorkerCapability,
|
|
15
|
+
WorkerInfo,
|
|
16
|
+
WorkerRuntimeSnapshot,
|
|
17
|
+
)
|
|
18
|
+
from falcon_interface.enums import CommandType, ProtocolType, TaskLifecycleStatus, WorkerStatus
|
|
19
|
+
from falcon_interface.version import INTERFACE_VERSION, PROTO_VERSION
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"CommandAck",
|
|
23
|
+
"CommandType",
|
|
24
|
+
"CommonMetrics",
|
|
25
|
+
"ExecutionPlanItem",
|
|
26
|
+
"HeartbeatWorkerCommand",
|
|
27
|
+
"INTERFACE_VERSION",
|
|
28
|
+
"MetricEnvelope",
|
|
29
|
+
"ProtocolMetricsExtension",
|
|
30
|
+
"PROTO_VERSION",
|
|
31
|
+
"ProtocolType",
|
|
32
|
+
"RegisterWorkerCommand",
|
|
33
|
+
"ReportTaskEventCommand",
|
|
34
|
+
"StartTaskCommand",
|
|
35
|
+
"StopTaskCommand",
|
|
36
|
+
"TaskContext",
|
|
37
|
+
"TaskDefinition",
|
|
38
|
+
"TaskLifecycleStatus",
|
|
39
|
+
"WorkerCapability",
|
|
40
|
+
"WorkerInfo",
|
|
41
|
+
"WorkerRuntimeSnapshot",
|
|
42
|
+
"WorkerStatus",
|
|
43
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from falcon_interface.contracts.command import (
|
|
2
|
+
CommandAck,
|
|
3
|
+
RegisterWorkerCommand,
|
|
4
|
+
HeartbeatWorkerCommand,
|
|
5
|
+
ReportTaskEventCommand,
|
|
6
|
+
StartTaskCommand,
|
|
7
|
+
StopTaskCommand,
|
|
8
|
+
)
|
|
9
|
+
from falcon_interface.contracts.metrics import CommonMetrics, MetricEnvelope, ProtocolMetricsExtension
|
|
10
|
+
from falcon_interface.contracts.task import ExecutionPlanItem, TaskContext, TaskDefinition
|
|
11
|
+
from falcon_interface.contracts.worker import WorkerCapability, WorkerInfo, WorkerRuntimeSnapshot
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"CommandAck",
|
|
15
|
+
"CommonMetrics",
|
|
16
|
+
"ExecutionPlanItem",
|
|
17
|
+
"HeartbeatWorkerCommand",
|
|
18
|
+
"MetricEnvelope",
|
|
19
|
+
"ProtocolMetricsExtension",
|
|
20
|
+
"RegisterWorkerCommand",
|
|
21
|
+
"ReportTaskEventCommand",
|
|
22
|
+
"StartTaskCommand",
|
|
23
|
+
"StopTaskCommand",
|
|
24
|
+
"TaskContext",
|
|
25
|
+
"TaskDefinition",
|
|
26
|
+
"WorkerCapability",
|
|
27
|
+
"WorkerInfo",
|
|
28
|
+
"WorkerRuntimeSnapshot",
|
|
29
|
+
]
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
from falcon_interface.contracts.metrics import MetricEnvelope
|
|
6
|
+
from falcon_interface.contracts.task import TaskDefinition
|
|
7
|
+
from falcon_interface.contracts.worker import WorkerInfo
|
|
8
|
+
from falcon_interface.enums import CommandType
|
|
9
|
+
from falcon_interface.version import INTERFACE_VERSION
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CommandAck(BaseModel):
|
|
13
|
+
"""Stable minimal acknowledgement contract."""
|
|
14
|
+
|
|
15
|
+
version: str = INTERFACE_VERSION
|
|
16
|
+
accepted: bool
|
|
17
|
+
message: str = ""
|
|
18
|
+
worker_id: str = ""
|
|
19
|
+
worker_task_id: str = ""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class RegisterWorkerCommand(BaseModel):
|
|
23
|
+
"""Register command.
|
|
24
|
+
|
|
25
|
+
The command frame is stable. Nested worker capability details are still evolving.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
version: str = INTERFACE_VERSION
|
|
29
|
+
command: CommandType = CommandType.REGISTER
|
|
30
|
+
token: str
|
|
31
|
+
worker: WorkerInfo
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class HeartbeatWorkerCommand(BaseModel):
|
|
35
|
+
"""Heartbeat command with an experimental snapshot payload."""
|
|
36
|
+
|
|
37
|
+
version: str = INTERFACE_VERSION
|
|
38
|
+
command: CommandType = CommandType.HEARTBEAT
|
|
39
|
+
token: str
|
|
40
|
+
worker_id: str
|
|
41
|
+
running_tasks: int = 0
|
|
42
|
+
capacity: int = 1
|
|
43
|
+
tags: list[str] = Field(default_factory=list)
|
|
44
|
+
version_name: str | None = None
|
|
45
|
+
last_seen_error: str | None = None
|
|
46
|
+
snapshot: dict = Field(default_factory=dict)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class StartTaskCommand(BaseModel):
|
|
50
|
+
"""Stable start-task command frame around an evolving task contract."""
|
|
51
|
+
|
|
52
|
+
version: str = INTERFACE_VERSION
|
|
53
|
+
command: CommandType = CommandType.START_TASK
|
|
54
|
+
worker_task_id: str
|
|
55
|
+
task: TaskDefinition
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class StopTaskCommand(BaseModel):
|
|
59
|
+
"""Stable stop-task command frame."""
|
|
60
|
+
|
|
61
|
+
version: str = INTERFACE_VERSION
|
|
62
|
+
command: CommandType = CommandType.STOP_TASK
|
|
63
|
+
task_id: int
|
|
64
|
+
task_run_id: int
|
|
65
|
+
worker_task_id: str
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ReportTaskEventCommand(BaseModel):
|
|
69
|
+
"""Task event command.
|
|
70
|
+
|
|
71
|
+
Stable core:
|
|
72
|
+
- worker_id
|
|
73
|
+
- worker_task_id
|
|
74
|
+
- task_id
|
|
75
|
+
- task_run_id
|
|
76
|
+
- event_type
|
|
77
|
+
- status
|
|
78
|
+
|
|
79
|
+
Experimental surface:
|
|
80
|
+
- metrics
|
|
81
|
+
- summary
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
version: str = INTERFACE_VERSION
|
|
85
|
+
command: CommandType = CommandType.REPORT_EVENT
|
|
86
|
+
worker_id: str
|
|
87
|
+
worker_task_id: str
|
|
88
|
+
task_id: int
|
|
89
|
+
task_run_id: int
|
|
90
|
+
event_type: str
|
|
91
|
+
status: str
|
|
92
|
+
metrics: MetricEnvelope | None = None
|
|
93
|
+
summary: dict = Field(default_factory=dict)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from falcon_interface.enums import ProtocolType
|
|
9
|
+
from falcon_interface.version import INTERFACE_VERSION
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CommonMetrics(BaseModel):
|
|
13
|
+
"""Stable protocol-neutral metrics core."""
|
|
14
|
+
|
|
15
|
+
timestamp: datetime | None = None
|
|
16
|
+
concurrency: int = 0
|
|
17
|
+
total_ops: int = 0
|
|
18
|
+
success_ops: int = 0
|
|
19
|
+
failed_ops: int = 0
|
|
20
|
+
ops_per_sec: float = 0.0
|
|
21
|
+
avg_latency_ms: float = 0.0
|
|
22
|
+
p95_latency_ms: float = 0.0
|
|
23
|
+
p99_latency_ms: float = 0.0
|
|
24
|
+
error_rate: float = 0.0
|
|
25
|
+
last_error: str | None = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ProtocolMetricsExtension(BaseModel):
|
|
29
|
+
"""Experimental protocol-specific metrics payload."""
|
|
30
|
+
|
|
31
|
+
values: dict[str, Any] = Field(default_factory=dict)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class MetricEnvelope(BaseModel):
|
|
35
|
+
"""Metrics contract.
|
|
36
|
+
|
|
37
|
+
Stable core:
|
|
38
|
+
- protocol
|
|
39
|
+
- task_id
|
|
40
|
+
- task_run_id
|
|
41
|
+
- worker_id
|
|
42
|
+
- target
|
|
43
|
+
- common
|
|
44
|
+
|
|
45
|
+
Experimental surface:
|
|
46
|
+
- extensions
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
version: str = INTERFACE_VERSION
|
|
50
|
+
protocol: ProtocolType
|
|
51
|
+
task_id: int
|
|
52
|
+
task_run_id: int
|
|
53
|
+
worker_id: str
|
|
54
|
+
target: str | None = None
|
|
55
|
+
common: CommonMetrics = Field(default_factory=CommonMetrics)
|
|
56
|
+
extensions: dict[str, ProtocolMetricsExtension] = Field(default_factory=dict)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
from falcon_interface.enums import ProtocolType
|
|
8
|
+
from falcon_interface.version import INTERFACE_VERSION
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TaskContext(BaseModel):
|
|
12
|
+
"""Experimental task context envelope.
|
|
13
|
+
|
|
14
|
+
Field meanings:
|
|
15
|
+
- protocol: stable coarse-grained category
|
|
16
|
+
- protocol_name: concrete protocol name, such as http, grpc, mqtt, mysql
|
|
17
|
+
- engine_name: concrete execution engine, such as builtin, locust, jmeter, k6
|
|
18
|
+
- adapter_name: optional adapter/plugin identity chosen for execution
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
version: str = INTERFACE_VERSION
|
|
22
|
+
protocol: ProtocolType = ProtocolType.HTTP
|
|
23
|
+
protocol_name: str = "http"
|
|
24
|
+
engine_name: str | None = None
|
|
25
|
+
adapter_name: str | None = None
|
|
26
|
+
project_id: int | None = None
|
|
27
|
+
project_name: str | None = None
|
|
28
|
+
owner_id: int | None = None
|
|
29
|
+
owner_name: str | None = None
|
|
30
|
+
labels: dict[str, str] = Field(default_factory=dict)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ExecutionPlanItem(BaseModel):
|
|
34
|
+
"""Experimental execution item.
|
|
35
|
+
|
|
36
|
+
The stable interface should eventually move protocol-specific execution details
|
|
37
|
+
into well-defined extension objects rather than an open config dict.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
name: str
|
|
41
|
+
weight: int = 0
|
|
42
|
+
target_users: int | None = None
|
|
43
|
+
config: dict[str, Any] = Field(default_factory=dict)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class TaskDefinition(BaseModel):
|
|
47
|
+
"""Task contract with a stable core and an experimental execution surface.
|
|
48
|
+
|
|
49
|
+
Stable core fields:
|
|
50
|
+
- task_id
|
|
51
|
+
- task_run_id
|
|
52
|
+
- task_name
|
|
53
|
+
- users
|
|
54
|
+
- spawn_rate
|
|
55
|
+
- duration
|
|
56
|
+
|
|
57
|
+
Experimental fields:
|
|
58
|
+
- host
|
|
59
|
+
- execution_strategy
|
|
60
|
+
- completion_policy
|
|
61
|
+
- context
|
|
62
|
+
- execution_plan
|
|
63
|
+
- control_plane_addr
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
version: str = INTERFACE_VERSION
|
|
67
|
+
task_id: int
|
|
68
|
+
task_run_id: int
|
|
69
|
+
task_name: str
|
|
70
|
+
host: str
|
|
71
|
+
users: int
|
|
72
|
+
spawn_rate: int
|
|
73
|
+
duration: int
|
|
74
|
+
execution_strategy: str
|
|
75
|
+
completion_policy: str = "graceful"
|
|
76
|
+
context: TaskContext = Field(default_factory=TaskContext)
|
|
77
|
+
execution_plan: list[ExecutionPlanItem] = Field(default_factory=list)
|
|
78
|
+
control_plane_addr: str | None = None
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from falcon_interface.enums import ProtocolType, WorkerStatus
|
|
9
|
+
from falcon_interface.version import INTERFACE_VERSION
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class WorkerCapability(BaseModel):
|
|
13
|
+
"""Experimental worker capability descriptor.
|
|
14
|
+
|
|
15
|
+
Field meanings:
|
|
16
|
+
- protocol: stable coarse-grained category
|
|
17
|
+
- protocol_name: concrete protocol name, such as grpc, mqtt, mysql, kafka
|
|
18
|
+
- engine_name: concrete execution engine, such as builtin, locust, jmeter, k6
|
|
19
|
+
- adapter_name: optional adapter/plugin identity
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
protocol: ProtocolType
|
|
23
|
+
protocol_name: str
|
|
24
|
+
engine_name: str
|
|
25
|
+
adapter_name: str | None = None
|
|
26
|
+
language: str | None = None
|
|
27
|
+
tags: list[str] = Field(default_factory=list)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class WorkerRuntimeSnapshot(BaseModel):
|
|
31
|
+
"""Experimental runtime snapshot payload. Shape may evolve by protocol and engine."""
|
|
32
|
+
|
|
33
|
+
sampled_at: datetime | None = None
|
|
34
|
+
system: dict[str, Any] = Field(default_factory=dict)
|
|
35
|
+
resources: dict[str, Any] = Field(default_factory=dict)
|
|
36
|
+
process: dict[str, Any] = Field(default_factory=dict)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class WorkerInfo(BaseModel):
|
|
40
|
+
"""Stable core worker contract.
|
|
41
|
+
|
|
42
|
+
Stable core fields:
|
|
43
|
+
- worker_id
|
|
44
|
+
- host
|
|
45
|
+
- port
|
|
46
|
+
- address
|
|
47
|
+
- status
|
|
48
|
+
- capacity
|
|
49
|
+
- running_tasks
|
|
50
|
+
|
|
51
|
+
Experimental fields:
|
|
52
|
+
- capabilities
|
|
53
|
+
- snapshot
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
version: str = INTERFACE_VERSION
|
|
57
|
+
worker_id: str
|
|
58
|
+
host: str
|
|
59
|
+
port: int
|
|
60
|
+
address: str
|
|
61
|
+
status: WorkerStatus = WorkerStatus.ONLINE
|
|
62
|
+
capacity: int = 1
|
|
63
|
+
running_tasks: int = 0
|
|
64
|
+
capabilities: list[WorkerCapability] = Field(default_factory=list)
|
|
65
|
+
snapshot: WorkerRuntimeSnapshot | None = None
|