Skip to content

Commit

Permalink
moved toRetryPolicy to RetryOptionsUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
mfateev committed Dec 29, 2023
1 parent fc3df01 commit b539e51
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package io.temporal.internal.client;

import static io.temporal.internal.common.HeaderUtils.toHeaderGrpc;
import static io.temporal.internal.common.SerializerUtils.toRetryPolicy;
import static io.temporal.internal.common.RetryOptionsUtils.toRetryPolicy;

import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.temporal.failure.ApplicationFailure;
import io.temporal.failure.ChildWorkflowFailure;
import java.time.Duration;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -95,4 +96,21 @@ public static RetryOptions toRetryOptions(RetryPolicy retryPolicy) {

return roBuilder.validateBuildWithDefaults();
}

public static RetryPolicy.Builder toRetryPolicy(RetryOptions retryOptions) {
RetryPolicy.Builder builder =
RetryPolicy.newBuilder()
.setInitialInterval(
ProtobufTimeUtils.toProtoDuration(retryOptions.getInitialInterval()))
.setMaximumInterval(
ProtobufTimeUtils.toProtoDuration(retryOptions.getMaximumInterval()))
.setBackoffCoefficient(retryOptions.getBackoffCoefficient())
.setMaximumAttempts(retryOptions.getMaximumAttempts());

if (retryOptions.getDoNotRetry() != null) {
builder = builder.addAllNonRetryableErrorTypes(Arrays.asList(retryOptions.getDoNotRetry()));
}

return builder;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import static io.temporal.internal.common.HeaderUtils.intoPayloadMap;
import static io.temporal.internal.common.HeaderUtils.toHeaderGrpc;
import static io.temporal.internal.common.SerializerUtils.toRetryPolicy;
import static io.temporal.internal.common.RetryOptionsUtils.toRetryPolicy;
import static io.temporal.internal.sync.WorkflowInternal.DEFAULT_VERSION;

import com.google.common.base.MoreObjects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

package io.temporal.internal.common;

import static io.temporal.internal.common.SerializerUtils.toRetryPolicy;
import static io.temporal.internal.common.RetryOptionsUtils.toRetryPolicy;
import static org.junit.Assert.assertEquals;

import io.temporal.api.common.v1.RetryPolicy;
Expand Down

0 comments on commit b539e51

Please sign in to comment.