Package com.couchbase.client.core.cnc
Class SimpleEventBus
- java.lang.Object
-
- com.couchbase.client.core.cnc.SimpleEventBus
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.couchbase.client.core.cnc.EventBus
EventBus.PublishResult
-
-
Constructor Summary
Constructors Constructor Description SimpleEventBus(boolean ignoreSystemEvents)
Creates a newSimpleEventBus
.SimpleEventBus(boolean ignoreSystemEvents, List<Class<? extends Event>> othersToIgnore)
Creates a newSimpleEventBus
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
EventBus.PublishResult
publish(Event event)
Try to publish an event.List<Event>
publishedEvents()
Mono<Void>
start()
Starts the event bus if it hasn't been started yet.Mono<Void>
stop(Duration timeout)
Stops the event bus if it hasn't been stopped already.EventSubscription
subscribe(Consumer<Event> consumer)
void
unsubscribe(EventSubscription subscription)
-
-
-
Constructor Detail
-
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
public SimpleEventBus(boolean ignoreSystemEvents, List<Class<? extends Event>> othersToIgnore)
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 Detail
-
publish
public EventBus.PublishResult publish(Event event)
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
public EventSubscription subscribe(Consumer<Event> consumer)
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
public void unsubscribe(EventSubscription subscription)
Description copied from interface:EventBus
- Specified by:
unsubscribe
in interfaceEventBus
- Parameters:
subscription
- the subscription used.
-
clear
public void clear()
-
start
public Mono<Void> start()
Description copied from interface:EventBus
Starts the event bus if it hasn't been started yet.
-
-