juliuszsompolski commented on code in PR #43757: URL: https://github.com/apache/spark/pull/43757#discussion_r1392626387
########## connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/RetryPolicy.scala: ########## @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.connect.client + +import scala.concurrent.duration.{Duration, FiniteDuration} +import scala.util.Random + +import io.grpc.{Status, StatusRuntimeException} + +/** + * [[RetryPolicy]] configure the retry mechanism in [[GrpcRetryHandler]] + * + * @param maxRetries + * Maximum number of retries. + * @param initialBackoff + * Start value of the exponential backoff (ms). + * @param maxBackoff + * Maximal value of the exponential backoff (ms). + * @param backoffMultiplier + * Multiplicative base of the exponential backoff. + * @param canRetry + * Function that determines whether a retry is to be performed in the event of an error. + */ +case class RetryPolicy( + maxRetries: Option[Int] = None, + initialBackoff: FiniteDuration = FiniteDuration(1000, "ms"), + maxBackoff: Option[FiniteDuration] = None, + backoffMultiplier: Double = 1.0, + jitter: FiniteDuration = FiniteDuration(0, "s"), + minJitterThreshold: FiniteDuration = FiniteDuration(0, "s"), + canRetry: Throwable => Boolean, + name: String) { + + def getName: String = name + + def toState: RetryPolicy.RetryPolicyState = new RetryPolicy.RetryPolicyState(this) +} Review Comment: ... or just close down `RetryPolicyState` and acknowledge that there should be no need to override it at this point. It would be weird to override it anyway, because the parameters for ``` initialBackoff: FiniteDuration = FiniteDuration(1000, "ms"), maxBackoff: Option[FiniteDuration] = None, backoffMultiplier: Double = 1.0, jitter: FiniteDuration = FiniteDuration(0, "s"), minJitterThreshold: FiniteDuration = FiniteDuration(0, "s"), ``` give a pretty rigid structure for how RetryPolicyState should be behaved. It would be weird, if someone was to override RetryPolicyState in a way that e.g. does the backoff differently? So maybe better leave it as is, and close it down. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
