Skip to content

Commit

Permalink
Merge ca088b2 into 2f71963
Browse files Browse the repository at this point in the history
  • Loading branch information
maarek committed May 19, 2017
2 parents 2f71963 + ca088b2 commit b5b0724
Show file tree
Hide file tree
Showing 12 changed files with 962 additions and 7 deletions.
1 change: 1 addition & 0 deletions resilience4j-all/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ dependencies {
compile project(':resilience4j-retry')
compile project(':resilience4j-consumer')
compile project(':resilience4j-cache')
compile project(':resilience4j-timeout')
testCompile project(':resilience4j-test')
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package io.github.resilience4j.decorators;

import java.util.concurrent.CompletionStage;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

import io.github.resilience4j.bulkhead.Bulkhead;
import io.github.resilience4j.cache.Cache;
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.ratelimiter.RateLimiter;
import io.github.resilience4j.retry.AsyncRetry;
import io.github.resilience4j.retry.Retry;
import io.github.resilience4j.timeout.Timeout;
import io.vavr.CheckedFunction0;
import io.vavr.CheckedFunction1;
import io.vavr.CheckedRunnable;

import java.util.concurrent.CompletionStage;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

/**
* A Decorator builder which can be used to apply multiple decorators to a (Checked-)Supplier, (Checked-)Function,
* (Checked-)Runnable, (Checked-)CompletionStage or (Checked-)Consumer
Expand Down Expand Up @@ -86,6 +87,11 @@ public DecorateSupplier<T> withBulkhead(Bulkhead bulkhead) {
return this;
}

public DecorateSupplier<T> withTimeout(Timeout timeout) {
supplier = Timeout.decorateSupplier(timeout, supplier);
return this;
}

public Supplier<T> decorate() {
return supplier;
}
Expand Down Expand Up @@ -122,6 +128,11 @@ public DecorateFunction<T, R> withBulkhead(Bulkhead bulkhead) {
return this;
}

public DecorateFunction<T, R> withTimeout(Timeout timeout) {
function = Timeout.decorateFunction(timeout, function);
return this;
}

public Function<T, R> decorate() {
return function;
}
Expand Down Expand Up @@ -158,6 +169,11 @@ public DecorateRunnable withBulkhead(Bulkhead bulkhead) {
return this;
}

public DecorateRunnable withTimeout(Timeout timeout) {
runnable = Timeout.decorateRunnable(timeout, runnable);
return this;
}

public Runnable decorate() {
return runnable;
}
Expand Down Expand Up @@ -199,6 +215,11 @@ public DecorateCheckedSupplier<T> withBulkhead(Bulkhead bulkhead) {
return this;
}

public DecorateCheckedSupplier<T> withTimeout(Timeout timeout) {
supplier = Timeout.decorateCheckedSupplier(timeout, supplier);
return this;
}

public CheckedFunction0<T> decorate() {
return supplier;
}
Expand Down Expand Up @@ -235,6 +256,11 @@ public DecorateCheckedFunction<T, R> withBulkhead(Bulkhead bulkhead) {
return this;
}

public DecorateCheckedFunction<T, R> withTimeout(Timeout timeout) {
function = Timeout.decorateCheckedFunction(timeout, function);
return this;
}

public CheckedFunction1<T, R> decorate() {
return function;
}
Expand Down Expand Up @@ -271,6 +297,11 @@ public DecorateCheckedRunnable withBulkhead(Bulkhead bulkhead) {
return this;
}

public DecorateCheckedRunnable withTimeout(Timeout timeout) {
runnable = Timeout.decorateCheckedRunnable(timeout, runnable);
return this;
}

public CheckedRunnable decorate() {
return runnable;
}
Expand Down Expand Up @@ -340,6 +371,11 @@ public DecorateConsumer<T> withBulkhead(Bulkhead bulkhead) {
return this;
}

public DecorateConsumer<T> withTimeout(Timeout timeout) {
consumer = Timeout.decorateConsumer(timeout, consumer);
return this;
}

public Consumer<T> decorate() {
return consumer;
}
Expand Down
3 changes: 3 additions & 0 deletions resilience4j-timeout/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
compile ( libraries.rxjava2)
}

0 comments on commit b5b0724

Please sign in to comment.