-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathworker.py
More file actions
19 lines (15 loc) · 716 Bytes
/
worker.py
File metadata and controls
19 lines (15 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import asyncio
from waitress import serve
from config import MIGRATION_PATH, DB_CONN, CACHE_CONN
from reactive_cache import migration, consumer, client, repository
if __name__ == '__main__':
print("starting worker...")
migration.run(DB_CONN, MIGRATION_PATH)
postgres_conn = client.Postgres(DB_CONN).get_connection()
redis_conn = client.Redis(CACHE_CONN).get_connection()
repo = repository.Repository(postgres_conn, redis_conn)
profile_change_consumer = consumer.ProfileChange(postgres_conn)
# run a postgres' notify consumer
loop = asyncio.get_event_loop()
loop.add_reader(postgres_conn, profile_change_consumer.subscribe, repo.store_profile_cache)
loop.run_forever()