refactor(store): extract shared AbstractEventStore and registry utilities - #220
refactor(store): extract shared AbstractEventStore and registry utilities#220devin-ai-integration[bot] wants to merge 2 commits into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Test run: store integration tests (Devin)Full Channel-name / default-mode invariants (all 7 backends unchanged)Temporary reflection test over Matches pre-refactor naming/modes exactly. Flakes (14) — likely environmentalAll were "clients failed to join room within timeout" in Hazelcast/Kafka/NATS distributed tests and passed on retry. Session: https://app.devin.ai/sessions/78bf7322d0ff4d139f1f0c157954bfad |
Description
The seven broker backed
EventStoreimplementations each re-implemented the same boilerplate: nullablenodeId/eventStoreMode/prefix defaulting,SINGLE_CHANNELchannel-name resolution,modevalidation, self-message filtering, theEventType -> Queue<registrationId>+registrationId -> handlebookkeeping with its identical unsubscribe loop, theArrays.stream(EventType.values()).forEach(this::unsubscribe)shutdown, and the uncheckedListenerRegistrationdispatch loop. This PR moves all of it into three shared types understore.event, so the concrete stores only contain broker-specific code. Net −540/+353 lines with no behavior change.AbstractEventStore(base class for all remote stores):SubscriptionRegistry<I, S>replaces the two ad-hoc maps in the pub/sub stores, so e.g. Redis pub/sub becomes:ListenerRegistryholds the localListenerRegistrationqueues for the poll based stores (Kafka, Redis Stream) and owns the single remaining unchecked cast used to dispatch a message to typed listeners.Per-store defaults are preserved by passing them to
super(...): Redis pub/sub and NATS keep an empty prefix, Hazelcast (both) and Redis reliable/stream keep"SOCKETIO4J:", Kafka keeps"SOCKETIO4J-", and Redis Stream keepsSINGLE_CHANNELas its default mode while everything else keepsMULTI_CHANNEL.Type of Change
Related Issue
N/A
Changes Made
store/event/AbstractEventStore.java,store/event/SubscriptionRegistry.java,store/event/ListenerRegistry.javaRedisPubSubEventStore,RedisPubSubReliableEventStore,RedisStreamEventStore,NatsEventStore,HazelcastPubSubEventStore,HazelcastPubSubRingBufferEventStoreandKafkaEventStoreto extendAbstractEventStoreand use the shared registriesgetStreamName/getSubjectName/getTopicName/topic,resolve,validateSubscribe,getEventStoreModeand the duplicated unsubscribe/shutdown/dispatch loopsTesting
mvn test—mvn -pl netty-socketio-core verify(compile + checkstyle + license) passes; the store integration tests are Testcontainers based and are exercised by CIChecklist
Additional Notes
No public API changed: constructors, builders and the
EventStoreSPI keep their existing signatures.Link to Devin session: https://app.devin.ai/sessions/78bf7322d0ff4d139f1f0c157954bfad
Requested by: @sanjomo