-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a job to allow backfilling of the elasticsearch index.
Also add monitoring for posts in elasticsearch to be able to detect the index from diverging.
- Loading branch information
1 parent
9bb8de9
commit 958a233
Showing
7 changed files
with
105 additions
and
10 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
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import logging | ||
from typing import Any, List | ||
|
||
from absl import flags | ||
from injector import Binder, Module, inject, singleton | ||
|
||
from rep0st.framework import app | ||
from rep0st.framework.execute import execute | ||
from rep0st.service.feature_service import FeatureService, FeatureServiceModule | ||
from rep0st.db.post import Type as PostType | ||
|
||
log = logging.getLogger(__name__) | ||
FLAGS = flags.FLAGS | ||
flags.DEFINE_enum_class( | ||
'rep0st_backfill_features_post_type', PostType.IMAGE, PostType, | ||
'The post type (image, video, ...) this job should index.') | ||
|
||
|
||
class BackfillFeaturesJobModule(Module): | ||
|
||
def configure(self, binder: Binder): | ||
binder.install(FeatureServiceModule) | ||
binder.bind(BackfillFeaturesJob) | ||
|
||
|
||
@singleton | ||
class BackfillFeaturesJob: | ||
feature_service: FeatureService | ||
|
||
@inject | ||
def __init__(self, feature_service: FeatureService): | ||
self.feature_service = feature_service | ||
|
||
@execute() | ||
def backfill_feature_job(self): | ||
self.feature_service.backfill_features( | ||
FLAGS.rep0st_backfill_features_post_type) | ||
|
||
|
||
def modules() -> List[Any]: | ||
return [BackfillFeaturesJobModule] | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(modules) |
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