Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 715 Bytes

functional-interface.md

File metadata and controls

30 lines (21 loc) · 715 Bytes
layout title
default
Functional Interface Support

Functional Interface Support

Failsafe can be used to create resilient functional interfaces.

It can wrap Runnable, Callables, Suppliers, Consumers and Functions:

Function<String, Connection> connect = address -> 
  Failsafe.with(retryPolicy).get(() -> connect(address));

Stream operations:

Stream.of("foo").map(value -> Failsafe.with(retryPolicy).get(() -> value + "bar"));

Or individual CompletableFuture stages:

CompletableFuture.supplyAsync(() -> Failsafe.with(retryPolicy).get(() -> "foo"))
  .thenApplyAsync(value -> Failsafe.with(retryPolicy).get(() -> value + "bar"));

{% include common-links.html %}