mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-05-03 16:21:06 +00:00
fceb3cf39f
Build and push containers / metadata (push) Has been cancelled
Build and push containers / build-push-containers (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Test the built package works basically. (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been cancelled
ChangeDetection.io App Test / lint-code (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-10 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-11 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-12 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-13 (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/amd64 (alpine) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/arm64 (alpine) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/amd64 (main) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/arm/v7 (main) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/arm/v8 (main) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/arm64 (main) (push) Has been cancelled
101 lines
2.4 KiB
Python
101 lines
2.4 KiB
Python
"""
|
|
Base classes for the datastore.
|
|
|
|
This module defines the abstract interfaces that all datastore implementations must follow.
|
|
"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from threading import Lock
|
|
from loguru import logger
|
|
|
|
|
|
class DataStore(ABC):
|
|
"""
|
|
Abstract base class for all datastore implementations.
|
|
|
|
Defines the core interface that all datastores must implement for:
|
|
- Loading and saving data
|
|
- Managing watches
|
|
- Handling settings
|
|
- Providing data access
|
|
"""
|
|
|
|
lock = Lock()
|
|
datastore_path = None
|
|
|
|
@abstractmethod
|
|
def reload_state(self, datastore_path, include_default_watches, version_tag):
|
|
"""
|
|
Load data from persistent storage.
|
|
|
|
Args:
|
|
datastore_path: Path to the datastore directory
|
|
include_default_watches: Whether to create default watches if none exist
|
|
version_tag: Application version string
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def add_watch(self, url, **kwargs):
|
|
"""
|
|
Add a new watch.
|
|
|
|
Args:
|
|
url: URL to watch
|
|
**kwargs: Additional watch parameters
|
|
|
|
Returns:
|
|
UUID of the created watch
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def update_watch(self, uuid, update_obj):
|
|
"""
|
|
Update an existing watch.
|
|
|
|
Args:
|
|
uuid: Watch UUID
|
|
update_obj: Dictionary of fields to update
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def delete(self, uuid):
|
|
"""
|
|
Delete a watch.
|
|
|
|
Args:
|
|
uuid: Watch UUID to delete
|
|
"""
|
|
pass
|
|
|
|
@property
|
|
@abstractmethod
|
|
def data(self):
|
|
"""
|
|
Access to the underlying data structure.
|
|
|
|
Returns:
|
|
Dictionary containing all datastore data
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def force_save_all(self):
|
|
"""
|
|
Force immediate synchronous save of all data to storage.
|
|
|
|
This is the abstract method for forcing a complete save.
|
|
Different backends implement this differently:
|
|
- File backend: Mark all watches/settings dirty, then save
|
|
- Redis backend: SAVE command or pipeline flush
|
|
- SQL backend: COMMIT transaction
|
|
|
|
Used by:
|
|
- Backup creation (ensure everything is saved before backup)
|
|
- Shutdown (ensure all changes are persisted)
|
|
- Manual save operations
|
|
"""
|
|
pass
|