misc hub setup, testing live

pull/660/head
Ryan Barrett 2023-09-29 11:23:50 -07:00
rodzic f85ab9ef41
commit 318ba554d5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
5 zmienionych plików z 28 dodań i 7 usunięć

2
.gitignore vendored
Wyświetl plik

@ -1,3 +1,5 @@
*_token
*_jwt
.coverage
/.well-known/acme-challenge/
datastore.dat*

Wyświetl plik

@ -29,7 +29,6 @@ from common import (
USER_AGENT,
)
import flask_app
import hub
from models import Object, PROTOCOLS, Target, User
from protocol import Protocol
@ -299,7 +298,7 @@ class ATProto(User, Protocol):
return bluesky.from_as1(obj.as1), {'Content-Type': 'application/json'}
@hub.app.get('/_ah/queue/atproto-poll-notifs')
# URL route is registered in hub.py
def poll_notifications():
"""Fetches and enqueueus new activities from the AppView for our users.

20
hub.py
Wyświetl plik

@ -4,6 +4,7 @@ import json
import logging
import os
from pathlib import Path
from threading import Timer
import arroba.server
from arroba.datastore_storage import DatastoreStorage
@ -11,6 +12,7 @@ from arroba.util import service_jwt
from arroba import xrpc_sync
from flask import Flask, request
import google.cloud.logging
import lexrpc.client
import lexrpc.server
import lexrpc.flask_server
from oauth_dropins.webutil import (
@ -59,10 +61,13 @@ def health_check():
#
# XRPC server
# XRPC server, other URL routes
#
lexrpc.flask_server.init_flask(arroba.server.server, app)
app.add_url_rule('/_ah/queue/atproto-poll-notifs',
view_func=atproto.poll_notifications,
methods=['POST'])
@app.post('/_ah/queue/atproto-commit')
def atproto_commit():
@ -72,3 +77,16 @@ def atproto_commit():
"""
xrpc_sync.send_new_commits()
return 'OK'
# send requestCrawl to BGS
# delay because we're not up and serving XRPCs at this point yet. not sure why not.
if 'GAE_INSTANCE' in os.environ: # prod
def request_crawl():
bgs = lexrpc.client.Client(f'https://{os.environ["BGS_HOST"]}',
headers={'User-Agent': USER_AGENT})
resp = bgs.com.atproto.sync.requestCrawl({'hostname': os.environ['PDS_HOST']})
logger.info(resp)
Timer(15, request_crawl).start()
logger.info('Will send BGS requestCrawl in 15s')

Wyświetl plik

@ -9,10 +9,12 @@ env: flex
runtime: python
runtime_config:
operating_system: ubuntu22
runtime_version: "3.10"
runtime_version: "3.11"
network:
instance_ip_mode: internal
# can't do this because Bluesky BGS needs to be able to connect externally over
# websocket for subscribeRepos
# network:
# instance_ip_mode: internal
# need only one instance so that new commits can be delivered to subscribeRepos
# subscribers in memory

Wyświetl plik

@ -478,7 +478,7 @@ class ATProtoTest(TestCase):
]
client = app.test_client()
resp = client.get('/_ah/queue/atproto-poll-notifs')
resp = client.post('/_ah/queue/atproto-poll-notifs')
self.assertEqual(200, resp.status_code)
expected_list_notifs = call(