|
3 | 3 | import dev.openfeature.contrib.providers.flagd.FlagdOptions;
|
4 | 4 | import dev.openfeature.contrib.providers.flagd.resolver.grpc.cache.Cache;
|
5 | 5 | import dev.openfeature.contrib.providers.flagd.resolver.common.ChannelBuilder;
|
| 6 | +import dev.openfeature.contrib.providers.flagd.resolver.common.Util; |
6 | 7 | import dev.openfeature.flagd.grpc.Schema;
|
7 | 8 | import dev.openfeature.flagd.grpc.ServiceGrpc;
|
8 | 9 | import dev.openfeature.sdk.ProviderState;
|
@@ -73,7 +74,7 @@ public void initialize() throws Exception {
|
73 | 74 | eventObserverThread.start();
|
74 | 75 |
|
75 | 76 | // block till ready
|
76 |
| - busyWaitAndCheck(this.deadline, this.connected); |
| 77 | + Util.busyWaitAndCheck(this.deadline, this.connected); |
77 | 78 | }
|
78 | 79 |
|
79 | 80 | /**
|
@@ -160,22 +161,4 @@ private void grpcStateConsumer(final ProviderState state) {
|
160 | 161 | // chain to initiator
|
161 | 162 | this.stateConsumer.accept(state);
|
162 | 163 | }
|
163 |
| - |
164 |
| - /** |
165 |
| - * A helper to block the caller for given conditions. |
166 |
| - * |
167 |
| - * @param deadline number of milliseconds to block |
168 |
| - * @param check {@link AtomicBoolean} to check for status true |
169 |
| - */ |
170 |
| - private static void busyWaitAndCheck(final Long deadline, final AtomicBoolean check) throws InterruptedException { |
171 |
| - long start = System.currentTimeMillis(); |
172 |
| - |
173 |
| - do { |
174 |
| - if (deadline <= System.currentTimeMillis() - start) { |
175 |
| - throw new RuntimeException(String.format("Initialization not complete after %d ms", deadline)); |
176 |
| - } |
177 |
| - |
178 |
| - Thread.sleep(50L); |
179 |
| - } while (!check.get()); |
180 |
| - } |
181 | 164 | }
|
0 commit comments