new abstract method for volumepath

This commit is contained in:
Renan Bernordi
2025-11-16 17:47:23 -03:00
parent ff16c6914d
commit 14dadc85e7
14 changed files with 112 additions and 84 deletions

View File

@@ -4,6 +4,7 @@ import { logger } from "../../../utils/logger";
import { testMariaDBConnection } from "../../../utils/database-dump";
import type { VolumeBackend } from "../backend";
import { BACKEND_STATUS, type BackendConfig } from "~/schemas/volumes";
import { VOLUME_MOUNT_BASE } from "../../../core/constants";
const mount = async (config: BackendConfig, volumePath: string) => {
if (config.backend !== "mariadb") {
@@ -50,8 +51,15 @@ const checkHealth = async (config: BackendConfig) => {
}
};
export const makeMariaDBBackend = (config: BackendConfig, volumePath: string): VolumeBackend => ({
export const makeMariaDBBackend = (config: BackendConfig, volumeName: string, volumePath: string): VolumeBackend => ({
mount: () => mount(config, volumePath),
unmount: () => unmount(volumePath),
checkHealth: () => checkHealth(config),
getVolumePath: () => volumePath,
isDatabaseBackend: () => true,
getDumpPath: () => `${VOLUME_MOUNT_BASE}/${volumeName}/dumps`,
getDumpFilePath: (timestamp: number) => {
const dumpDir = `${VOLUME_MOUNT_BASE}/${volumeName}/dumps`;
return `${dumpDir}/${volumeName}-${timestamp}.sql`;
},
});