Package com.couchbase.client.core.cnc
Class SimpleEventBus
java.lang.Object
com.couchbase.client.core.cnc.SimpleEventBus
- All Implemented Interfaces:
EventBus
This super simple event bus should be used in testing only to assert certain
events got pushed through.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.couchbase.client.core.cnc.EventBus
EventBus.PublishResult
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleEventBus
(boolean ignoreSystemEvents) Creates a newSimpleEventBus
.SimpleEventBus
(boolean ignoreSystemEvents, List<Class<? extends Event>> othersToIgnore) Creates a newSimpleEventBus
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Try to publish an event.reactor.core.publisher.Mono
<Void> start()
Starts the event bus if it hasn't been started yet.reactor.core.publisher.Mono
<Void> Stops the event bus if it hasn't been stopped already.void
unsubscribe
(EventSubscription subscription)
-
Constructor Details
-
SimpleEventBus
public SimpleEventBus(boolean ignoreSystemEvents) Creates a newSimpleEventBus
.Note that in general you want to ignore system events since they add nondeterminism during assertions when things like garbage collections happen. Of course if you need to test/verify system events, set the argument to false.
- Parameters:
ignoreSystemEvents
- true if they should be ignored (recommended), false otherwise.
-
SimpleEventBus
Creates a newSimpleEventBus
.Note that in general you want to ignore system events since they add nondeterminism during assertions when things like garbage collections happen. Of course if you need to test/verify system events, set the argument to false.
- Parameters:
ignoreSystemEvents
- true if they should be ignored (recommended), false otherwise.othersToIgnore
- other list of events to ignore.
-
-
Method Details
-
publish
Description copied from interface:EventBus
Try to publish an event.- Specified by:
publish
in interfaceEventBus
- Parameters:
event
- the event to publish.- Returns:
- the
EventBus.PublishResult
of th event.
-
subscribe
Description copied from interface:EventBus
- Specified by:
subscribe
in interfaceEventBus
- Parameters:
consumer
- the consumer which will receive events.- Returns:
- a
EventSubscription
that can be used to unsubscribe.
-
unsubscribe
Description copied from interface:EventBus
- Specified by:
unsubscribe
in interfaceEventBus
- Parameters:
subscription
- the subscription used.
-
publishedEvents
-
clear
public void clear() -
start
Description copied from interface:EventBus
Starts the event bus if it hasn't been started yet. -
stop
Description copied from interface:EventBus
Stops the event bus if it hasn't been stopped already.
-