Package com.onec.cluster
Class NoOpClusterEventBus
java.lang.Object
com.onec.cluster.NoOpClusterEventBus
- All Implemented Interfaces:
ClusterEventBus
Local-only
ClusterEventBus used when no cross-node transport is configured — a single-node
deployment, a non-Postgres (e.g. H2) datasource, or onec.cluster.enabled=false.
publish(com.onec.cluster.ClusterEvent) is inert (nothing leaves the JVM) and subscribe(java.util.function.Consumer<com.onec.cluster.ClusterEvent>) never fires (no remote
events ever arrive), so wiring it changes nothing: the local SSE fan-out on the change path is the
whole story, exactly as before this bus existed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this bus actually crosses node boundaries.voidpublish(ClusterEvent event) Publish a change to peer nodes.voidsubscribe(Consumer<ClusterEvent> sink) Register a sink invoked for events that originated on other nodes.
-
Constructor Details
-
NoOpClusterEventBus
public NoOpClusterEventBus()
-
-
Method Details
-
publish
Description copied from interface:ClusterEventBusPublish a change to peer nodes. Fan-out to the publishing node's own SSE clients has already happened synchronously on the local event path, so an implementation that echoes the event back to its own subscribers must let them filter it byClusterEvent.originNodeId().The implementation stamps the event's
ClusterEvent.originNodeId()with its own node id before sending (seeClusterEvent.withOrigin(java.lang.String)); callers may leave that fieldnull(asClusterEvent.entityChanged(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)does).- Specified by:
publishin interfaceClusterEventBus
-
subscribe
Description copied from interface:ClusterEventBusRegister a sink invoked for events that originated on other nodes. A bus must not invoke the sink for the local node's own events (seeClusterEvent.originNodeId()). May be called more than once to attach multiple sinks.- Specified by:
subscribein interfaceClusterEventBus
-
isDistributed
public boolean isDistributed()Description copied from interface:ClusterEventBusWhether this bus actually crosses node boundaries.falseforNoOpClusterEventBus(single-node / non-Postgres dev),truefor a real distributed implementation. Useful for diagnostics and for callers that want to log the active topology at startup.- Specified by:
isDistributedin interfaceClusterEventBus
-