1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.adservices.service.common; 18 19 import com.android.adservices.LoggerFactory; 20 21 import com.google.common.util.concurrent.ListenableFuture; 22 23 import java.util.Set; 24 import java.util.concurrent.Callable; 25 26 /** Provides utility to add retry logic on method calls. */ 27 public interface RetryStrategy { 28 29 /** 30 * @param listenableFutureToRetry Listenable future to retry. 31 * @param retryableExceptions the set of exceptions on which retry should be attempted. 32 * @return the listenableFutureToRetry after adding the retry wrapper on it. 33 */ call( Callable<ListenableFuture<T>> listenableFutureToRetry, Set<Class<? extends Exception>> retryableExceptions, LoggerFactory.Logger logger, String callingIdentifier)34 <T> ListenableFuture<T> call( 35 Callable<ListenableFuture<T>> listenableFutureToRetry, 36 Set<Class<? extends Exception>> retryableExceptions, 37 LoggerFactory.Logger logger, 38 String callingIdentifier); 39 } 40