-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Periodic (not instant) saving of the channel state
- Loading branch information
lavadk
committed
Apr 6, 2021
1 parent
4948835
commit 2ea41ad
Showing
5 changed files
with
23 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
from pathlib import Path | ||
from tengine.state.preserver import Preserver | ||
import inject | ||
from tengine.state.timed_preserver import TimedPreserver | ||
from tengine import Config | ||
|
||
from liker.state.reaction_hashes import ReactionHashes | ||
from liker.state.markup_queue import MarkupQueue | ||
from liker.state.markup_trail import MarkupTrail | ||
from liker.state.comment_trail import CommentTrail | ||
|
||
|
||
class ChannelState(Preserver): | ||
class ChannelState(TimedPreserver): | ||
config = inject.attr(Config) | ||
|
||
def __init__(self, state_dir: Path, str_channel_id: str): | ||
state_path = state_dir / f'{str_channel_id}.json' | ||
super().__init__(state_path) | ||
save_period = self.config['channel_state_save_seconds'] | ||
super().__init__(state_path, save_period=save_period) | ||
|
||
last_reactions_path = state_dir / f'{str_channel_id}_last_reactions.json' | ||
self.last_reactions = ReactionHashes(last_reactions_path) | ||
|
||
self.markup_queue = MarkupQueue(self.state) | ||
self.markup_trail = MarkupTrail(self.state) | ||
self.comment_trail = CommentTrail(self.state) | ||
|
||
def update(self): | ||
super().update() | ||
self.last_reactions.update() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule tengine
updated
from 436bc5 to 3ff826