Skip to content

Commit

Permalink
Added settings models for bg tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed Dec 5, 2024
1 parent 6437d14 commit 4e2d61c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions librarian_background/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def background(run_once: bool = False):
+ background_settings.check_consumed_queue
+ background_settings.outgoing_transfer_hypervisor
+ background_settings.incoming_transfer_hypervisor
+ background_settings.duplicate_remote_instance_hypervisor
+ background_settings.rolling_deletion
)

for task in all_tasks:
Expand Down
47 changes: 47 additions & 0 deletions librarian_background/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

from hera_librarian.deletion import DeletionPolicy
from librarian_background.hypervisor import (
DuplicateRemoteInstanceHypervisor,
IncomingTransferHypervisor,
OutgoingTransferHypervisor,
)
from librarian_background.rolling_deletion import RollingDeletion

from .check_integrity import CheckIntegrity
from .create_clone import CreateLocalClone
Expand Down Expand Up @@ -213,6 +215,46 @@ def task(self) -> IncomingTransferHypervisor:
)


class DuplicateRemoteInstanceHypervisorSettings(BackgroundTaskSettings):
"""
Settings for the duplicate instance hypervisor task.
"""

@property
def task(self) -> DuplicateRemoteInstanceHypervisor:
return DuplicateRemoteInstanceHypervisor(
name=self.task_name,
soft_timeout=self.soft_timeout,
)


class RollingDeletionSettings(BackgroundTaskSettings):
"""
Settings for the rolling deletion task
"""

store_name: str
age_in_days: float

number_of_remote_copies: int = 3
verify_downstream_checksums: bool = True
mark_unavailable: bool = True
force_deletion: bool = True

@property
def task(self) -> RollingDeletion:
return RollingDeletion(
name=self.task_name,
soft_timeout=self.soft_timeout,
store_name=self.store_name,
age_in_days=self.age_in_days,
number_of_remote_copies=self.number_of_remote_copies,
verify_downstream_checksums=self.verify_downstream_checksums,
mark_unavailable=self.mark_unavailable,
force_deletion=self.force_deletion,
)


class BackgroundSettings(BaseSettings):
"""
Background task settings, configurable.
Expand Down Expand Up @@ -240,6 +282,11 @@ class BackgroundSettings(BaseSettings):

outgoing_transfer_hypervisor: list[OutgoingTransferHypervisorSettings] = []
incoming_transfer_hypervisor: list[IncomingTransferHypervisorSettings] = []
duplicate_remote_instance_hypervisor: list[
DuplicateRemoteInstanceHypervisorSettings
] = []

rolling_deletion: list[RollingDeletionSettings] = []

# Global settings:

Expand Down

0 comments on commit 4e2d61c

Please sign in to comment.