/*
 * Copyright 2011-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.lettuce.core.event;

import reactor.core.publisher.EmitterProcessor;
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Scheduler;

/**
 * Default implementation for an {@link EventBus}. Events are published using a {@link Scheduler}.
 *
 * @author Mark Paluch
 * @since 3.4
 */
public class DefaultEventBus implements EventBus {

    private final EmitterProcessor<Event> bus;
    private final Scheduler scheduler;

    public DefaultEventBus(Scheduler scheduler) {
        this.bus = EmitterProcessor.create();
        this.scheduler = scheduler;
    }

    @Override
    public Flux<Event> get() {
        return bus.onBackpressureDrop().publishOn(scheduler);
    }

    @Override
    public void publish(Event event) {
        if (bus.hasDownstreams()) {
            bus.onNext(event);
        }
    }
}

@@ -676,23 +676,22 @@
 blisher.
-Emitter
+Direct
 Processo
@@ -729,16 +729,56 @@
 r.Flux;%0A
+import reactor.core.publisher.FluxSink;%0A
 import r
@@ -1028,23 +1028,22 @@
 e final 
-Emitter
+Direct
 Processo
@@ -1056,16 +1056,56 @@
 t%3E bus;%0A
+    private final FluxSink%3CEvent%3E sink;%0A
     priv
@@ -1209,15 +1209,14 @@
 s = 
-Emitter
+Direct
 Proc
@@ -1231,16 +1231,48 @@
 eate();%0A
+        this.sink = bus.sink();%0A
         
@@ -1485,55 +1485,14 @@
     
-if (bus.hasDownstreams()) %7B%0A            bus.onN
+sink.n
 ext(
@@ -1503,18 +1503,8 @@
 t);%0A
-        %7D%0A
     

Use DirectProcessor in EventBus #1086