Static factory for creating the four standard FMQ queues: 1. q_a2e: api server --> engine 2. q_e2w: engine --> worker 3. q_w2e: worker --> engine 4. q_e2a: engine --> api server API Server: q_a2e producer / q_e2a consumer Engine: q_a2e consumer / q_e2w pr
| 18 | |
| 19 | |
| 20 | class FMQFactory: |
| 21 | """ |
| 22 | Static factory for creating the four standard FMQ queues: |
| 23 | 1. q_a2e: api server --> engine |
| 24 | 2. q_e2w: engine --> worker |
| 25 | 3. q_w2e: worker --> engine |
| 26 | 4. q_e2a: engine --> api server |
| 27 | API Server: q_a2e producer / q_e2a consumer |
| 28 | Engine: q_a2e consumer / q_e2w producer / q_w2e consumer / q_e2a producer |
| 29 | Worker: q_e2w consumer / q_w2e producer |
| 30 | """ |
| 31 | |
| 32 | _fmq = FMQ() |
| 33 | |
| 34 | # ------------------------------ |
| 35 | # API → Engine |
| 36 | # ------------------------------ |
| 37 | @classmethod |
| 38 | def q_a2e_producer(cls): |
| 39 | return cls._fmq.queue("q_a2e", role="producer") |
| 40 | |
| 41 | @classmethod |
| 42 | def q_a2e_consumer(cls): |
| 43 | return cls._fmq.queue("q_a2e", role="consumer") |
| 44 | |
| 45 | # ------------------------------ |
| 46 | # Engine → Worker |
| 47 | # ------------------------------ |
| 48 | @classmethod |
| 49 | def q_e2w_producer(cls): |
| 50 | return cls._fmq.queue("q_e2w", role="producer") |
| 51 | |
| 52 | @classmethod |
| 53 | def q_e2w_consumer(cls): |
| 54 | return cls._fmq.queue("q_e2w", role="consumer") |
| 55 | |
| 56 | # ------------------------------ |
| 57 | # Worker → Engine |
| 58 | # ------------------------------ |
| 59 | @classmethod |
| 60 | def q_w2e_producer(cls): |
| 61 | return cls._fmq.queue("q_w2e", role="producer") |
| 62 | |
| 63 | @classmethod |
| 64 | def q_w2e_consumer(cls): |
| 65 | return cls._fmq.queue("q_w2e", role="consumer") |
| 66 | |
| 67 | # ------------------------------ |
| 68 | # Engine → API |
| 69 | # ------------------------------ |
| 70 | @classmethod |
| 71 | def q_e2a_producer(cls): |
| 72 | return cls._fmq.queue("q_e2a", role="producer") |
| 73 | |
| 74 | @classmethod |
| 75 | def q_e2a_consumer(cls): |
| 76 | return cls._fmq.queue("q_e2a", role="consumer") |
| 77 |