13m0n4de / scanner-demo

scanner demo, FastAPI + Dramatiq
0 stars 0 forks source link

StoredPipeline 使用 Redis 作为存储后端 #2

Closed 13m0n4de closed 1 year ago

13m0n4de commented 1 year ago

目前 StoredPipeline 是定义了一个全局 Dict 来存储 job_id => messages

app/utils/pipeline.py

EXTERNAL_JOB_STORE = {}

几乎照搬了 https://github.com/Bogdanp/dramatiq/issues/287 中的案例

计划将其改为 Redis 作为存储后端,与 ResultBackend 保持一致。

13m0n4de commented 1 year ago

已完成,见:

https://github.com/13m0n4de/fastapi-dramatiq-demo/blob/b5f7bba0350cb505a3bf13f83f819c208d7d652f/app/utils/pipeline.py#L1-L58

MessageData 的编解码使用自定义的 CustomJsonEncoder