aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/tasks/consumer.py
blob: 0f735296616b00cb4972c46d1fa27d2ec360db56 (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
# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
#
# SPDX-License-Identifier: BSD-3-Clause

from huey import Huey, crontab

from .. import HUEY, create_app


def create_consumer() -> Huey:
    """
    Create and configure the Huey consumer.

    The application is initialized, task modules are imported to register their
    tasks, and the source scanner is registered with the configured periodic
    schedule.

    :return: Configured Huey instance.
    """
    app = create_app()

    from . import receiver, scanner, sender  # noqa: F401

    schedule = crontab(
        *app.config["WEBMENTIONS_SSG_SCANNER_SCHEDULE"].split(), strict=True
    )
    HUEY.periodic_task(schedule)(scanner.scan_sources)

    return HUEY.huey


huey = create_consumer()