Package discord4j.core.event
Interface EventDispatcher.Builder
-
- All Known Implementing Classes:
DefaultEventDispatcher.Builder
,ReplayingEventDispatcher.Builder
- Enclosing interface:
- EventDispatcher
public static interface EventDispatcher.Builder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description EventDispatcher
build()
Create theEventDispatcher
DefaultEventDispatcher.Builder
eventProcessor(FluxProcessor<Event,Event> eventProcessor)
Deprecated.due to the Processor API being deprecated, we recommend usingeventSink(Function)
moving forwardDefaultEventDispatcher.Builder
eventScheduler(Scheduler eventScheduler)
Set theScheduler
this dispatcher should use to publish events to its subscribers.SinksEventDispatcher.Builder
eventSink(Function<Sinks.ManySpec,Sinks.Many<Event>> eventSinkFactory)
Set the underlyingSinks.Many
the dispatcher will use to queue and distribute events.DefaultEventDispatcher.Builder
overflowStrategy(FluxSink.OverflowStrategy overflowStrategy)
Deprecated.due to the Processor API being deprecated, we recommend usingeventSink(Function)
moving forward
-
-
-
Method Detail
-
eventSink
SinksEventDispatcher.Builder eventSink(Function<Sinks.ManySpec,Sinks.Many<Event>> eventSinkFactory)
Set the underlyingSinks.Many
the dispatcher will use to queue and distribute events. Defaults to using a multicast buffering sink.- Parameters:
eventSinkFactory
- the custom sink factory for events- Returns:
- this builder
-
eventProcessor
@Deprecated DefaultEventDispatcher.Builder eventProcessor(FluxProcessor<Event,Event> eventProcessor)
Deprecated.due to the Processor API being deprecated, we recommend usingeventSink(Function)
moving forwardSet the underlyingFluxProcessor
the dispatcher will use to queue and distribute events. Defaults to using anEmitterProcessor
.Using
EmitterProcessor
only emits events since a subscriber has subscribed to the processor (except for the first one which receives all queued signals until that point), and it allows you to configure the backing queue size while allowing you to use operators likeFlux.repeat()
andFlux.retry()
to drop the triggering signal.- Parameters:
eventProcessor
- the custom processor for events- Returns:
- this builder
-
overflowStrategy
@Deprecated DefaultEventDispatcher.Builder overflowStrategy(FluxSink.OverflowStrategy overflowStrategy)
Deprecated.due to the Processor API being deprecated, we recommend usingeventSink(Function)
moving forwardSet theFluxSink.OverflowStrategy
for dealing with overflow scenarios where too many events are being published. Defaults to usingFluxSink.OverflowStrategy.BUFFER
to ensure all events are delivered at the cost of higher memory footprint and potentialOutOfMemoryError
scenarios.To only keep the earliest events you can use
FluxSink.OverflowStrategy.DROP
, and to only keep the most recent events, useFluxSink.OverflowStrategy.LATEST
. The number of events that can be queued until this strategy is applied depends on the underlying processor implementation.- Parameters:
overflowStrategy
- the custom backpressure strategy- Returns:
- this builder
-
eventScheduler
DefaultEventDispatcher.Builder eventScheduler(Scheduler eventScheduler)
Set theScheduler
this dispatcher should use to publish events to its subscribers. Using a bounded elastic/blocking-capable one is recommended for general workloads that may have blocking sequences.- Parameters:
eventScheduler
- a customScheduler
to publish events- Returns:
- this builder
-
build
EventDispatcher build()
Create theEventDispatcher
- Returns:
- an
EventDispatcher
with the configured parameters.
-
-