Skip to content

Commit 21cc15b

Browse files
vanroguclaude
andauthored
Extract readUnbounded into separate UnboundedReadModelCapability interface (#25)
Move readUnbounded() methods out of ReadModelCapability into a dedicated UnboundedReadModelCapability interface so they are no longer exposed on BoundedContext by default. Dashboard code can opt in by extending the new interface in a custom bounded context type, leveraging the existing proxy mechanism. This keeps the public API clean for application developers. https://claude.ai/code/session_012D3mi7czkMEwKXYUvi7m2s Co-authored-by: Claude <noreply@anthropic.com>
1 parent 137da97 commit 21cc15b

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

sliceworkz-eventmodeling-api/src/main/java/org/sliceworkz/eventmodeling/readmodels/ReadModelCapability.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,4 @@ public interface ReadModelCapability<DOMAIN_EVENT_TYPE> {
2525

2626
<T> T read ( Class<? extends ReadModelWithMetaData<? extends DOMAIN_EVENT_TYPE>> readModelClass, Object... params );
2727

28-
// TODO how to hide these from other clients than the Dashboard?
29-
30-
<T> T readUnbounded ( Class<? extends ReadModelWithMetaData<? extends DOMAIN_EVENT_TYPE>> readModelClass, Tracing tracing, Object... params );
31-
32-
<T> T readUnbounded ( Class<? extends ReadModelWithMetaData<? extends DOMAIN_EVENT_TYPE>> readModelClass, Object... params );
33-
3428
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Sliceworkz Event Modeling - an opinionated Event Modeling framework in Java
3+
* Copyright © 2025 Sliceworkz / XTi (info@sliceworkz.org)
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
package org.sliceworkz.eventmodeling.readmodels;
19+
20+
import org.sliceworkz.eventmodeling.events.Tracing;
21+
22+
/**
23+
* Capability for reading models across all event streams, regardless of bounded context boundaries.
24+
* <p>
25+
* This is intended for internal dashboard and monitoring use only.
26+
* Application developers should use {@link ReadModelCapability#read} instead,
27+
* which scopes queries to the bounded context's own domain event stream.
28+
* <p>
29+
* To use this capability, define a custom bounded context interface that explicitly
30+
* extends this interface:
31+
* <pre>{@code
32+
* interface DashboardContext extends CQRSCapabilities<MyEvent>, UnboundedReadModelCapability<MyEvent> {}
33+
* }</pre>
34+
*/
35+
public interface UnboundedReadModelCapability<DOMAIN_EVENT_TYPE> {
36+
37+
<T> T readUnbounded ( Class<? extends ReadModelWithMetaData<? extends DOMAIN_EVENT_TYPE>> readModelClass, Tracing tracing, Object... params );
38+
39+
<T> T readUnbounded ( Class<? extends ReadModelWithMetaData<? extends DOMAIN_EVENT_TYPE>> readModelClass, Object... params );
40+
41+
}

sliceworkz-eventmodeling-impl/src/main/java/org/sliceworkz/eventmodeling/module/boundedcontext/BoundedContextImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.sliceworkz.eventmodeling.module.outbound.OutboundModule;
4242
import org.sliceworkz.eventmodeling.module.readmodels.ReadModelModule;
4343
import org.sliceworkz.eventmodeling.readmodels.ReadModelWithMetaData;
44+
import org.sliceworkz.eventmodeling.readmodels.UnboundedReadModelCapability;
4445
import org.sliceworkz.eventmodeling.slices.FeatureSliceConfiguration;
4546
import org.sliceworkz.eventstore.events.EphemeralEvent;
4647
import org.sliceworkz.eventstore.events.Event;
@@ -52,7 +53,7 @@
5253
import io.micrometer.core.instrument.Counter;
5354
import io.micrometer.core.instrument.MeterRegistry;
5455

55-
public class BoundedContextImpl<DOMAIN_EVENT_TYPE,INBOUND_EVENT_TYPE,OUTBOUND_EVENT_TYPE> implements AllCapabilities<DOMAIN_EVENT_TYPE, INBOUND_EVENT_TYPE, OUTBOUND_EVENT_TYPE>, ConsistentEventProcessor<DOMAIN_EVENT_TYPE> {
56+
public class BoundedContextImpl<DOMAIN_EVENT_TYPE,INBOUND_EVENT_TYPE,OUTBOUND_EVENT_TYPE> implements AllCapabilities<DOMAIN_EVENT_TYPE, INBOUND_EVENT_TYPE, OUTBOUND_EVENT_TYPE>, UnboundedReadModelCapability<DOMAIN_EVENT_TYPE>, ConsistentEventProcessor<DOMAIN_EVENT_TYPE> {
5657

5758
private static final Logger LOGGER = LoggerFactory.getLogger(BoundedContextImpl.class);
5859

0 commit comments

Comments
 (0)