Skip to content

Commit

Permalink
3.2.7-SNAPSHOT
Browse files Browse the repository at this point in the history
Fix Bug: Logging initialization is too early in KeelVerticle Impls.

Signed-off-by: sinri <[email protected]>
  • Loading branch information
sinri committed May 20, 2024
1 parent cbbbb09 commit eb5159c
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ static <R> Future<R> vertxizedRawFuture(@Nonnull java.util.concurrent.Future<R>
static <T> Future<T> executeBlocking(@Nonnull Handler<Promise<T>> blockingCodeHandler) {
Promise<T> promise = Promise.promise();
KeelVerticle verticle = new KeelVerticleImplPure() {

@Override
public void start() {
protected void startAsPureKeelVerticle() {
blockingCodeHandler.handle(promise);
promise.future().onComplete(ar -> this.undeployMe());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected Future<Void> rest() {
}

@Override
public void start() throws Exception {
protected void startAsKeelVerticle() {
barrelUsed.set(0);
KeelAsyncKit.repeatedlyCall(routineResult -> {
return fireOnce();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public final KeelWatchmanEventHandler regularHandler() {
}

@Override
public void start() {
protected void startAsKeelVerticle() {
Future.succeededFuture()
.compose(v -> cronTabUpdateStartup.apply(eventBusAddress()))
.onSuccess(v -> super.start())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected String eventBusAddress() {
}

@Override
public void start() {
protected void startAsKeelVerticle() {
this.consumer = Keel.getVertx().eventBus().consumer(eventBusAddress());
this.consumer.handler(this::consumeHandleMassage);
this.consumer.exceptionHandler(throwable -> getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private Promise<Void> getCurrentInterrupt() {
}

@Override
public void start() throws Exception {
protected void startAsKeelVerticle() {
KeelAsyncKit.endless(promise -> {
this.interruptRef.set(null);
//System.out.println("ENDLESS "+System.currentTimeMillis());
Expand Down Expand Up @@ -95,6 +95,7 @@ public void start() throws Exception {
});
}


// @Deprecated
// public static void main(String[] args) {
// Keel.initializeVertxStandalone(new VertxOptions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private Promise<Void> getCurrentInterrupt() {
}

@Override
public void start() {
protected void startAsKeelVerticle() {
queueAcceptTask = true;

int configuredBatchSize = getBatchSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ protected KeelQueue setQueueStatus(QueueStatus queueStatus) {
*/
abstract protected @Nonnull SignalReader getSignalReader();

public void start() {
@Override
protected void startAsKeelVerticle() {
this.queueStatus = QueueStatus.RUNNING;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ final void setQueueWorkerPoolManager(QueueWorkerPoolManager queueWorkerPoolManag
@Nonnull
abstract public String getTaskCategory();

// as verticle
public final void start() {
@Override
protected final void startAsKeelVerticle() {
this.queueWorkerPoolManager.whenOneWorkerStarts();

Future.succeededFuture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ protected KeelEventLogger buildEventLogger() {
}

@Override

public void start() throws Exception {
protected void startAsKeelVerticle() {
int delaySeconds = 61 - KeelCronExpression.parseCalenderToElements(Calendar.getInstance()).second;
this.timerID = Keel.getVertx().setPeriodic(delaySeconds * 1000L, 60_000L, timerID -> {
handleEveryMinute(Calendar.getInstance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public KeelSundialVerticle(@Nonnull KeelSundialPlan sundialPlan, Calendar now) {
}

@Override
public void start() throws Exception {
protected void startAsPureKeelVerticle() {
Future.succeededFuture()
.compose(v -> {
return sundialPlan.execute(now);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
package io.github.sinri.keel.verticles;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;

/**
* @since 3.2.0
*/
public abstract class KeelVerticleImplPure extends AbstractVerticle implements KeelVerticle {
@Override
public final void start(Promise<Void> startPromise) {
this.startAsPureKeelVerticle(startPromise);
}

@Override
public final void start() {
this.startAsPureKeelVerticle();
}

protected void startAsPureKeelVerticle(Promise<Void> startPromise) {
startAsPureKeelVerticle();
startPromise.complete();
}

abstract protected void startAsPureKeelVerticle();
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package io.github.sinri.keel.verticles;

import io.github.sinri.keel.logger.event.KeelEventLogger;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;

import javax.annotation.Nonnull;

/**
* @since 3.2.0
*/
abstract public class KeelVerticleImplWithEventLogger extends KeelVerticleImplPure {
private final @Nonnull KeelEventLogger logger;
abstract public class KeelVerticleImplWithEventLogger extends AbstractVerticle implements KeelVerticle {
private @Nonnull KeelEventLogger logger;

public KeelVerticleImplWithEventLogger() {
super();
Expand All @@ -22,4 +24,22 @@ public KeelEventLogger getLogger() {

abstract protected KeelEventLogger buildEventLogger();

@Override
public final void start(Promise<Void> startPromise) {
this.logger = buildEventLogger();
start();
startPromise.complete();
}

@Override
public final void start() {
this.startAsKeelVerticle();
}

protected void startAsKeelVerticle(Promise<Void> startPromise) {
startAsKeelVerticle();
startPromise.complete();
}

abstract protected void startAsKeelVerticle();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import io.github.sinri.keel.logger.issue.record.KeelIssueRecord;
import io.github.sinri.keel.logger.issue.recorder.KeelIssueRecorder;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;

import javax.annotation.Nonnull;

abstract public class KeelVerticleImplWithIssueRecorder<T extends KeelIssueRecord<T>> extends KeelVerticleImplPure {
private final @Nonnull KeelIssueRecorder<T> issueRecorder;
abstract public class KeelVerticleImplWithIssueRecorder<T extends KeelIssueRecord<T>> extends AbstractVerticle implements KeelVerticle {
private @Nonnull KeelIssueRecorder<T> issueRecorder;

public KeelVerticleImplWithIssueRecorder() {
this.issueRecorder = buildIssueRecorder();
Expand All @@ -18,4 +20,22 @@ public KeelIssueRecorder<T> getIssueRecorder() {
}

abstract protected @Nonnull KeelIssueRecorder<T> buildIssueRecorder();

@Override
public final void start(Promise<Void> startPromise) {
this.issueRecorder = buildIssueRecorder();
this.start();
}

@Override
public final void start() {
this.startAsKeelVerticle();
}

protected void startAsKeelVerticle(Promise<Void> startPromise) {
startAsKeelVerticle();
startPromise.complete();
}

abstract protected void startAsKeelVerticle();
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected boolean isMainService() {
protected abstract void configureRoutes(Router router);

@Override
public void start() throws Exception {
protected void startAsKeelVerticle() {
this.server = Keel.getVertx().createHttpServer(getHttpServerOptions());

Router router = Router.router(Keel.getVertx());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ private static Future<Void> blockPiece(BlockingVerticlePlanA futureForBlocking,
}

@Override
public void start() throws Exception {
protected void startAsKeelVerticle() {

}


public <T> Future<T> executeBlocking(Handler<Promise<T>> promiseHandler) {
Promise<T> promise = Promise.promise();
this.context.runOnContext(new Handler<Void>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public KeelIssueRecorder<KeelEventLog> buildIssueRecorder() {
}

@Override
public void start() throws Exception {

protected void startAsKeelVerticle() {
getIssueRecorder().info(r -> r.message("in verticle " + deploymentID()));
blockCode.handle(promise);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class TestMainVerticle extends KeelVerticleImplWithEventLogger {


@Override
public void start() throws Exception {
protected void startAsKeelVerticle() {
KeelAsyncKit.endless(() -> {
getLogger().info(r -> r.message("X"));
return Future.succeededFuture();
Expand Down

0 comments on commit eb5159c

Please sign in to comment.