mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-25 02:14:38 -05:00
feat(system): add a lock mechanism
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package io.kestra.repository.postgres;
|
||||
|
||||
import io.kestra.core.lock.Lock;
|
||||
import io.kestra.jdbc.AbstractJdbcRepository;
|
||||
import io.kestra.jdbc.repository.AbstractJdbcLockRepository;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
@PostgresRepositoryEnabled
|
||||
public class PostgresLockRepository extends AbstractJdbcLockRepository {
|
||||
public PostgresLockRepository(@Named("locks") AbstractJdbcRepository<Lock> jdbcRepository) {
|
||||
super(jdbcRepository);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS locks (
|
||||
key VARCHAR(250) NOT NULL PRIMARY KEY,
|
||||
value JSONB NOT NULL,
|
||||
category VARCHAR(250) NOT NULL GENERATED ALWAYS AS (value ->> 'category') STORED,
|
||||
id VARCHAR(150) NOT NULL GENERATED ALWAYS AS (value ->> 'id') STORED,
|
||||
owner VARCHAR(150) NOT NULL GENERATED ALWAYS AS (value ->> 'owner') STORED
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS locks__catefory_id ON locks (category, id);
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.kestra.repository.postgres;
|
||||
|
||||
import io.kestra.core.repositories.AbstractLockRepositoryTest;
|
||||
|
||||
public class PostgresRepositoryTest extends AbstractLockRepositoryTest {
|
||||
}
|
||||
Reference in New Issue
Block a user