All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.stargate.sgv2.api.common.grpc.retries.impl.StatusCodesRetryPredicate Maven / Gradle / Ivy

There is a newer version: 2.1.0-BETA-19
Show newest version
package io.stargate.sgv2.api.common.grpc.retries.impl;

import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.stargate.sgv2.api.common.grpc.retries.GrpcRetryPredicate;
import java.util.Set;

/** {@link GrpcRetryPredicate} based on status code matching. */
public class StatusCodesRetryPredicate implements GrpcRetryPredicate {

  private final Set statusCodes;

  public StatusCodesRetryPredicate(Set statusCodes) {
    this.statusCodes = statusCodes;
  }

  /** {@inheritDoc} */
  @Override
  public boolean test(StatusRuntimeException e) {
    if (null != statusCodes) {
      return statusCodes.contains(e.getStatus().getCode());
    }
    return false;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy