ATProto firehose: load bridged dids from AtpRepo instead of users

hopefully cuts down on datastore load a bit

for #978
in-reply-to-bridged
Ryan Barrett 2024-05-10 11:31:47 -07:00
rodzic 0fc971724d
commit 6bc9269ad0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 5 dodań i 10 usunięć

Wyświetl plik

@ -9,6 +9,7 @@ from queue import SimpleQueue
from threading import Event, Lock, Thread, Timer
import time
from arroba.datastore_storage import AtpRepo
from carbox import read_car
import dag_json
from google.cloud import ndb
@ -21,7 +22,6 @@ from oauth_dropins.webutil.util import json_loads
from atproto import ATProto, Cursor
from common import add, create_task, report_exception
import models
from models import Object
RECONNECT_DELAY = timedelta(seconds=30)
@ -64,12 +64,8 @@ def _load_dids():
atproto_dids = frozenset(key.id() for key in
ATProto.query(ATProto.enabled_protocols != None
).iter(keys_only=True))
others_queries = itertools.chain(*(
cls.query(cls.copies.protocol == 'atproto').iter()
for cls in set(models.PROTOCOLS.values())
if cls and cls != ATProto))
bridged_dids = frozenset(user.get_copy(ATProto) for user in others_queries)
bridged_dids = frozenset(key.id() for key in
AtpRepo.query().iter(keys_only=True))
dids_initialized.set()
logger.info(f'Loaded {len(atproto_dids)} ATProto, {len(bridged_dids)} bridged dids')

Wyświetl plik

@ -4,6 +4,7 @@ from datetime import timedelta, timezone
from unittest import skip
from unittest.mock import patch
from arroba.datastore_storage import AtpRepo
import arroba.util
from carbox import read_car, write_car
from carbox.car import Block
@ -97,9 +98,7 @@ class ATProtoFirehoseSubscribeTest(TestCase):
atproto_firehose.bridged_dids = None
atproto_firehose.dids_initialized.clear()
self.alice = self.make_user(
'eefake:alice', cls=ExplicitEnableFake,
copies=[Target(protocol='atproto', uri='did:alice')])
AtpRepo(id='did:alice', head='', signing_key_pem=b'').put()
def assert_enqueues(self, record=None, repo='did:plc:user', action='create',
path='app.bsky.feed.post/abc123'):