Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Simple Storage Component #6729

Merged
merged 1 commit into from
Jan 19, 2022
Merged

Conversation

drew2a
Copy link
Contributor

@drew2a drew2a commented Jan 17, 2022

This PR is a part of #6718. It introduces the Simple Storage Component.

The reason to introduce this component: in #6718 I need persistent storage for the last_processed_torrent_id that is used by TagComponent during rules processing.

Normal Tribler's approach is either to store values in SQL or to store values in separate files.

Examples

The SQL approach includes:

class MiscData(db.Entity):
"""
This binding is used to store all kinds of values, like DB version, counters, etc.
"""
name = orm.PrimaryKey(str)
value = orm.Optional(str)
return MiscData

With actual data:

db_version,13

The file approach includes using a single file like exitnode_cache.dat to store a small amount of persistent data.
Another example: sometimes Tribler uses the config file like persistent storage:


def set_libtorrent_proxy_settings(config: LibtorrentSettings, proxy_type, server=None, auth=None):

Solution

Instead of using multiple small files, or "config-like-a-storage" or SQL tables for nonSQL data, we can use the one single JSON storage which is more suitable for these needs.

Simple Storage

Simple Storage is object storage that stores data in JSON format and uses pydantic BaseModel class for defining models.

The writing procedure calls every 5 minutes as well as on shutdown.

Heavier alternatives:

@drew2a drew2a force-pushed the feature/simple_storage branch 2 times, most recently from 1158869 to 2d782d2 Compare January 18, 2022 10:03
@drew2a drew2a marked this pull request as ready for review January 18, 2022 10:10
@drew2a drew2a requested review from a team, xoriole and kozlovsky and removed request for a team and xoriole January 18, 2022 10:10
@drew2a drew2a force-pushed the feature/simple_storage branch 2 times, most recently from aea6f68 to 1d98bc2 Compare January 18, 2022 20:28
@drew2a drew2a requested a review from kozlovsky January 18, 2022 20:29
@drew2a drew2a force-pushed the feature/simple_storage branch 2 times, most recently from 2514fbe to 084d799 Compare January 19, 2022 10:28
@drew2a drew2a requested a review from kozlovsky January 19, 2022 11:12
@drew2a drew2a force-pushed the feature/simple_storage branch 2 times, most recently from 8c0f0c9 to 52f4f82 Compare January 19, 2022 11:34
@sonarcloud
Copy link

sonarcloud bot commented Jan 19, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@drew2a drew2a merged commit 7d6cf40 into Tribler:main Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants