11import datetime as dt
22
33import msgspec
4-
4+ from ... import settings
55from ..base import BaseConfig
66
77# class Worker(Enum):
@@ -30,15 +30,46 @@ class WorkerBackendConfig(BaseConfig):
3030
3131
3232class APSDataStoreConfig (WorkerBackendConfig ):
33- type : str = msgspec .field (default_factory = lambda : "postgresql" )
34- host : str = msgspec .field (default_factory = lambda : "localhost" )
35- port : int = msgspec .field (default_factory = lambda : 5432 )
33+ type : str = msgspec .field (default = settings .FP_APS_WORKER_BACKEND_DS )
34+ host : str = msgspec .field (
35+ default = settings .BACKEND_PROPERTIES [settings .FP_APS_WORKER_BACKEND_DS ][
36+ "default_host"
37+ ]
38+ )
39+ port : int = msgspec .field (
40+ default = settings .BACKEND_PROPERTIES [settings .FP_APS_WORKER_BACKEND_DS ][
41+ "default_port"
42+ ]
43+ )
3644 schema : str | None = msgspec .field (default = "flowerpower" )
37- username : str = msgspec .field (default_factory = lambda : "postgres" )
45+ username : str = msgspec .field (
46+ default = settings .BACKEND_PROPERTIES [settings .FP_APS_WORKER_BACKEND_DS ][
47+ "default_username"
48+ ]
49+ )
3850
3951
4052class APSEventBrokerConfig (WorkerBackendConfig ):
41- from_ds_sqla : bool = msgspec .field (default = True )
53+ type : str = msgspec .field (default = settings .FP_APS_WORKER_BACKEND_EB )
54+ host : str = msgspec .field (
55+ default = settings .BACKEND_PROPERTIES [settings .FP_APS_WORKER_BACKEND_EB ][
56+ "default_host"
57+ ]
58+ )
59+ port : int = msgspec .field (
60+ default = settings .BACKEND_PROPERTIES [settings .FP_APS_WORKER_BACKEND_EB ][
61+ "default_port"
62+ ]
63+ )
64+ username : str = msgspec .field (
65+ default = settings .BACKEND_PROPERTIES [settings .FP_APS_WORKER_BACKEND_EB ][
66+ "default_username"
67+ ]
68+ )
69+ from_ds_sqla : bool = msgspec .field (
70+ default_factory = lambda : settings .FP_APS_WORKER_BACKEND_EB == "postgresql"
71+ and settings .FP_APS_WORKER_BACKEND_DS == "postgresql"
72+ )
4273
4374
4475class APSBackendConfig (BaseConfig ):
@@ -47,18 +78,33 @@ class APSBackendConfig(BaseConfig):
4778 default_factory = APSEventBrokerConfig
4879 )
4980 cleanup_interval : int | float | dt .timedelta = msgspec .field (
50- default = 300
81+ default = settings . FP_APS_WORKER_CLEANUP_INTERVAL
5182 ) # int in secods
52- max_concurrent_jobs : int = msgspec .field (default = 10 )
53- default_job_executor : str | None = msgspec .field (default = "threadpool" )
54- num_workers : int | None = msgspec .field (default = None )
83+ max_concurrent_jobs : int = msgspec .field (
84+ default = settings .FP_APS_WORKER_MAX_CONCURRENT_JOBS
85+ )
86+ default_job_executor : str | None = msgspec .field (
87+ default = settings .FP_EXECUTOR
88+ )
89+ num_workers : int | None = msgspec .field (
90+ default = settings .FP_EXECUTOR_NUM_CPUS
91+ )
5592
5693
5794class RQBackendConfig (WorkerBackendConfig ):
58- type : str = msgspec .field (default_factory = lambda : "redis" )
59- host : str = msgspec .field (default_factory = lambda : "localhost" )
60- port : int = msgspec .field (default_factory = lambda : 6379 )
61- queues : str | list [str ] = msgspec .field (default_factory = lambda : ["default" ])
95+ type : str = msgspec .field (default = "redis" )
96+ host : str = msgspec .field (
97+ default = settings .BACKEND_PROPERTIES ["redis" ]["default_host" ]
98+ )
99+ port : int = msgspec .field (
100+ default = settings .BACKEND_PROPERTIES ["redis" ]["default_port" ]
101+ )
102+ database : int = msgspec .field (
103+ default = settings .BACKEND_PROPERTIES ["redis" ]["default_database" ]
104+ )
105+ queues : str | list [str ] = msgspec .field (
106+ default_factory = lambda : ["low-prio" , "default" , "high-prio" ]
107+ )
62108
63109
64110class HueyBackendConfig (WorkerBackendConfig ):
0 commit comments