distro-tools/apollo/rhworker/__main__.py
2023-02-01 22:37:16 +01:00

52 lines
1.0 KiB
Python

"""
Apollo RH Temporal Worker
This worker only executes tasks that are related to Red Hat.
"""
import asyncio
from temporalio.worker import Worker
import click
from common.database import Database
from common.info import Info
from common.logger import Logger
from common.temporal import Temporal
from apollo.rhworker.temporal import TASK_QUEUE
from apollo.rhworker.poll_rh_workflow import PollRHAdvisoriesWorkflow
from apollo.rhworker.poll_rh_activities import get_last_indexed_date, get_rh_advisories
async def run():
db = Database(True)
await db.init(["apollo.db"])
temporal = Temporal(True)
await temporal.connect()
worker = Worker(
temporal.client,
task_queue=TASK_QUEUE,
workflows=[
PollRHAdvisoriesWorkflow,
],
activities=[
get_last_indexed_date,
get_rh_advisories,
]
)
await worker.run()
@click.command()
def main():
Info("apollorhworker", "apollo2")
Logger()
asyncio.run(run())
if __name__ == "__main__":
main()