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 createEventDispatcher
instances.
-
-
Field Summary
Fields Modifier and Type Field Description protected EmissionStrategy
emissionStrategy
protected Scheduler
eventScheduler
protected Function<Sinks.ManySpec,Sinks.Many<Event>>
eventSinkFactory
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventDispatcher
build()
SinksEventDispatcher.Builder
emissionStrategy(EmissionStrategy emissionStrategy)
Set theEmissionStrategy
to 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.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.
-
-
-
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.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
-
emissionStrategy
public SinksEventDispatcher.Builder emissionStrategy(EmissionStrategy emissionStrategy)
Set theEmissionStrategy
to 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 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
public EventDispatcher build()
-
-