/** * Build a {@literal Broadcaster}, ready to broadcast values with {@link * reactor.rx.action.Action#onNext(Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param dispatcher the {@link reactor.core.Dispatcher} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> create(Dispatcher dispatcher) { return create(null, dispatcher); }
/** * Build a {@literal Broadcaster}, ready to broadcast values with {@link * Broadcaster#onNext(Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param env the Reactor {@link reactor.Environment} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> create(Environment env) { return create(env, env.getDefaultDispatcher()); }
/** * Subscribe a new {@link Broadcaster} and return it for future subscribers interactions. Effectively it turns any * stream into an Hot Stream where subscribers will only values from the time T when they subscribe to the returned * stream. Complete and Error signals are however retained unless {@link #keepAlive()} has been called before. * <p> * * @param dispatcher the dispatcher to run the signals * @return a new {@literal stream} whose values are broadcasted to all subscribers */ public final Stream<O> broadcastOn(Dispatcher dispatcher) { Broadcaster<O> broadcaster = Broadcaster.create(getEnvironment(), dispatcher); return broadcastTo(broadcaster); }
protected ReactiveSubscription<T> createWindowStream() { Action<T, T> action = Broadcaster.<T>create(environment, dispatcher); ReactiveSubscription<T> _currentWindow = new ReactiveSubscription<T>(null, action); currentWindows.add(_currentWindow); action.onSubscribe(_currentWindow); broadcastNext(action); return _currentWindow; }
public ThrottleRequestWhenAction(Dispatcher dispatcher, Function<? super Stream<? extends Long>, ? extends Publisher<? extends Long>> predicate) { this.throttleStream = Broadcaster.create(null, dispatcher); Publisher<? extends Long> afterRequestStream = predicate.apply(throttleStream); afterRequestStream.subscribe(new ThrottleSubscriber()); }
protected Stream<T> createWindowStream() { Broadcaster<T> action = timer != null && dispatcher == SynchronousDispatcher.INSTANCE ? SerializedBroadcaster.<T>create(environment, dispatcher) : Broadcaster.<T>create(environment, dispatcher); ReactiveSubscription<T> _currentWindow = new ReactiveSubscription<T>(null, action); currentWindow = _currentWindow; action.onSubscribe(_currentWindow); return action; }
public RepeatWhenAction(Dispatcher dispatcher, Function<? super Stream<? extends Long>, ? extends Publisher<?>> predicate, Publisher<? extends T> rootPublisher) { this.retryStream = Broadcaster.create(null, dispatcher); if (SynchronousDispatcher.INSTANCE == dispatcher) { this.dispatcher = Environment.tailRecurse(); } else { this.dispatcher = dispatcher; } this.rootPublisher = rootPublisher; Publisher<?> afterRetryPublisher = predicate.apply(retryStream); afterRetryPublisher.subscribe(new RestartSubscriber()); }
public RetryWhenAction(Dispatcher dispatcher, Function<? super Stream<? extends Throwable>, ? extends Publisher<?>> predicate, Publisher<? extends T> rootPublisher) { this.retryStream = Broadcaster.create(null, dispatcher); if(SynchronousDispatcher.INSTANCE == dispatcher){ this.dispatcher = Environment.tailRecurse(); }else{ this.dispatcher = dispatcher; } this.rootPublisher = rootPublisher; Publisher<?> afterRetryPublisher = predicate.apply(retryStream); afterRetryPublisher.subscribe(new RestartSubscriber()); }
requestMapper) { this.consumer = consumer; this.requestMapperStream = Broadcaster.create(); this.requestMapperStream.onSubscribe(new Subscription() { @Override
@Override public Action<O, O> get() { Broadcaster<O> newStream = Broadcaster.<O>create(getEnvironment(), getDispatcher()).capacity(capacity); if (queueSupplier == null) { subscribeWithSubscription(newStream, new DropSubscription<O>(Action.this, newStream) { @Override public void request(long elements) { super.request(elements); requestUpstream(capacity, isComplete(), elements); } }); } else { subscribeWithSubscription(newStream, createSubscription(newStream, queueSupplier.get())); } return newStream; } });
/** * Build a {@literal Broadcaster}, ready to broadcast values with {@link * reactor.rx.action.Action#onNext(Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param dispatcher the {@link reactor.core.Dispatcher} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> create(Dispatcher dispatcher) { return create(null, dispatcher); }
/** * Build a {@literal Broadcaster}, ready to broadcast values with {@link * Broadcaster#onNext(Object)}, * {@link Broadcaster#onError(Throwable)}, {@link Broadcaster#onComplete()}. * Values broadcasted are directly consumable by subscribing to the returned instance. * * @param env the Reactor {@link reactor.Environment} to use * @param <T> the type of values passing through the {@literal Broadcaster} * @return a new {@link Broadcaster} */ public static <T> Broadcaster<T> create(Environment env) { return create(env, env.getDefaultDispatcher()); }
/** * Subscribe a new {@link Broadcaster} and return it for future subscribers interactions. Effectively it turns any * stream into an Hot Stream where subscribers will only values from the time T when they subscribe to the returned * stream. Complete and Error signals are however retained unless {@link #keepAlive()} has been called before. * <p> * * @param dispatcher the dispatcher to run the signals * @return a new {@literal stream} whose values are broadcasted to all subscribers */ public final Stream<O> broadcastOn(Dispatcher dispatcher) { Broadcaster<O> broadcaster = Broadcaster.create(getEnvironment(), dispatcher); return broadcastTo(broadcaster); }
protected ReactiveSubscription<T> createWindowStream() { Action<T, T> action = Broadcaster.<T>create(environment, dispatcher); ReactiveSubscription<T> _currentWindow = new ReactiveSubscription<T>(null, action); currentWindows.add(_currentWindow); action.onSubscribe(_currentWindow); broadcastNext(action); return _currentWindow; }
public ThrottleRequestWhenAction(Dispatcher dispatcher, Function<? super Stream<? extends Long>, ? extends Publisher<? extends Long>> predicate) { this.throttleStream = Broadcaster.create(null, dispatcher); Publisher<? extends Long> afterRequestStream = predicate.apply(throttleStream); afterRequestStream.subscribe(new ThrottleSubscriber()); }
protected Stream<T> createWindowStream() { Broadcaster<T> action = timer != null && dispatcher == SynchronousDispatcher.INSTANCE ? SerializedBroadcaster.<T>create(environment, dispatcher) : Broadcaster.<T>create(environment, dispatcher); ReactiveSubscription<T> _currentWindow = new ReactiveSubscription<T>(null, action); currentWindow = _currentWindow; action.onSubscribe(_currentWindow); return action; }
public RepeatWhenAction(Dispatcher dispatcher, Function<? super Stream<? extends Long>, ? extends Publisher<?>> predicate, Publisher<? extends T> rootPublisher) { this.retryStream = Broadcaster.create(null, dispatcher); if (SynchronousDispatcher.INSTANCE == dispatcher) { this.dispatcher = Environment.tailRecurse(); } else { this.dispatcher = dispatcher; } this.rootPublisher = rootPublisher; Publisher<?> afterRetryPublisher = predicate.apply(retryStream); afterRetryPublisher.subscribe(new RestartSubscriber()); }
public RetryWhenAction(Dispatcher dispatcher, Function<? super Stream<? extends Throwable>, ? extends Publisher<?>> predicate, Publisher<? extends T> rootPublisher) { this.retryStream = Broadcaster.create(null, dispatcher); if(SynchronousDispatcher.INSTANCE == dispatcher){ this.dispatcher = Environment.tailRecurse(); }else{ this.dispatcher = dispatcher; } this.rootPublisher = rootPublisher; Publisher<?> afterRetryPublisher = predicate.apply(retryStream); afterRetryPublisher.subscribe(new RestartSubscriber()); }
requestMapper) { this.consumer = consumer; this.requestMapperStream = Broadcaster.create(); this.requestMapperStream.onSubscribe(new Subscription() { @Override
@Override public Action<O, O> get() { Broadcaster<O> newStream = Broadcaster.<O>create(getEnvironment(), getDispatcher()).capacity(capacity); if (queueSupplier == null) { subscribeWithSubscription(newStream, new DropSubscription<O>(Action.this, newStream) { @Override public void request(long elements) { super.request(elements); requestUpstream(capacity, isComplete(), elements); } }); } else { subscribeWithSubscription(newStream, createSubscription(newStream, queueSupplier.get())); } return newStream; } });