-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sinri Edogawa <[email protected]>
- Loading branch information
Showing
6 changed files
with
132 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialPlan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
package io.github.sinri.keel.servant.sundial; | ||
|
||
import io.github.sinri.keel.core.KeelCronExpression; | ||
import io.vertx.core.Future; | ||
|
||
import java.util.Calendar; | ||
|
||
/** | ||
* @since 3.0.0 | ||
* @since 3.2.4 change sync method `execute` to be async. | ||
*/ | ||
public interface KeelSundialPlan { | ||
String key(); | ||
|
||
KeelCronExpression cronExpression(); | ||
|
||
void execute(Calendar now); | ||
Future<Void> execute(Calendar now); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/github/sinri/keel/servant/sundial/KeelSundialVerticle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.github.sinri.keel.servant.sundial; | ||
|
||
import io.github.sinri.keel.verticles.KeelVerticleImplPure; | ||
import io.vertx.core.Future; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Calendar; | ||
|
||
/** | ||
* @since 3.2.4 | ||
*/ | ||
public class KeelSundialVerticle extends KeelVerticleImplPure { | ||
private final KeelSundialPlan sundialPlan; | ||
private final Calendar now; | ||
|
||
public KeelSundialVerticle(@Nonnull KeelSundialPlan sundialPlan, Calendar now) { | ||
this.sundialPlan = sundialPlan; | ||
this.now = now; | ||
} | ||
|
||
@Override | ||
public void start() throws Exception { | ||
Future.succeededFuture() | ||
.compose(v -> { | ||
return sundialPlan.execute(now); | ||
}) | ||
.onComplete(ar -> { | ||
undeployMe(); | ||
}); | ||
} | ||
} |