-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jdbc): first implementation of jdbc runner
- Loading branch information
1 parent
8b3fcbd
commit 6ea7118
Showing
29 changed files
with
1,043 additions
and
60 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
45 changes: 45 additions & 0 deletions
45
core/src/main/java/io/kestra/core/runners/DefaultFlowExecutor.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,45 @@ | ||
package io.kestra.core.runners; | ||
|
||
import io.kestra.core.models.flows.Flow; | ||
import io.kestra.core.repositories.FlowRepositoryInterface; | ||
import io.kestra.core.services.FlowListenersInterface; | ||
import lombok.Setter; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class DefaultFlowExecutor implements FlowExecutorInterface { | ||
private final FlowRepositoryInterface flowRepositoryInterface; | ||
@Setter | ||
private List<Flow> allFlows; | ||
|
||
public DefaultFlowExecutor(FlowListenersInterface flowListeners, FlowRepositoryInterface flowRepositoryInterface) { | ||
this.flowRepositoryInterface = flowRepositoryInterface; | ||
flowListeners.listen(flows -> { | ||
this.allFlows = flows; | ||
}); | ||
} | ||
|
||
@Override | ||
public Collection<Flow> allLastVersion() { | ||
return this.allFlows; | ||
} | ||
|
||
@Override | ||
public Optional<Flow> findById(String namespace, String id, Optional<Integer> revision) { | ||
Optional<Flow> find = this.allFlows | ||
.stream() | ||
.filter(flow -> flow.getNamespace().equals(namespace) && | ||
flow.getId().equals(id) && | ||
(revision.isEmpty() || revision.get().equals(flow.getRevision())) | ||
) | ||
.findFirst(); | ||
|
||
if (find.isPresent()) { | ||
return find; | ||
} else { | ||
return flowRepositoryInterface.findById(namespace, id, revision); | ||
} | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
core/src/main/java/io/kestra/core/runners/MemoryFlowExecutor.java
This file was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
jdbc-mysql/src/main/java/io/kestra/runner/mysql/MysqlExecutorStateStorage.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,15 @@ | ||
package io.kestra.runner.mysql; | ||
|
||
import io.kestra.jdbc.runner.AbstractExecutorStateStorage; | ||
import io.kestra.jdbc.runner.JdbcExecutorState; | ||
import io.kestra.repository.mysql.MysqlRepository; | ||
import io.micronaut.context.ApplicationContext; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
@MysqlQueueEnabled | ||
public class MysqlExecutorStateStorage extends AbstractExecutorStateStorage { | ||
public MysqlExecutorStateStorage(ApplicationContext applicationContext) { | ||
super(new MysqlRepository<>(JdbcExecutorState.class, applicationContext)); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
jdbc-mysql/src/test/java/io/kestra/runner/mysql/MysqlRunnerTest.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,7 @@ | ||
package io.kestra.runner.mysql; | ||
|
||
import io.kestra.jdbc.runner.JdbcRunnerTest; | ||
|
||
public class MysqlRunnerTest extends JdbcRunnerTest { | ||
|
||
} |
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
15 changes: 15 additions & 0 deletions
15
jdbc-postgres/src/main/java/io/kestra/runner/postgres/PostgresExecutorStateStorage.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,15 @@ | ||
package io.kestra.runner.postgres; | ||
|
||
import io.kestra.jdbc.runner.AbstractExecutorStateStorage; | ||
import io.kestra.jdbc.runner.JdbcExecutorState; | ||
import io.kestra.repository.postgres.PostgresRepository; | ||
import io.micronaut.context.ApplicationContext; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
@PostgresQueueEnabled | ||
public class PostgresExecutorStateStorage extends AbstractExecutorStateStorage { | ||
public PostgresExecutorStateStorage(ApplicationContext applicationContext) { | ||
super(new PostgresRepository<>(JdbcExecutorState.class, applicationContext)); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
jdbc-postgres/src/test/java/io/kestra/runner/postgres/PostgresRunnerTest.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,7 @@ | ||
package io.kestra.runner.postgres; | ||
|
||
import io.kestra.jdbc.runner.JdbcRunnerTest; | ||
|
||
public class PostgresRunnerTest extends JdbcRunnerTest { | ||
|
||
} |
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
Oops, something went wrong.