Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/interface.py
# Copyright (C) 2015-2020 The Software Heritage developers | # Copyright (C) 2015-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from typing import Any, Dict, Optional | from typing import Any, Dict, Iterable, List, Optional | ||||
from swh.core.api import remote_api_endpoint | from swh.core.api import remote_api_endpoint | ||||
from swh.scheduler.model import Lister | from swh.scheduler.model import ListedOrigin, Lister | ||||
class SchedulerInterface: | class SchedulerInterface: | ||||
@remote_api_endpoint("task_type/create") | @remote_api_endpoint("task_type/create") | ||||
def create_task_type(self, task_type): | def create_task_type(self, task_type): | ||||
"""Create a new task type ready for scheduling. | """Create a new task type ready for scheduling. | ||||
Args: | Args: | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | def update_lister(self, lister: Lister) -> Lister: | ||||
a new Lister object, with all fields updated from the database | a new Lister object, with all fields updated from the database | ||||
Raises: | Raises: | ||||
StaleData if the `updated` timestamp for the lister instance in | StaleData if the `updated` timestamp for the lister instance in | ||||
database doesn't match the one passed by the user. | database doesn't match the one passed by the user. | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("origins/record") | |||||
def record_listed_origins( | |||||
self, listed_origins: Iterable[ListedOrigin] | |||||
) -> List[ListedOrigin]: | |||||
"""Record a set of origins that a lister has listed. | |||||
This performs an "upsert": origins with the same (lister_id, url, | |||||
visit_type) values are updated with new values for | |||||
extra_loader_arguments, last_update and last_seen. | |||||
""" | |||||
... | |||||
@remote_api_endpoint("priority_ratios/get") | @remote_api_endpoint("priority_ratios/get") | ||||
def get_priority_ratios(self): | def get_priority_ratios(self): | ||||
... | ... |