Skip to content

Commit 8d411c2

Browse files
authored
Merge pull request #113 from zero88/schedulerx/release/2.0.0-rc.1
Release v2.0.0-rc.1
2 parents b86bf94 + 5abf11c commit 8d411c2

File tree

3 files changed

+7
-174
lines changed

3 files changed

+7
-174
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393

9494
publish:
9595
uses: zero88/shared-ghactions/.github/workflows/gradle-publish.yml@main
96-
needs: [ context, test, webdocs ]
96+
needs: [ context, test, docs ]
9797
if: needs.context.outputs.shouldPublish == 'true'
9898
with:
9999
profile: 'schedulerx'
@@ -109,7 +109,7 @@ jobs:
109109

110110
release:
111111
runs-on: ubuntu-latest
112-
needs: [ context, publish ]
112+
needs: [ context, webdocs, publish ]
113113
if: needs.context.outputs.isRelease == 'true'
114114
steps:
115115
- name: Create GitHub Release

README.adoc

+3-170
Original file line numberDiff line numberDiff line change
@@ -16,175 +16,8 @@ image:https://sonarcloud.io/api/project_badges/measure?project={sonarKey}&metric
1616
image:https://sonarcloud.io/api/project_badges/measure?project={sonarKey}&metric=security_rating[Security Rating,link=https://sonarcloud.io/dashboard?id={sonarKey}]
1717
image:https://sonarcloud.io/api/project_badges/measure?project={sonarKey}&metric=alert_status[Quality Gate Status,link=https://sonarcloud.io/dashboard?id={sonarKey}]
1818

19-
A `lightweight plugable scheduler` based on plain https://vertx.io/[Vert.x] core without any external libs for scheduling with _cron-style_ and _interval_ timers with a detail _monitor_ on both sync and async job.
19+
A pluggable `lightweight scheduler` based on plain https://vertx.io/[Vert.x] core without any external libs for scheduling on *time-based*: _cron_ and _interval_ or on *event-based*.
2020

21-
* `Scheduling` with:
22-
* `cron-style` based on http://www.quartz-scheduler.org/[Quartz] - `Unix` cron expression and `timezone` available
23-
on `JVM`
24-
* `interval` with given `time interval`, given `initial delay time` and `repeating` a given number of times or
25-
repeating infinitely
26-
* able to `cancel` schedule event
27-
* Support `synchronize` job and `async` job
28-
* Run on `vertx-worker-thread` or dedicated `vertx thread-pool`
29-
* Monitor `executor event` includes `fire counting`, `fired round`, `event time`, `job result data`, `job error` on
30-
your need such as `on schedule`, `on misfire`, `on each round`, `on completed`, etc…
31-
* Easy customize your `job` such as `HTTP client job`, `EventBus job`, `MQTT client job`, `database job`, etc…
21+
`Scheduler.x` follows an event-driven architecture.
3222

33-
== Usage
34-
35-
=== Maven Dependency
36-
37-
[source,xml]
38-
----
39-
40-
<dependency>
41-
<groupId>io.github.zero88</groupId>
42-
<artifactId>scheduler.x</artifactId>
43-
<version>1.0.0</version>
44-
</dependency>
45-
46-
----
47-
48-
=== Gradle Dependency
49-
50-
[source,groovy]
51-
----
52-
api("io.github.zero88:schedulerx:1.0.0")
53-
54-
----
55-
56-
== How To
57-
58-
=== Creating an executor
59-
60-
[source,java]
61-
----
62-
IntervalTaskExecutor.builder()
63-
.vertx(vertx)
64-
.trigger(IntervalTrigger.builder().interval(1).repeat(10).build())
65-
.job((jobData, ctx) -> {
66-
if(ctx.round()==5) {
67-
ctx.forceStopExecution();
68-
}
69-
})
70-
.build()
71-
.start()
72-
73-
----
74-
75-
[source,java]
76-
----
77-
CronTaskExecutor.builder()
78-
.vertx(vertx)
79-
.trigger(CronTrigger.builder().expression("0/5 * * ? * * *").build())
80-
.job((jobData, ctx) -> {})
81-
.build()
82-
.start(vertx.createSharedWorkerExecutor("TEST_CRON",3));
83-
----
84-
85-
=== Monitor
86-
87-
Please
88-
check https://github.com/zero88/scheduler.x/blob/62d8feb265f45afad2626886c24f2899346f46b1/src/main/java/io/github/zero88/vertx/scheduler/TaskExecutorMonitor.java[TaskExecutorMonitor]
89-
. Example:
90-
91-
[source,java]
92-
----
93-
public interface TaskExecutorLogMonitor extends TaskExecutorMonitor {
94-
95-
Logger LOGGER = LoggerFactory.getLogger(TaskExecutorLogMonitor.class);
96-
TaskExecutorMonitor LOG_MONITOR = new TaskExecutorLogMonitor() {};
97-
98-
@Override
99-
default void onUnableSchedule(@NotNull TaskResult result) {
100-
LOGGER.error("Unable schedule job at [{}] due to error", result.unscheduledAt(), result.error());
101-
}
102-
103-
@Override
104-
default void onSchedule(@NotNull TaskResult result) {
105-
if (result.isReschedule()) {
106-
LOGGER.debug("TaskExecutor is rescheduled at [{}] round [{}]", result.rescheduledAt(), result.round());
107-
} else {
108-
LOGGER.debug("TaskExecutor is available at [{}]", result.availableAt());
109-
}
110-
}
111-
112-
@Override
113-
default void onMisfire(@NotNull TaskResult result) {
114-
LOGGER.debug("Misfire tick [{}] at [{}]", result.tick(), result.triggeredAt());
115-
}
116-
117-
@Override
118-
default void onEach(@NotNull TaskResult result) {
119-
LOGGER.debug("Finish round [{}] - Is Error [{}] | Executed at [{}] - Finished at [{}]", result.round(),
120-
result.isError(), result.executedAt(), result.finishedAt());
121-
}
122-
123-
@Override
124-
default void onCompleted(@NotNull TaskResult result) {
125-
LOGGER.debug("Completed job in round [{}] at [{}]", result.round(), result.completedAt());
126-
}
127-
128-
}
129-
----
130-
131-
=== Custom job
132-
133-
Please
134-
check https://github.com/zero88/scheduler.x/blob/62d8feb265f45afad2626886c24f2899346f46b1/src/test/java/io/github/zero88/vertx/scheduler/custom/HttpClientTask.java[HttpClientTask]
135-
and
136-
its https://github.com/zero88/scheduler.x/blob/62d8feb265f45afad2626886c24f2899346f46b1/src/test/java/io/github/zero88/vertx/scheduler/custom/HttpClientTaskTest.java[test]
137-
for `async` job
138-
139-
[source,java]
140-
----
141-
public class HttpClientTask implements Task {
142-
143-
@Override
144-
public boolean isAsync() {
145-
return true;
146-
}
147-
148-
@Override
149-
public void execute(@NotNull JobData jobData, @NotNull TaskExecutionContext executionContext) {
150-
final Vertx vertx = executionContext.vertx();
151-
JsonObject url = (JsonObject) jobData.get();
152-
vertx.createHttpClient().request(HttpMethod.GET, url.getString("host"), url.getString("path"), ar1 -> {
153-
if (ar1.succeeded()) {
154-
HttpClientRequest request = ar1.result();
155-
request.send(ar2 -> {
156-
if (ar2.succeeded()) {
157-
HttpClientResponse response = ar2.result();
158-
response.body(ar3 -> {
159-
if (ar3.succeeded()) {
160-
executionContext.complete(new JsonObject().put("status", response.statusCode())
161-
.put("response", ar3.result().toJson()));
162-
} else {
163-
executionContext.fail(ar3.cause());
164-
}
165-
});
166-
} else {
167-
executionContext.fail(ar2.cause());
168-
}
169-
});
170-
} else {
171-
executionContext.fail(ar1.cause());
172-
}
173-
});
174-
}
175-
176-
}
177-
----
178-
179-
== TODO
180-
181-
* [ ] Cron job with repeating until a given time / date
182-
* [ ] Async query job data in execution
183-
* [ ] Optimize `CronExpression`
184-
185-
== Disclaim and Disclosure
186-
187-
This is lightweight module then I will not support for adding any rich function like `manage group of job/trigger`
188-
, `publish monitor event` by integrate with a fantastic client such as `Vertx EventBus`, etc…
189-
190-
I'm planning to do it in `vertx-planner` project later. Stay a tune!!!
23+
Please check out full documentation at https://zero88.github.io/jooqx-webdocs/schedulerx/main/index.html[web-docs]

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title=Scheduler.x
77
description=A scheduler based on plain Vertx promise/future/periodic/timer
88
projectGroup=io.github.zero88
99
projectLicense=The Apache License, Version 2.0
10-
version=2.0.0
10+
version=2.0.0-rc.1
1111
semanticVersion=-SNAPSHOT
1212
buildBy=local
1313
buildHash=
@@ -31,7 +31,7 @@ nexus.username=
3131
nexus.password=
3232
## --- Sonatype OSSRH
3333
#ossrh.snapshot.url=https://oss.sonatype.org/content/repositories/snapshots/
34-
ossrh.release.url=https://oss.sonatype.org/service/local/staging/deploy/maven2/
34+
ossrh.release.url=https://oss.sonatype.org/service/local/
3535
## --- GitHub Repo
3636
github.repo=zero88/scheduler.x
3737

0 commit comments

Comments
 (0)