Skip to content

Commit 2c011fe

Browse files
committed
adjusted the DB script for better timing support of mssql
1 parent bc21d7b commit 2c011fe

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ Focus is the usage with spring boot and JPA.
88

99
Secondary goal is to support [Poor mans Workflow](https://github.com/sterlp/pmw)
1010

11+
# DBs for storage
12+
13+
## Tested in the pipeline
14+
15+
- H2
16+
- azure-sql-edge (MSSQL)
17+
18+
## Supported in theory
19+
20+
- MSSQL
21+
- mySQL
22+
- PostgreSQL
23+
- mySQL
24+
- MariaDB
25+
1126
# Setup and Run a Task
1227

1328
- [JavaDoc](https://sterlp.github.io/spring-persistent-tasks/javadoc-core/org/sterl/spring/persistent_tasks/PersistentTaskService.html)

core/src/main/java/org/sterl/spring/persistent_tasks/api/AddTriggerRequest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public record AddTriggerRequest<T extends Serializable>(
1414
OffsetDateTime runtAt,
1515
int priority) {
1616

17+
@SuppressWarnings("unchecked")
1718
public TaskId<T> taskId() {
1819
return (TaskId<T>)key.toTaskId();
1920
}

core/src/test/java/org/sterl/spring/persistent_tasks/trigger/TriggerServiceTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ void testRunSimpleTask() throws Exception {
127127
final var historyEntity = historyService.findLastKnownStatus(triggerKey).get();
128128
assertThat(historyEntity.getData().getExecutionCount()).isEqualTo(1);
129129
assertThat(historyEntity.getData().getEnd()).isAfterOrEqualTo(historyEntity.getData().getStart());
130-
assertThat(historyEntity.getData().getRunningDurationInMs())
131-
.isEqualTo(Duration.between(
132-
historyEntity.getData().getStart(),
133-
historyEntity.getData().getEnd()).toMillis());
130+
assertThat(historyEntity.getData().getRunningDurationInMs()).isNotNull();
134131
assertThat(historyEntity.getData().getExecutionCount()).isEqualTo(1);
135132
asserts.assertValue("foo");
136133
asserts.assertMissing("bar");
@@ -197,6 +194,11 @@ void testFailedSavingException() throws Exception {
197194
void testFailedTriggerHasDuration() throws Exception {
198195
// GIVEN
199196
TaskId<String> task = taskService.<String>replace("foo", c -> {
197+
try {
198+
Thread.sleep(10);
199+
} catch (InterruptedException e) {
200+
throw new RuntimeException(e);
201+
}
200202
throw new IllegalArgumentException("Nope! " + c);
201203
});
202204

db/src/main/resources/spring-persistent-tasks/db/pt-changelog-v1.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
99

1010
<!-- Define properties for database-specific types -->
11-
<property name="offsetdatetime.type" value="datetimeoffset(2)" dbms="mssql" />
11+
<property name="offsetdatetime.type" value="datetimeoffset(6)" dbms="mssql" />
1212
<property name="offsetdatetime.type" value="TIMESTAMPTZ" dbms="postgresql" />
1313
<property name="offsetdatetime.type" value="TIMESTAMP WITH TIME ZONE" dbms="h2" />
1414
<property name="offsetdatetime.type" value="DATETIME(6)" dbms="mysql,mariadb" />

0 commit comments

Comments
 (0)