Skip to content

Commit

Permalink
Remove callback methods and use only futures
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Mar 15, 2023
1 parent 5fa7cad commit 6ceb237
Show file tree
Hide file tree
Showing 21 changed files with 20 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.consul;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* under the License.
*
*/
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.git;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void tearDown() {
bare.close();
}

vertx.close(v -> done.set(true));
vertx.close().onComplete(v -> done.set(true));

await().untilAtomic(done, is(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void tearDown() {
git.close();
}

vertx.close(v -> done.set(true));
vertx.close().onComplete(v -> done.set(true));

await().untilAtomic(done, is(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.hocon;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* under the License.
*
*/
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.kubernetes;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.redis;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.spring;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* under the License.
*
*/
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.vault;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setup() {

@After
public void tearDown(TestContext tc) {
vertx.close(tc.asyncAssertSuccess());
vertx.close().onComplete(tc.asyncAssertSuccess());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void setup() {

@After
public void tearDown(TestContext tc) {
vertx.close(tc.asyncAssertSuccess());
vertx.close().onComplete(tc.asyncAssertSuccess());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void setup() {

@After
public void tearDown(TestContext tc) {
vertx.close(tc.asyncAssertSuccess());
vertx.close().onComplete(tc.asyncAssertSuccess());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void setup() {

@After
public void tearDown(TestContext tc) {
vertx.close(tc.asyncAssertSuccess());
vertx.close().onComplete(tc.asyncAssertSuccess());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* under the License.
*
*/
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.yaml;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* under the License.
*
*/
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config.zookeeper;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void setUp(TestContext tc) throws Exception {
public void tearDown(TestContext tc) throws IOException {
retriever.close();
client.close();
vertx.close(tc.asyncAssertSuccess());
vertx.close().onComplete(tc.asyncAssertSuccess());
server.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,8 @@ static ConfigRetriever create(Vertx vertx) {
* Reads the configuration from the different {@link ConfigStore}
* and computes the final configuration.
*
* @param completionHandler handler receiving the computed configuration, or a failure if the
* @return a future notified the computed configuration, or a failure if the
* configuration cannot be retrieved
* @deprecated use {@link #getConfig()} instead
*/
@Deprecated
void getConfig(Handler<AsyncResult<JsonObject>> completionHandler);

/**
* Like {@link #getConfig(Handler)} but returns a {@code Future} of the asynchronous result
*/
Future<JsonObject> getConfig();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,6 @@ public synchronized void initializePeriodicScan() {
}
}

@Override
public void getConfig(Handler<AsyncResult<JsonObject>> completionHandler) {
Objects.requireNonNull(completionHandler);
getConfig().onComplete(completionHandler);
}

@Override
public Future<JsonObject> getConfig() {
return compute().onSuccess(result -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", checkCallbackDeprecation = true)
@ModuleGen(name = "vertx-config", groupPackage = "io.vertx", useFutures = true)
package io.vertx.config;

import io.vertx.codegen.annotations.ModuleGen;
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,13 @@ public interface ConfigProcessor {

/**
* Transforms the given {@code input} into a {@link JsonObject}. This is an asynchronous non-blocking
* transformation. The result is passed to the given {@code Handler}. If the transformation fails, the passed
* transformation. If the transformation fails, the passed
* {@link AsyncResult} would be marked as failed. On success, the result contains the {@link JsonObject}.
*
* @param vertx the Vert.x instance
* @param configuration the processor configuration, may be {@code null}
* @param input the input, must not be {@code null}
* @param handler the result handler, must not be {@code null}. The handler will be called in the same context as
* the caller.
* @deprecated implement {@link #process(Vertx, JsonObject, Buffer)} instead
*/
@Deprecated
default void process(Vertx vertx, JsonObject configuration, Buffer input, Handler<AsyncResult<JsonObject>> handler) {
vertx.runOnContext(v -> handler.handle(Future.failedFuture("Deprecated")));
}

/**
* Transforms the given {@code input} into a {@link JsonObject}.
* <p>
* This is an asynchronous non-blocking transformation.
*
* @param vertx the Vert.x instance
* @param configuration the processor configuration, may be {@code null}
* @param input the input, must not be {@code null}
* @return a future notified with the result
*/
Future<JsonObject> process(Vertx vertx, JsonObject configuration, Buffer input);
}
22 changes: 0 additions & 22 deletions vertx-config/src/main/java/io/vertx/config/spi/ConfigStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,6 @@
*/
public interface ConfigStore {

/**
* Closes the configuration store.
*
* @param completionHandler handler called when the cleanup has been completed
* @deprecated implement {@link #close()} instead
*/
@Deprecated
default void close(Handler<Void> completionHandler) {
completionHandler.handle(null);
}

/**
* Retrieves the configuration store in this store.
*
* @param completionHandler the handler to pass the configuration
* @deprecated implement {@link #get()} instead
*/
@Deprecated
default void get(Handler<AsyncResult<Buffer>> completionHandler) {
completionHandler.handle(Future.failedFuture("Deprecated"));
}

/**
* Retrieves the configuration store in this store.
*
Expand Down

0 comments on commit 6ceb237

Please sign in to comment.