Now-playing publisher and worker task (phase 4, step 3)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 11s
CI / federation-interop (push) Successful in 1m7s
CI / test (push) Successful in 3m15s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 11s
CI / federation-interop (push) Successful in 1m7s
CI / test (push) Successful in 3m15s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
publishing/now_playing.py: a periodic scan (federation.now_playing,
every 30s) that pushes a throttled Update(Person) for the profile
field (5 minutes) and, for users opted into posts, publishes a Note
after a track's been playing 30+ seconds (throttled to 30 minutes),
deleting the previous now-playing post once the new one is confirmed
published - not before, so a failed publish never leaves a user with
none showing. Reuses publishing.publish()/delete_post() unchanged;
now_playing is just another post kind.
Fixed a real bug before it ever ran against Postgres: the key
(artist/track/started_at) was going straight into federation_posts.key
(VARCHAR(64)), which routinely overflows for real track and artist
names. Hashed instead - it's an idempotency token, not something
anyone needs to read.
New metric scrobbler_federation_profile_updates_total{result}; posts
already get scrobbler_federation_posts_total{kind="now_playing",...}
for free from the existing publish() instrumentation.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
9ab8bd8e03
commit
ba30d5cb15
5 files changed
+382
-5
No files matched your search
@@ -40,7 +40,7 @@ def init_app(app: Flask) -> None:
|
||||
|
||||
from scrobbler import events, worker
|
||||
from scrobbler.federation import delivery, inbox
|
||||
from scrobbler.federation.publishing import milestones, weekly
|
||||
from scrobbler.federation.publishing import milestones, now_playing, weekly
|
||||
|
||||
worker.register_task(app, "federation.inbox", inbox.work_once)
|
||||
worker.register_task(app, "federation.deliver", delivery.work_once)
|
||||
@@ -48,6 +48,7 @@ def init_app(app: Flask) -> None:
|
||||
worker.register_periodic(app, "federation.inbox.maintenance", 300, inbox.maintenance)
|
||||
worker.register_periodic(app, "federation.gauges", 30, delivery.maintenance)
|
||||
worker.register_periodic(app, "federation.weekly", 900, weekly.check_all)
|
||||
worker.register_periodic(app, "federation.now_playing", 30, now_playing.check_all)
|
||||
|
||||
# blinker signals are process-wide, not per-app: once any app in a process enables
|
||||
# federation these stay connected for every app in it, including one built with
|
||||
|
||||
Reference in new issue
Block a user