Skip to content

Commit 1eccc02

Browse files
committed
fix(flagd): Please spotless
Signed-off-by: Guido Breitenhuber <[email protected]>
1 parent 89e2104 commit 1eccc02

File tree

2 files changed

+62
-65
lines changed

2 files changed

+62
-65
lines changed

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/ChannelBuilder.java

Lines changed: 56 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,20 @@ public class ChannelBuilder {
2929
@SuppressWarnings({"unchecked", "rawtypes"})
3030
private static final Map<String, ?> DEFAULT_RETRY_POLICY = new HashMap() {
3131
{
32-
// 1 + 2 + 4
32+
// 1s + 2s + 4s
3333
put("maxAttempts", 3.0); // types used here are important, need to be doubles
3434
put("initialBackoff", "1s");
3535
put("maxBackoff", "5s");
3636
put("backoffMultiplier", 2.0);
3737
// status codes to retry on:
38-
put("retryableStatusCodes",
39-
Arrays.asList(
40-
/*
41-
* Only states UNAVAILABLE and UNKNOWN should be retried. All
42-
* other failure states will probably not be resolved with a simple retry.
43-
*/
44-
Code.UNAVAILABLE.toString(),
45-
Code.UNKNOWN.toString()
46-
)
47-
);
38+
put(
39+
"retryableStatusCodes",
40+
Arrays.asList(
41+
/*
42+
* Only states UNAVAILABLE and UNKNOWN should be retried. All
43+
* other failure states will probably not be resolved with a simple retry.
44+
*/
45+
Code.UNAVAILABLE.toString(), Code.UNKNOWN.toString()));
4846
}
4947
};
5048

@@ -54,10 +52,11 @@ public class ChannelBuilder {
5452
@SuppressWarnings({"unchecked", "rawtypes"})
5553
static final Map<String, ?> SERVICE_CONFIG_WITH_RETRY = new HashMap() {
5654
{
57-
put("methodConfig", Arrays.asList(
58-
new HashMap() {
59-
{
60-
put("name", Arrays.asList(
55+
put("methodConfig", Arrays.asList(new HashMap() {
56+
{
57+
put(
58+
"name",
59+
Arrays.asList(
6160
new HashMap() {
6261
{
6362
put("service", "flagd.sync.v1.FlagSyncService");
@@ -67,56 +66,51 @@ public class ChannelBuilder {
6766
{
6867
put("service", "flagd.evaluation.v1.Service");
6968
}
70-
}
71-
));
72-
put("retryPolicy", DEFAULT_RETRY_POLICY);
73-
}
69+
}));
70+
put("retryPolicy", DEFAULT_RETRY_POLICY);
71+
}
7472

73+
{
74+
put("name", Arrays.asList(new HashMap() {
7575
{
76-
put("name", Arrays.asList(
77-
new HashMap() {
78-
{
79-
put("service", "flagd.sync.v1.FlagSyncService");
80-
put("method", "SyncFlags");
81-
}
82-
}
83-
));
84-
put("retryPolicy", new HashMap(DEFAULT_RETRY_POLICY) {
85-
{
86-
// 1 + 2 + 4 + 5 + 5 + 5 + 5 + 5 + 5 + 5
87-
put("maxAttempts", 12.0);
88-
// for streaming Retry on more status codes
89-
put("retryableStatusCodes",
90-
Arrays.asList(
91-
/*
92-
* All codes are retryable except OK and DEADLINE_EXCEEDED since
93-
* any others not listed here cause a very tight loop of retries.
94-
* DEADLINE_EXCEEDED is typically a result of a client specified
95-
* deadline,and definitionally should not result in a tight loop
96-
* (it's a timeout).
97-
*/
98-
Code.CANCELLED.toString(),
99-
Code.UNKNOWN.toString(),
100-
Code.INVALID_ARGUMENT.toString(),
101-
Code.NOT_FOUND.toString(),
102-
Code.ALREADY_EXISTS.toString(),
103-
Code.PERMISSION_DENIED.toString(),
104-
Code.RESOURCE_EXHAUSTED.toString(),
105-
Code.FAILED_PRECONDITION.toString(),
106-
Code.ABORTED.toString(),
107-
Code.OUT_OF_RANGE.toString(),
108-
Code.UNIMPLEMENTED.toString(),
109-
Code.INTERNAL.toString(),
110-
Code.UNAVAILABLE.toString(),
111-
Code.DATA_LOSS.toString(),
112-
Code.UNAUTHENTICATED.toString()
113-
)
114-
);
115-
}
116-
});
76+
put("service", "flagd.sync.v1.FlagSyncService");
77+
put("method", "SyncFlags");
11778
}
118-
}
119-
));
79+
}));
80+
put("retryPolicy", new HashMap(DEFAULT_RETRY_POLICY) {
81+
{
82+
// 1s + 2s + 4s + 5s + 5s + 5s + 5s + 5s + 5s + 5s
83+
put("maxAttempts", 12.0);
84+
// for streaming Retry on more status codes
85+
put(
86+
"retryableStatusCodes",
87+
Arrays.asList(
88+
/*
89+
* All codes are retryable except OK and DEADLINE_EXCEEDED since
90+
* any others not listed here cause a very tight loop of retries.
91+
* DEADLINE_EXCEEDED is typically a result of a client specified
92+
* deadline,and definitionally should not result in a tight loop
93+
* (it's a timeout).
94+
*/
95+
Code.CANCELLED.toString(),
96+
Code.UNKNOWN.toString(),
97+
Code.INVALID_ARGUMENT.toString(),
98+
Code.NOT_FOUND.toString(),
99+
Code.ALREADY_EXISTS.toString(),
100+
Code.PERMISSION_DENIED.toString(),
101+
Code.RESOURCE_EXHAUSTED.toString(),
102+
Code.FAILED_PRECONDITION.toString(),
103+
Code.ABORTED.toString(),
104+
Code.OUT_OF_RANGE.toString(),
105+
Code.UNIMPLEMENTED.toString(),
106+
Code.INTERNAL.toString(),
107+
Code.UNAVAILABLE.toString(),
108+
Code.DATA_LOSS.toString(),
109+
Code.UNAUTHENTICATED.toString()));
110+
}
111+
});
112+
}
113+
}));
120114
}
121115
};
122116

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/sync/SyncStreamQueueSource.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ public SyncStreamQueueSource(final FlagdOptions options, Consumer<FlagdProviderE
5858
providerId = options.getProviderId();
5959
syncMetadataDisabled = options.isSyncMetadataDisabled();
6060
channelConnector = new ChannelConnector(options, onConnectionEvent, ChannelBuilder.nettyChannel(options));
61-
flagSyncStub = FlagSyncServiceGrpc.newStub(channelConnector.getChannel()).withWaitForReady();
62-
metadataStub = FlagSyncServiceGrpc.newBlockingStub(channelConnector.getChannel()).withWaitForReady();
61+
flagSyncStub =
62+
FlagSyncServiceGrpc.newStub(channelConnector.getChannel()).withWaitForReady();
63+
metadataStub = FlagSyncServiceGrpc.newBlockingStub(channelConnector.getChannel())
64+
.withWaitForReady();
6365
}
6466

6567
// internal use only
@@ -157,7 +159,8 @@ private Struct getMetadata() {
157159
} catch (StatusRuntimeException e) {
158160
// In newer versions of flagd, metadata is part of the sync stream. If the method is unimplemented, we
159161
// can ignore the error
160-
if (e.getStatus() != null && Status.Code.UNIMPLEMENTED.equals(e.getStatus().getCode())) {
162+
if (e.getStatus() != null
163+
&& Status.Code.UNIMPLEMENTED.equals(e.getStatus().getCode())) {
161164
return null;
162165
}
163166

0 commit comments

Comments
 (0)