DefStream 0.1.5__tar.gz → 0.1.7__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.
- {defstream-0.1.5 → defstream-0.1.7}/DefStream.egg-info/PKG-INFO +28 -8
- {defstream-0.1.5 → defstream-0.1.7}/DefStream.egg-info/SOURCES.txt +4 -0
- {defstream-0.1.5 → defstream-0.1.7}/PKG-INFO +28 -8
- {defstream-0.1.5 → defstream-0.1.7}/README.en.md +28 -7
- {defstream-0.1.5 → defstream-0.1.7}/README.md +27 -7
- {defstream-0.1.5 → defstream-0.1.7}/issues/feature/1/README.md +3 -3
- defstream-0.1.7/issues/fix/3/IMPLEMENTS.md +232 -0
- defstream-0.1.7/issues/fix/3/README.md +94 -0
- defstream-0.1.7/issues/fix/3/REQUIREMENTS.md +78 -0
- defstream-0.1.7/issues/fix/3/ci.refs.json +4 -0
- {defstream-0.1.5 → defstream-0.1.7}/sample/Worker/RabbitMQ/Worker.py +2 -2
- {defstream-0.1.5 → defstream-0.1.7}/sample/Worker/Redis/Sample.py +2 -2
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Connection.py +21 -5
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/__init__.py +4 -2
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extensions/Console.py +4 -15
- {defstream-0.1.5 → defstream-0.1.7}/src/Worker/Message.py +17 -16
- {defstream-0.1.5 → defstream-0.1.7}/src/Worker/Worker.py +3 -11
- {defstream-0.1.5 → defstream-0.1.7}/src/Worker/__init__.py +2 -4
- {defstream-0.1.5 → defstream-0.1.7}/test/test_inspector.py +2 -3
- {defstream-0.1.5 → defstream-0.1.7}/test/test_inspector_console.py +2 -2
- {defstream-0.1.5 → defstream-0.1.7}/test/test_lifecycle_hooks.py +1 -1
- {defstream-0.1.5 → defstream-0.1.7}/test/test_protocol_contracts.py +176 -10
- {defstream-0.1.5 → defstream-0.1.7}/test/test_runner_hooks.py +1 -2
- {defstream-0.1.5 → defstream-0.1.7}/test/test_task_messages.py +120 -21
- {defstream-0.1.5 → defstream-0.1.7}/test/test_task_priorities.py +9 -9
- {defstream-0.1.5 → defstream-0.1.7}/test/test_worker.py +1 -2
- {defstream-0.1.5 → defstream-0.1.7}/test/test_worker_startup.py +1 -1
- {defstream-0.1.5 → defstream-0.1.7}/.github/workflows/ci.yml +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/.gitignore +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/DefStream.egg-info/dependency_links.txt +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/DefStream.egg-info/requires.txt +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/DefStream.egg-info/top_level.txt +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/LICENSE +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/issues/feature/1/IMPLEMENTS.md +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/issues/feature/1/REQUIREMENTS.md +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/issues/feature/1/TASK.md +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/issues/feature/1/ci.refs.json +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/sample/Broker/Sample.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/sample/Worker/RabbitMQ/Client.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/sample/Worker/RabbitMQ/Tasks.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/sample/Worker/Sample.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/setup.cfg +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/setup.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Configuration.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Consumer.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Errors.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Event.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Implements/__init__.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Policies.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Priority.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Broker/Protocol.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Descriptor/DataObject.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Descriptor/Types.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Descriptor/Value.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Descriptor/__init__.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extension.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extensions/Console.html +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extensions/Dashboard.html +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extensions/Dashboard.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extensions/HealthCheck.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extensions/Metrics.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extensions/Specifications.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Extensions/__init__.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Inspector.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/Response.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Inspector/__init__.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Pattern.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/Array.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/Common.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/Compare.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/Condition.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/DataObject.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/DateTime.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/Number.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/Object.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/Size.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/String.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/Type.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Patterns/__init__.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Validate.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/Validator.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Validator/__init__.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Worker/Executor.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Worker/Pool.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Worker/Run.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Worker/Specification.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/Worker/Startup.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/src/__init__.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/test/test_dashboard.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/test/test_dashboard_ui.cjs +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/test/test_pool_callbacks.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/test/test_process_signals.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/test/test_release_workflow.py +0 -0
- {defstream-0.1.5 → defstream-0.1.7}/test/test_specifications.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DefStream
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Synchronous message processing with pluggable broker adapters
|
|
5
5
|
Home-page: https://github.com/yong5eon/DefStream
|
|
6
6
|
Author: Heo Yongseon
|
|
@@ -124,6 +124,11 @@ class Add(
|
|
|
124
124
|
|
|
125
125
|
### 2. Worker 실행: `worker.py`
|
|
126
126
|
|
|
127
|
+
`Worker`는 `DefStream.Broker.Connection`을 직접 받습니다.
|
|
128
|
+
연결 계약은 `connect()`, `close()`만 요구하며, 워커 실행 시 내부에서
|
|
129
|
+
`GetConsumer` 지원 여부를 검사합니다. 컨슈머를 생성할 수 없는 브로커는 `TypeError`를 발생시키며,
|
|
130
|
+
워커 전용 연결 타입은 필요하지 않습니다.
|
|
131
|
+
|
|
127
132
|
```python
|
|
128
133
|
from signal import SIGINT, signal
|
|
129
134
|
|
|
@@ -176,7 +181,7 @@ Worker가 실행 중인 상태에서 다른 터미널에서 실행하세요.
|
|
|
176
181
|
|
|
177
182
|
```python
|
|
178
183
|
from DefStream.Broker.Implements.RabbitMQ import Configuration, Connection
|
|
179
|
-
from DefStream.Worker import
|
|
184
|
+
from DefStream.Worker import emit, request
|
|
180
185
|
from tasks import Add
|
|
181
186
|
|
|
182
187
|
|
|
@@ -188,7 +193,7 @@ connection = Connection(Configuration(
|
|
|
188
193
|
))
|
|
189
194
|
try:
|
|
190
195
|
connection.connect()
|
|
191
|
-
message_id =
|
|
196
|
+
message_id = emit(
|
|
192
197
|
{'a': 10, 'b': 20},
|
|
193
198
|
task=Add,
|
|
194
199
|
broker=connection,
|
|
@@ -209,7 +214,7 @@ finally:
|
|
|
209
214
|
python client.py
|
|
210
215
|
```
|
|
211
216
|
|
|
212
|
-
`
|
|
217
|
+
`emit()`와 `request()`는 **각각 별도의 작업을 발행**합니다. 위 예제는 덧셈을 두 번 실행하며,
|
|
213
218
|
`request()`의 결과는 `30`입니다. `request()`의 제한 시간은 초 단위이고,
|
|
214
219
|
시간이 초과되어도 이미 전달된 작업은 취소되지 않습니다.
|
|
215
220
|
|
|
@@ -220,14 +225,20 @@ python client.py
|
|
|
220
225
|
| 함수 | 역할 | 연결 관리 |
|
|
221
226
|
| --- | --- | --- |
|
|
222
227
|
| `declare(task=..., broker=...)` | 작업의 큐·구독 리소스 선언 | 호출자가 연결·종료 |
|
|
223
|
-
| `
|
|
228
|
+
| `emit(body, task=..., broker=...)` | 작업 목적지로 단방향 메시지 발행 | 호출자가 연결·종료 |
|
|
224
229
|
| `request(body, task=..., broker=..., timeout=5)` | 작업 결과를 동기 RPC로 요청 | 호출자가 연결·종료; RabbitMQ만 지원 |
|
|
225
230
|
|
|
226
231
|
세 함수는 `DefStream.Worker`에서 가져옵니다. 전달된 연결을 자동으로 열거나 닫지 않으며,
|
|
227
|
-
`
|
|
232
|
+
`emit()`와 `request()`는 목적지를 자동 선언하지 않습니다.
|
|
228
233
|
수신 Worker 또는 별도의 준비 단계에서 먼저 `declare()`를 호출하세요.
|
|
229
234
|
하나의 연결을 같은 소유 스레드에서 여러 발행에 재사용할 수 있습니다.
|
|
230
235
|
|
|
236
|
+
세 함수 모두 공통 `Connection`을 받고, 내부에서 선언·발행·RPC 지원 여부를 확인합니다.
|
|
237
|
+
지원하지 않는 기능은 `NotImplementedError`로 실패합니다.
|
|
238
|
+
기존 작업 발행 함수와 연결의 `send`는 `emit`으로 이름이 바뀌었습니다.
|
|
239
|
+
사용자 정의 브로커의 작업 발행 계약도 `TaskSender.send` 대신 `Emittable.emit`을 사용하세요.
|
|
240
|
+
큐·Exchange·Stream의 저수준 `Sendable.send()`와 RPC `Callable.call()`은 그대로입니다.
|
|
241
|
+
|
|
231
242
|
작업 본문은 **문자열 키를 가진 매핑**이어야 하며, 반환값은 어댑터가 직렬화할 수 있어야 합니다.
|
|
232
243
|
하나의 Worker에서는 같은 큐에 여러 작업을 중복 등록할 수 없습니다.
|
|
233
244
|
메시지 유형을 보고 여러 `Run` 중 하나를 고르는 방식이 아니라 큐별로 작업을 선택합니다.
|
|
@@ -245,7 +256,7 @@ from DefStream.Worker import (
|
|
|
245
256
|
Run,
|
|
246
257
|
declare,
|
|
247
258
|
request,
|
|
248
|
-
|
|
259
|
+
emit,
|
|
249
260
|
)
|
|
250
261
|
|
|
251
262
|
|
|
@@ -270,7 +281,7 @@ declare(
|
|
|
270
281
|
task=Add,
|
|
271
282
|
broker=broker,
|
|
272
283
|
)
|
|
273
|
-
|
|
284
|
+
emit(
|
|
274
285
|
{'a': 10, 'b': 20},
|
|
275
286
|
task=Add,
|
|
276
287
|
broker=broker,
|
|
@@ -310,6 +321,10 @@ result = request(
|
|
|
310
321
|
브로커 리소스를 직접 사용할 때의 공통 메서드는 다음과 같습니다.
|
|
311
322
|
모든 리소스가 모든 메서드를 지원하는 것은 아닙니다.
|
|
312
323
|
|
|
324
|
+
연결의 `exchange()`·`queue()`·`stream()`·`consumer()` 지원 여부는 각각
|
|
325
|
+
`GetExchange`·`GetQueue`·`GetStream`·`GetConsumer`로 `isinstance` 또는 `issubclass`
|
|
326
|
+
검사할 수 있습니다. 이 계약들은 `DefStream.Broker`에서 가져옵니다.
|
|
327
|
+
|
|
313
328
|
| 메서드 | 의미 | 제한 시간 단위 |
|
|
314
329
|
| --- | --- | --- |
|
|
315
330
|
| `send(body)` | 메시지 발행 | 어댑터별 설정 |
|
|
@@ -574,6 +589,11 @@ inspector = Inspector(
|
|
|
574
589
|
Inspector 자체는 TLS를 제공하지 않으며 공개 웹 서버가 아닙니다.
|
|
575
590
|
콘솔의 연결 팩터리는 호출마다 새 연결을 반환해야 하고 Worker 연결을 공유하면 안 됩니다.
|
|
576
591
|
|
|
592
|
+
Console의 `broker` 인자는 `DefStream.Broker.BrokerFactory` 계약을 사용합니다.
|
|
593
|
+
이 계약의 `__call__() -> Connection`은 인자 없이 새 연결을 반환합니다.
|
|
594
|
+
위의 `create_connection` 같은 함수나 람다도 그대로 전달할 수 있으며,
|
|
595
|
+
클래스로 구현할 때는 `BrokerFactory`를 상속하고 `__call__`을 구현할 수 있습니다.
|
|
596
|
+
|
|
577
597
|
## 브로커 선택과 운영 주의사항
|
|
578
598
|
|
|
579
599
|
| 기능 | RabbitMQ | Redis Streams |
|
|
@@ -14,6 +14,10 @@ issues/feature/1/README.md
|
|
|
14
14
|
issues/feature/1/REQUIREMENTS.md
|
|
15
15
|
issues/feature/1/TASK.md
|
|
16
16
|
issues/feature/1/ci.refs.json
|
|
17
|
+
issues/fix/3/IMPLEMENTS.md
|
|
18
|
+
issues/fix/3/README.md
|
|
19
|
+
issues/fix/3/REQUIREMENTS.md
|
|
20
|
+
issues/fix/3/ci.refs.json
|
|
17
21
|
sample/Broker/Sample.py
|
|
18
22
|
sample/Worker/Sample.py
|
|
19
23
|
sample/Worker/RabbitMQ/Client.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: DefStream
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Synchronous message processing with pluggable broker adapters
|
|
5
5
|
Home-page: https://github.com/yong5eon/DefStream
|
|
6
6
|
Author: Heo Yongseon
|
|
@@ -124,6 +124,11 @@ class Add(
|
|
|
124
124
|
|
|
125
125
|
### 2. Worker 실행: `worker.py`
|
|
126
126
|
|
|
127
|
+
`Worker`는 `DefStream.Broker.Connection`을 직접 받습니다.
|
|
128
|
+
연결 계약은 `connect()`, `close()`만 요구하며, 워커 실행 시 내부에서
|
|
129
|
+
`GetConsumer` 지원 여부를 검사합니다. 컨슈머를 생성할 수 없는 브로커는 `TypeError`를 발생시키며,
|
|
130
|
+
워커 전용 연결 타입은 필요하지 않습니다.
|
|
131
|
+
|
|
127
132
|
```python
|
|
128
133
|
from signal import SIGINT, signal
|
|
129
134
|
|
|
@@ -176,7 +181,7 @@ Worker가 실행 중인 상태에서 다른 터미널에서 실행하세요.
|
|
|
176
181
|
|
|
177
182
|
```python
|
|
178
183
|
from DefStream.Broker.Implements.RabbitMQ import Configuration, Connection
|
|
179
|
-
from DefStream.Worker import
|
|
184
|
+
from DefStream.Worker import emit, request
|
|
180
185
|
from tasks import Add
|
|
181
186
|
|
|
182
187
|
|
|
@@ -188,7 +193,7 @@ connection = Connection(Configuration(
|
|
|
188
193
|
))
|
|
189
194
|
try:
|
|
190
195
|
connection.connect()
|
|
191
|
-
message_id =
|
|
196
|
+
message_id = emit(
|
|
192
197
|
{'a': 10, 'b': 20},
|
|
193
198
|
task=Add,
|
|
194
199
|
broker=connection,
|
|
@@ -209,7 +214,7 @@ finally:
|
|
|
209
214
|
python client.py
|
|
210
215
|
```
|
|
211
216
|
|
|
212
|
-
`
|
|
217
|
+
`emit()`와 `request()`는 **각각 별도의 작업을 발행**합니다. 위 예제는 덧셈을 두 번 실행하며,
|
|
213
218
|
`request()`의 결과는 `30`입니다. `request()`의 제한 시간은 초 단위이고,
|
|
214
219
|
시간이 초과되어도 이미 전달된 작업은 취소되지 않습니다.
|
|
215
220
|
|
|
@@ -220,14 +225,20 @@ python client.py
|
|
|
220
225
|
| 함수 | 역할 | 연결 관리 |
|
|
221
226
|
| --- | --- | --- |
|
|
222
227
|
| `declare(task=..., broker=...)` | 작업의 큐·구독 리소스 선언 | 호출자가 연결·종료 |
|
|
223
|
-
| `
|
|
228
|
+
| `emit(body, task=..., broker=...)` | 작업 목적지로 단방향 메시지 발행 | 호출자가 연결·종료 |
|
|
224
229
|
| `request(body, task=..., broker=..., timeout=5)` | 작업 결과를 동기 RPC로 요청 | 호출자가 연결·종료; RabbitMQ만 지원 |
|
|
225
230
|
|
|
226
231
|
세 함수는 `DefStream.Worker`에서 가져옵니다. 전달된 연결을 자동으로 열거나 닫지 않으며,
|
|
227
|
-
`
|
|
232
|
+
`emit()`와 `request()`는 목적지를 자동 선언하지 않습니다.
|
|
228
233
|
수신 Worker 또는 별도의 준비 단계에서 먼저 `declare()`를 호출하세요.
|
|
229
234
|
하나의 연결을 같은 소유 스레드에서 여러 발행에 재사용할 수 있습니다.
|
|
230
235
|
|
|
236
|
+
세 함수 모두 공통 `Connection`을 받고, 내부에서 선언·발행·RPC 지원 여부를 확인합니다.
|
|
237
|
+
지원하지 않는 기능은 `NotImplementedError`로 실패합니다.
|
|
238
|
+
기존 작업 발행 함수와 연결의 `send`는 `emit`으로 이름이 바뀌었습니다.
|
|
239
|
+
사용자 정의 브로커의 작업 발행 계약도 `TaskSender.send` 대신 `Emittable.emit`을 사용하세요.
|
|
240
|
+
큐·Exchange·Stream의 저수준 `Sendable.send()`와 RPC `Callable.call()`은 그대로입니다.
|
|
241
|
+
|
|
231
242
|
작업 본문은 **문자열 키를 가진 매핑**이어야 하며, 반환값은 어댑터가 직렬화할 수 있어야 합니다.
|
|
232
243
|
하나의 Worker에서는 같은 큐에 여러 작업을 중복 등록할 수 없습니다.
|
|
233
244
|
메시지 유형을 보고 여러 `Run` 중 하나를 고르는 방식이 아니라 큐별로 작업을 선택합니다.
|
|
@@ -245,7 +256,7 @@ from DefStream.Worker import (
|
|
|
245
256
|
Run,
|
|
246
257
|
declare,
|
|
247
258
|
request,
|
|
248
|
-
|
|
259
|
+
emit,
|
|
249
260
|
)
|
|
250
261
|
|
|
251
262
|
|
|
@@ -270,7 +281,7 @@ declare(
|
|
|
270
281
|
task=Add,
|
|
271
282
|
broker=broker,
|
|
272
283
|
)
|
|
273
|
-
|
|
284
|
+
emit(
|
|
274
285
|
{'a': 10, 'b': 20},
|
|
275
286
|
task=Add,
|
|
276
287
|
broker=broker,
|
|
@@ -310,6 +321,10 @@ result = request(
|
|
|
310
321
|
브로커 리소스를 직접 사용할 때의 공통 메서드는 다음과 같습니다.
|
|
311
322
|
모든 리소스가 모든 메서드를 지원하는 것은 아닙니다.
|
|
312
323
|
|
|
324
|
+
연결의 `exchange()`·`queue()`·`stream()`·`consumer()` 지원 여부는 각각
|
|
325
|
+
`GetExchange`·`GetQueue`·`GetStream`·`GetConsumer`로 `isinstance` 또는 `issubclass`
|
|
326
|
+
검사할 수 있습니다. 이 계약들은 `DefStream.Broker`에서 가져옵니다.
|
|
327
|
+
|
|
313
328
|
| 메서드 | 의미 | 제한 시간 단위 |
|
|
314
329
|
| --- | --- | --- |
|
|
315
330
|
| `send(body)` | 메시지 발행 | 어댑터별 설정 |
|
|
@@ -574,6 +589,11 @@ inspector = Inspector(
|
|
|
574
589
|
Inspector 자체는 TLS를 제공하지 않으며 공개 웹 서버가 아닙니다.
|
|
575
590
|
콘솔의 연결 팩터리는 호출마다 새 연결을 반환해야 하고 Worker 연결을 공유하면 안 됩니다.
|
|
576
591
|
|
|
592
|
+
Console의 `broker` 인자는 `DefStream.Broker.BrokerFactory` 계약을 사용합니다.
|
|
593
|
+
이 계약의 `__call__() -> Connection`은 인자 없이 새 연결을 반환합니다.
|
|
594
|
+
위의 `create_connection` 같은 함수나 람다도 그대로 전달할 수 있으며,
|
|
595
|
+
클래스로 구현할 때는 `BrokerFactory`를 상속하고 `__call__`을 구현할 수 있습니다.
|
|
596
|
+
|
|
577
597
|
## 브로커 선택과 운영 주의사항
|
|
578
598
|
|
|
579
599
|
| 기능 | RabbitMQ | Redis Streams |
|
|
@@ -93,6 +93,11 @@ declares an error queue to receive rejected messages.
|
|
|
93
93
|
|
|
94
94
|
### 2. Run the Worker: `worker.py`
|
|
95
95
|
|
|
96
|
+
`Worker` accepts `DefStream.Broker.Connection` directly.
|
|
97
|
+
The connection contract only requires `connect()` and `close()`. The worker checks
|
|
98
|
+
for `GetConsumer` support internally when it runs. A broker that cannot create
|
|
99
|
+
a consumer raises `TypeError`; no worker-specific connection type is needed.
|
|
100
|
+
|
|
96
101
|
```python
|
|
97
102
|
from signal import SIGINT, signal
|
|
98
103
|
|
|
@@ -146,7 +151,7 @@ Run this in another terminal while the Worker is running.
|
|
|
146
151
|
|
|
147
152
|
```python
|
|
148
153
|
from DefStream.Broker.Implements.RabbitMQ import Configuration, Connection
|
|
149
|
-
from DefStream.Worker import
|
|
154
|
+
from DefStream.Worker import emit, request
|
|
150
155
|
from tasks import Add
|
|
151
156
|
|
|
152
157
|
|
|
@@ -158,7 +163,7 @@ connection = Connection(Configuration(
|
|
|
158
163
|
))
|
|
159
164
|
try:
|
|
160
165
|
connection.connect()
|
|
161
|
-
message_id =
|
|
166
|
+
message_id = emit(
|
|
162
167
|
{'a': 10, 'b': 20},
|
|
163
168
|
task=Add,
|
|
164
169
|
broker=connection,
|
|
@@ -179,7 +184,7 @@ finally:
|
|
|
179
184
|
python client.py
|
|
180
185
|
```
|
|
181
186
|
|
|
182
|
-
`
|
|
187
|
+
`emit()` and `request()` **each publish a separate task**. This example performs
|
|
183
188
|
the addition twice; `request()` returns `30`. The request timeout is in seconds
|
|
184
189
|
and does not cancel work that has already been delivered.
|
|
185
190
|
|
|
@@ -190,14 +195,21 @@ and does not cancel work that has already been delivered.
|
|
|
190
195
|
| Function | Purpose | Connection ownership |
|
|
191
196
|
| --- | --- | --- |
|
|
192
197
|
| `declare(task=..., broker=...)` | Declare task queues and subscription resources | Caller connects and closes |
|
|
193
|
-
| `
|
|
198
|
+
| `emit(body, task=..., broker=...)` | Publish a one-way message to a task | Caller connects and closes |
|
|
194
199
|
| `request(body, task=..., broker=..., timeout=5)` | Request a task result synchronously | Caller connects and closes; RabbitMQ only |
|
|
195
200
|
|
|
196
201
|
Import these functions from `DefStream.Worker`. They do not connect or close
|
|
197
|
-
the supplied connection. Neither `
|
|
202
|
+
the supplied connection. Neither `emit()` nor `request()` declares destinations.
|
|
198
203
|
Call `declare()` in the receiving Worker's setup or a separate provisioning step.
|
|
199
204
|
Reuse a connection for multiple publications on its owning thread.
|
|
200
205
|
|
|
206
|
+
All three helpers accept the common `Connection` type and check declaration,
|
|
207
|
+
emission, or RPC support internally. Unsupported operations raise `NotImplementedError`.
|
|
208
|
+
The task helper and connection method previously named `send` are now named `emit`.
|
|
209
|
+
Custom brokers should use `Emittable.emit` instead of `TaskSender.send` for task emission.
|
|
210
|
+
Low-level `Sendable.send()` and RPC `Callable.call()` on queues, exchanges, and streams
|
|
211
|
+
remain unchanged.
|
|
212
|
+
|
|
201
213
|
Task bodies must be **mappings with string keys**. Return values must be
|
|
202
214
|
serializable by the adapter. A Worker cannot register multiple tasks for the
|
|
203
215
|
same queue: routing selects tasks by queue, not by a type field in the message.
|
|
@@ -215,7 +227,7 @@ from DefStream.Worker import (
|
|
|
215
227
|
Run,
|
|
216
228
|
declare,
|
|
217
229
|
request,
|
|
218
|
-
|
|
230
|
+
emit,
|
|
219
231
|
)
|
|
220
232
|
|
|
221
233
|
|
|
@@ -240,7 +252,7 @@ declare(
|
|
|
240
252
|
task=Add,
|
|
241
253
|
broker=broker,
|
|
242
254
|
)
|
|
243
|
-
|
|
255
|
+
emit(
|
|
244
256
|
{'a': 10, 'b': 20},
|
|
245
257
|
task=Add,
|
|
246
258
|
broker=broker,
|
|
@@ -282,6 +294,10 @@ result = request(
|
|
|
282
294
|
The common resource operations below apply when accessing a broker directly.
|
|
283
295
|
Not every resource supports every operation.
|
|
284
296
|
|
|
297
|
+
Use `isinstance` or `issubclass` with `GetExchange`, `GetQueue`, `GetStream`,
|
|
298
|
+
or `GetConsumer` to check whether a connection provides `exchange()`, `queue()`,
|
|
299
|
+
`stream()`, or `consumer()`, respectively. Import these contracts from `DefStream.Broker`.
|
|
300
|
+
|
|
285
301
|
| Method | Purpose | Timeout unit |
|
|
286
302
|
| --- | --- | --- |
|
|
287
303
|
| `send(body)` | Publish a message | Adapter configuration |
|
|
@@ -556,6 +572,11 @@ Inspector has no built-in TLS and is not a public web server.
|
|
|
556
572
|
The console's connection factory must return a new connection on every call,
|
|
557
573
|
never the Worker's connection.
|
|
558
574
|
|
|
575
|
+
Console's `broker` parameter uses the `DefStream.Broker.BrokerFactory` contract.
|
|
576
|
+
Its `__call__() -> Connection` takes no arguments and returns a new connection.
|
|
577
|
+
Functions such as `create_connection` above and lambdas remain valid without changes.
|
|
578
|
+
For a class-based factory, you can inherit `BrokerFactory` and implement `__call__`.
|
|
579
|
+
|
|
559
580
|
## Broker selection and operational considerations
|
|
560
581
|
|
|
561
582
|
| Feature | RabbitMQ | Redis Streams |
|
|
@@ -91,6 +91,11 @@ class Add(
|
|
|
91
91
|
|
|
92
92
|
### 2. Worker 실행: `worker.py`
|
|
93
93
|
|
|
94
|
+
`Worker`는 `DefStream.Broker.Connection`을 직접 받습니다.
|
|
95
|
+
연결 계약은 `connect()`, `close()`만 요구하며, 워커 실행 시 내부에서
|
|
96
|
+
`GetConsumer` 지원 여부를 검사합니다. 컨슈머를 생성할 수 없는 브로커는 `TypeError`를 발생시키며,
|
|
97
|
+
워커 전용 연결 타입은 필요하지 않습니다.
|
|
98
|
+
|
|
94
99
|
```python
|
|
95
100
|
from signal import SIGINT, signal
|
|
96
101
|
|
|
@@ -143,7 +148,7 @@ Worker가 실행 중인 상태에서 다른 터미널에서 실행하세요.
|
|
|
143
148
|
|
|
144
149
|
```python
|
|
145
150
|
from DefStream.Broker.Implements.RabbitMQ import Configuration, Connection
|
|
146
|
-
from DefStream.Worker import
|
|
151
|
+
from DefStream.Worker import emit, request
|
|
147
152
|
from tasks import Add
|
|
148
153
|
|
|
149
154
|
|
|
@@ -155,7 +160,7 @@ connection = Connection(Configuration(
|
|
|
155
160
|
))
|
|
156
161
|
try:
|
|
157
162
|
connection.connect()
|
|
158
|
-
message_id =
|
|
163
|
+
message_id = emit(
|
|
159
164
|
{'a': 10, 'b': 20},
|
|
160
165
|
task=Add,
|
|
161
166
|
broker=connection,
|
|
@@ -176,7 +181,7 @@ finally:
|
|
|
176
181
|
python client.py
|
|
177
182
|
```
|
|
178
183
|
|
|
179
|
-
`
|
|
184
|
+
`emit()`와 `request()`는 **각각 별도의 작업을 발행**합니다. 위 예제는 덧셈을 두 번 실행하며,
|
|
180
185
|
`request()`의 결과는 `30`입니다. `request()`의 제한 시간은 초 단위이고,
|
|
181
186
|
시간이 초과되어도 이미 전달된 작업은 취소되지 않습니다.
|
|
182
187
|
|
|
@@ -187,14 +192,20 @@ python client.py
|
|
|
187
192
|
| 함수 | 역할 | 연결 관리 |
|
|
188
193
|
| --- | --- | --- |
|
|
189
194
|
| `declare(task=..., broker=...)` | 작업의 큐·구독 리소스 선언 | 호출자가 연결·종료 |
|
|
190
|
-
| `
|
|
195
|
+
| `emit(body, task=..., broker=...)` | 작업 목적지로 단방향 메시지 발행 | 호출자가 연결·종료 |
|
|
191
196
|
| `request(body, task=..., broker=..., timeout=5)` | 작업 결과를 동기 RPC로 요청 | 호출자가 연결·종료; RabbitMQ만 지원 |
|
|
192
197
|
|
|
193
198
|
세 함수는 `DefStream.Worker`에서 가져옵니다. 전달된 연결을 자동으로 열거나 닫지 않으며,
|
|
194
|
-
`
|
|
199
|
+
`emit()`와 `request()`는 목적지를 자동 선언하지 않습니다.
|
|
195
200
|
수신 Worker 또는 별도의 준비 단계에서 먼저 `declare()`를 호출하세요.
|
|
196
201
|
하나의 연결을 같은 소유 스레드에서 여러 발행에 재사용할 수 있습니다.
|
|
197
202
|
|
|
203
|
+
세 함수 모두 공통 `Connection`을 받고, 내부에서 선언·발행·RPC 지원 여부를 확인합니다.
|
|
204
|
+
지원하지 않는 기능은 `NotImplementedError`로 실패합니다.
|
|
205
|
+
기존 작업 발행 함수와 연결의 `send`는 `emit`으로 이름이 바뀌었습니다.
|
|
206
|
+
사용자 정의 브로커의 작업 발행 계약도 `TaskSender.send` 대신 `Emittable.emit`을 사용하세요.
|
|
207
|
+
큐·Exchange·Stream의 저수준 `Sendable.send()`와 RPC `Callable.call()`은 그대로입니다.
|
|
208
|
+
|
|
198
209
|
작업 본문은 **문자열 키를 가진 매핑**이어야 하며, 반환값은 어댑터가 직렬화할 수 있어야 합니다.
|
|
199
210
|
하나의 Worker에서는 같은 큐에 여러 작업을 중복 등록할 수 없습니다.
|
|
200
211
|
메시지 유형을 보고 여러 `Run` 중 하나를 고르는 방식이 아니라 큐별로 작업을 선택합니다.
|
|
@@ -212,7 +223,7 @@ from DefStream.Worker import (
|
|
|
212
223
|
Run,
|
|
213
224
|
declare,
|
|
214
225
|
request,
|
|
215
|
-
|
|
226
|
+
emit,
|
|
216
227
|
)
|
|
217
228
|
|
|
218
229
|
|
|
@@ -237,7 +248,7 @@ declare(
|
|
|
237
248
|
task=Add,
|
|
238
249
|
broker=broker,
|
|
239
250
|
)
|
|
240
|
-
|
|
251
|
+
emit(
|
|
241
252
|
{'a': 10, 'b': 20},
|
|
242
253
|
task=Add,
|
|
243
254
|
broker=broker,
|
|
@@ -277,6 +288,10 @@ result = request(
|
|
|
277
288
|
브로커 리소스를 직접 사용할 때의 공통 메서드는 다음과 같습니다.
|
|
278
289
|
모든 리소스가 모든 메서드를 지원하는 것은 아닙니다.
|
|
279
290
|
|
|
291
|
+
연결의 `exchange()`·`queue()`·`stream()`·`consumer()` 지원 여부는 각각
|
|
292
|
+
`GetExchange`·`GetQueue`·`GetStream`·`GetConsumer`로 `isinstance` 또는 `issubclass`
|
|
293
|
+
검사할 수 있습니다. 이 계약들은 `DefStream.Broker`에서 가져옵니다.
|
|
294
|
+
|
|
280
295
|
| 메서드 | 의미 | 제한 시간 단위 |
|
|
281
296
|
| --- | --- | --- |
|
|
282
297
|
| `send(body)` | 메시지 발행 | 어댑터별 설정 |
|
|
@@ -541,6 +556,11 @@ inspector = Inspector(
|
|
|
541
556
|
Inspector 자체는 TLS를 제공하지 않으며 공개 웹 서버가 아닙니다.
|
|
542
557
|
콘솔의 연결 팩터리는 호출마다 새 연결을 반환해야 하고 Worker 연결을 공유하면 안 됩니다.
|
|
543
558
|
|
|
559
|
+
Console의 `broker` 인자는 `DefStream.Broker.BrokerFactory` 계약을 사용합니다.
|
|
560
|
+
이 계약의 `__call__() -> Connection`은 인자 없이 새 연결을 반환합니다.
|
|
561
|
+
위의 `create_connection` 같은 함수나 람다도 그대로 전달할 수 있으며,
|
|
562
|
+
클래스로 구현할 때는 `BrokerFactory`를 상속하고 `__call__`을 구현할 수 있습니다.
|
|
563
|
+
|
|
544
564
|
## 브로커 선택과 운영 주의사항
|
|
545
565
|
|
|
546
566
|
| 기능 | RabbitMQ | Redis Streams |
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
## 변경 후 (TO-BE)
|
|
9
9
|
|
|
10
|
-
지원 브로커의 작업 구독 설정에 기본·최대 우선순위를 정의하고, `
|
|
10
|
+
지원 브로커의 작업 구독 설정에 기본·최대 우선순위를 정의하고, `emit`과 `request`에서
|
|
11
11
|
메시지별 우선순위를 재정의할 수 있습니다. 현재 지원 브로커는 RabbitMQ입니다.
|
|
12
12
|
|
|
13
13
|
## 사용 방법
|
|
@@ -20,7 +20,7 @@ RabbitMQ 작업의 `parameters`에 `Subscription(priority=2, max_priority=5, ...
|
|
|
20
20
|
from DefStream.Worker import (
|
|
21
21
|
declare,
|
|
22
22
|
request,
|
|
23
|
-
|
|
23
|
+
emit,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
|
|
@@ -31,7 +31,7 @@ declare(
|
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
# 호출값을 생략하면 작업 구독의 기본 우선순위를 사용합니다.
|
|
34
|
-
|
|
34
|
+
emit(
|
|
35
35
|
{'a': 1, 'b': 2},
|
|
36
36
|
task=Add,
|
|
37
37
|
broker=broker,
|