Skip to content

Commit ac9c71a

Browse files
committed
use grpc retries instead of hand-written retries
1 parent 40d9aa4 commit ac9c71a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/v1/CallingWatch.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import io.grpc.Status;
1111
import io.grpc.StatusRuntimeException;
1212
import java.util.Iterator;
13+
import java.util.List;
14+
import java.util.Map;
1315

1416
// Installation
1517
// https://search.maven.org/artifact/com.authzed.api/authzed
@@ -33,6 +35,26 @@ public static void main(String[] args) {
3335
ManagedChannel channel = ManagedChannelBuilder
3436
.forTarget(target)
3537
.useTransportSecurity() // if not using TLS, replace with .usePlaintext()
38+
.disableServiceConfigLookUp()
39+
.defaultServiceConfig(Map.of(
40+
"methodConfig", List.of(
41+
Map.of(
42+
"name", List.of(
43+
Map.of(
44+
"service", "authzed.api.v1.WatchService",
45+
"method", "Watch"
46+
)
47+
),
48+
"retryPolicy", Map.of(
49+
"maxAttempts", "5",
50+
"initialBackoff", "1s",
51+
"backoffMultiplier", "4.0",
52+
"maxBackoff", "30s",
53+
"retryableStatusCodes", List.of("UNAVAILABLE", "INTERNAL")
54+
)
55+
)
56+
)
57+
))
3658
.build();
3759

3860
ZedToken lastZedToken = ZedToken.newBuilder().setToken("").build();

0 commit comments

Comments
 (0)