Package discord4j.core.event
Class SinksEventDispatcher.Builder
- java.lang.Object
-
- discord4j.core.event.SinksEventDispatcher.Builder
-
- Enclosing class:
- SinksEventDispatcher
public static class SinksEventDispatcher.Builder extends Object
A builder to createEventDispatcherinstances.
-
-
Field Summary
Fields Modifier and Type Field Description protected EmissionStrategyemissionStrategyprotected SchedulereventSchedulerprotected Function<Sinks.ManySpec,Sinks.Many<Event>>eventSinkFactory
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventDispatcherbuild()SinksEventDispatcher.BuilderemissionStrategy(EmissionStrategy emissionStrategy)Set theEmissionStrategyto apply when event publishing fails, which can be useful to handle overflowing, non-serialized or terminal scenarios through the means of retrying, parking threads or throwing an exception back to the emitter.SinksEventDispatcher.BuildereventScheduler(Scheduler eventScheduler)Set theSchedulerthis dispatcher should use to publish events to its subscribers.SinksEventDispatcher.BuildereventSink(Function<Sinks.ManySpec,Sinks.Many<Event>> eventSinkFactory)Set the underlyingSinks.Manythe dispatcher will use to queue and distribute events.
-
-
-
Field Detail
-
eventSinkFactory
protected Function<Sinks.ManySpec,Sinks.Many<Event>> eventSinkFactory
-
emissionStrategy
protected EmissionStrategy emissionStrategy
-
eventScheduler
protected Scheduler eventScheduler
-
-
Method Detail
-
eventSink
public SinksEventDispatcher.Builder eventSink(Function<Sinks.ManySpec,Sinks.Many<Event>> eventSinkFactory)
Set the underlyingSinks.Manythe 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
-
emissionStrategy
public SinksEventDispatcher.Builder emissionStrategy(EmissionStrategy emissionStrategy)
Set theEmissionStrategyto apply when event publishing fails, which can be useful to handle overflowing, non-serialized or terminal scenarios through the means of retrying, parking threads or throwing an exception back to the emitter. Defaults to a timeout-then-drop strategy after 10 seconds.- Parameters:
emissionStrategy- the emission failure handling strategy- Returns:
- this builder
-
eventScheduler
public SinksEventDispatcher.Builder eventScheduler(Scheduler eventScheduler)
Set theSchedulerthis 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 customSchedulerto publish events- Returns:
- this builder
-
build
public EventDispatcher build()
-
-