@Override public Publisher<T> apply(Flowable<T> upstream) { return Flowable.fromPublisher(downstream -> { SubscriptionArbiter sa = new SubscriptionArbiter(); downstream.onSubscribe(sa); RetrySubscriber<T> repeatSubscriber = new RetrySubscriber<>(downstream, retry.getRetryConfig().getMaxAttempts(), sa, upstream, retry); upstream.subscribe(repeatSubscriber); }); }
@Override public SingleSource<T> apply(Single<T> upstream) { return Single.fromPublisher(downstream -> { Flowable<T> flowable = upstream.toFlowable(); SubscriptionArbiter sa = new SubscriptionArbiter(); downstream.onSubscribe(sa); RetrySubscriber<T> retrySubscriber = new RetrySubscriber<>(downstream, retry.getRetryConfig().getMaxAttempts(), sa, flowable, retry); flowable.subscribe(retrySubscriber); }); }
@Override public ObservableSource<T> apply(Observable<T> upstream) { return Observable.fromPublisher(downstream -> { Flowable<T> flowable = upstream.toFlowable(BackpressureStrategy.BUFFER); SubscriptionArbiter sa = new SubscriptionArbiter(); downstream.onSubscribe(sa); RetrySubscriber<T> retrySubscriber = new RetrySubscriber<>(downstream, retry.getRetryConfig().getMaxAttempts(), sa, flowable, retry); flowable.subscribe(retrySubscriber); }); }
@Test() public void shouldBuilderCreateConfigEveryTime() { final RetryConfig.Builder builder = RetryConfig.custom(); builder.maxAttempts(5); final RetryConfig config1 = builder.build(); builder.maxAttempts(3); final RetryConfig config2 = builder.build(); assertThat(config2.getMaxAttempts()).isEqualTo(3); assertThat(config1.getMaxAttempts()).isEqualTo(5); }
public RetryImpl(String name, RetryConfig config){ this.name = name; this.config = config; this.maxAttempts = config.getMaxAttempts(); this.intervalFunction = config.getIntervalFunction(); this.exceptionPredicate = config.getExceptionPredicate(); this.resultPredicate = config.getResultPredicate(); this.metrics = this.new RetryMetrics(); this.eventProcessor = new RetryEventProcessor(); succeededAfterRetryCounter = new LongAdder(); failedAfterRetryCounter = new LongAdder(); succeededWithoutRetryCounter = new LongAdder(); failedWithoutRetryCounter = new LongAdder(); }
public AsyncRetryImpl(String name, RetryConfig config) { this.config = config; this.name = name; this.maxAttempts = config.getMaxAttempts(); this.intervalFunction = config.getIntervalFunction(); this.exceptionPredicate = config.getExceptionPredicate(); this.resultPredicate = config.getResultPredicate(); this.metrics = this.new AsyncRetryMetrics(); succeededAfterRetryCounter = new LongAdder(); failedAfterRetryCounter = new LongAdder(); succeededWithoutRetryCounter = new LongAdder(); failedWithoutRetryCounter = new LongAdder(); this.eventProcessor = new RetryEventProcessor(); }
@Override public Publisher<T> apply(Flowable<T> upstream) { return Flowable.fromPublisher(downstream -> { SubscriptionArbiter sa = new SubscriptionArbiter(); downstream.onSubscribe(sa); RetrySubscriber<T> repeatSubscriber = new RetrySubscriber<>(downstream, retry.getRetryConfig().getMaxAttempts(), sa, upstream, retry); upstream.subscribe(repeatSubscriber); }); }
@Override public ObservableSource<T> apply(Observable<T> upstream) { return Observable.fromPublisher(downstream -> { Flowable<T> flowable = upstream.toFlowable(BackpressureStrategy.BUFFER); SubscriptionArbiter sa = new SubscriptionArbiter(); downstream.onSubscribe(sa); RetrySubscriber<T> retrySubscriber = new RetrySubscriber<>(downstream, retry.getRetryConfig().getMaxAttempts(), sa, flowable, retry); flowable.subscribe(retrySubscriber); }); }
@Override public SingleSource<T> apply(Single<T> upstream) { return Single.fromPublisher(downstream -> { Flowable<T> flowable = upstream.toFlowable(); SubscriptionArbiter sa = new SubscriptionArbiter(); downstream.onSubscribe(sa); RetrySubscriber<T> retrySubscriber = new RetrySubscriber<>(downstream, retry.getRetryConfig().getMaxAttempts(), sa, flowable, retry); flowable.subscribe(retrySubscriber); }); }