Initial Source code version
This commit is contained in:
parent
90f5f38812
commit
d979374cbc
23 changed files with 2628 additions and 0 deletions
24
app/workers/mail_mx_worker.py
Normal file
24
app/workers/mail_mx_worker.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import asyncio
|
||||
from app.workers.base_worker import BaseWorker
|
||||
from app.job_registry import routing_key
|
||||
from app.workers.utils import resolve_mx
|
||||
|
||||
class MXValidationWorker(BaseWorker):
|
||||
async def process(self, payload: dict, **meta) -> dict:
|
||||
domain = payload.get("domain")
|
||||
if not domain:
|
||||
raise ValueError("payload.domain is required")
|
||||
mx = await resolve_mx(domain)
|
||||
await asyncio.sleep(0)
|
||||
return {
|
||||
"mx_records": [{"exchange": m.exchange, "preference": m.preference} for m in mx],
|
||||
"count": len(mx),
|
||||
}
|
||||
|
||||
async def main():
|
||||
worker = MXValidationWorker(routing_key("MailCheck", "MXValidation"), worker_id="mx-worker-1")
|
||||
await worker.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
import asyncio as _a
|
||||
_a.run(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue