All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.soffa.foundation.core.data.DB Maven / Gradle / Ivy

package io.soffa.foundation.core.data;

import io.soffa.foundation.core.models.TenantId;
import io.soffa.foundation.errors.TodoException;

import javax.sql.DataSource;
import java.time.Duration;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;

public interface DB {

    void createSchema(String linkId, String schema);

    boolean tenantExists(String tenant);

    default DataSource determineTargetDataSource() {
        return determineTargetDataSource(TenantId.INHERIT);
    }

    DataSource determineTargetDataSource(TenantId tenant);

    String getTablesPrefix();

    default Set getTenantList() {
        return new HashSet<>();
    }

    default void withTenants(Consumer consumer) {
        throw new TodoException();
    }

    default void withTenantsAsync(Consumer consumer) {
        throw new TodoException();
    }

    default void configureTenants() {
        // Implementation not required
    }

    default void configureTenantsAsync() {
        // Implementation not required
    }

    default void register(String[] names, boolean migrate) {
        // Implementation not required
    }

    default void withLock(String name, int atMostSeconds, int atLeastSeconds, Runnable runnable) {
        withLock(name, Duration.ofSeconds(atMostSeconds), Duration.ofSeconds(atLeastSeconds), runnable);
    }

    void withLock(String name, Duration atMost, Duration atLeast, Runnable runnable);

    default DataStore newStore() {
        throw new TodoException("Implement me");
    }

    default  EntityRepository newEntityRepository(Class entityClass) {
        throw new TodoException("Implement me");
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy