blob: 047c01037dd7adc17a0d019ca3654063ee97ab34 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
#
# SPDX-License-Identifier: BSD-3-Clause
"""Configure the Huey worker and its scheduled background tasks."""
from huey import Huey, crontab
from .. import create_app, extensions
def create_consumer() -> Huey:
"""Create and configure the Huey consumer.
The application is initialized, task modules are imported to register their
tasks, and periodic scanner, notification and verification recovery tasks
are registered.
:return: Configured Huey instance.
"""
app = create_app()
from . import notifications, receiver, retention, scanner
schedule = crontab(*app.config["SCANNER_SCHEDULE"].split(), strict=True)
extensions.huey.periodic_task(schedule)(scanner.scan_sources)
recovery_schedule = crontab(
*app.config["VERIFICATION_REAPER_SCHEDULE"].split(), strict=True
)
extensions.huey.periodic_task(recovery_schedule)(receiver.recover_stale_webmentions)
notification_schedule = crontab(
*app.config["NOTIFICATION_SCHEDULE"].split(), strict=True
)
extensions.huey.periodic_task(notification_schedule)(
notifications.send_webmention_digest
)
retention_schedule = crontab(
*app.config["RECEIVED_RETENTION_SCHEDULE"].split(), strict=True
)
extensions.huey.periodic_task(retention_schedule)(
retention.purge_old_received_webmentions
)
return extensions.huey.huey
huey = create_consumer()
|