class AwsObservableExt {

    public static <REQ extends AmazonWebServiceRequest, RES> Single<RES> asyncActionSingle(Func1<SingleHandlerSupplier<RES>, Future<RES>> action) {
        return Single.create(subscriber -> {
            try {
                final Future<RES> result = action.call(new SingleHandlerSupplier<>(subscriber));
                subscriber.add(Subscriptions.create(() -> result.cancel(true)));
            } catch (Throwable t) {
                Exceptions.throwIfFatal(t);
                subscriber.onError(t);
            }
        });
    }

}