Skip to content

Gossiper

Latest

Choose a tag to compare

@Hyromy Hyromy released this 02 May 22:37
· 1 commit to main since this release

Summary

This release introduces comprehensive real-time event broadcasting capabilities to the Lucy-API. The new Gossiper system enables all Guild CRUD operations to automatically publish events to Redis, allowing connected clients to receive live updates via Server-Sent Events (SSE). This establishes a solid foundation for reactive, event-driven architectures where multiple clients can stay synchronized on guild state changes.

Highlights

  • Event Broadcasting: Complete integration of Redis event publishing across all Guild operations (create, update, delete).
  • Real-Time Synchronization: Clients connected to the /api/events/ endpoint now receive instant notifications of guild changes.
  • Version Tracking: Automatic version incrementing on updates provides reliable change tracking and conflict detection capabilities.
  • Comprehensive Test Coverage: Added 4 new test cases covering event publication, payload structure, and custom source headers.

Added

  • Added perform_create() method to GuildViewSet to publish lucy.guild.created events when guilds are created.
  • Added perform_update() method to GuildViewSet with automatic version increment and lucy.guild.updated event publishing.
  • Added perform_destroy() method to GuildViewSet to publish lucy.guild.deleted events before deletion.
  • Added test_create_guild_publishes_event() to verify creation events with correct payload structure.
  • Added test_update_guild_publishes_event_with_version() to verify update events include incremented version numbers.
  • Added test_delete_guild_publishes_event() to verify deletion events are published before record removal.
  • Added test_redis_payload_includes_custom_source() to verify X-Source header capture in event metadata.

Changed

  • Refactored GuildViewSet to intercept all CRUD operations and inject Redis event broadcasting.
  • Updated test suite to include mocking of publish_on_redis for proper event verification.
  • Enhanced _redis_payload_keys() helper method usage across all perform methods for consistent event metadata.

Fixed

  • Fixed potential race conditions by ensuring Redis events are published before database changes are persisted (for destruction operations).
  • Fixed payload consistency by centralizing metadata generation through the _redis_payload_keys() method.

Breaking Changes

  • None. This release is fully backward compatible with existing API consumers.

Event Schema

All published events follow this structure:

{
  "event": "lucy.guild.{created|updated|deleted}",
  "version": 1,
  "updated_at": "2026-05-02T12:00:00Z",
  "source": "api request|X-Source header value",
  "id": "guild_id",
  "lang": { "code": "en", "name": "English" },
  "joined_at": "2026-05-02T12:00:00Z"
}

Deployment/Infra

  • No infrastructure changes required. Works with existing Redis configuration.
  • Event streaming is handled by existing /api/events/ endpoint via SSE.

Full Changelog

v0.2.0...v0.3.0