package tech.easyflow.ai.support;

import com.easyagents.core.store.DocumentStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 文档向量库生命周期辅助工具。
 */
public final class DocumentStoreLifecycleSupport {

    private static final Logger LOG = LoggerFactory.getLogger(DocumentStoreLifecycleSupport.class);

    private DocumentStoreLifecycleSupport() {
    }

    /**
     * 关闭支持关闭语义的文档向量库。
     *
     * @param documentStore 文档向量库实例
     */
    public static void closeQuietly(DocumentStore documentStore) {
        if (!(documentStore instanceof AutoCloseable)) {
            return;
        }
        try {
            ((AutoCloseable) documentStore).close();
        } catch (Exception e) {
            LOG.warn("关闭文档向量库连接失败: store={}", documentStore.getClass().getSimpleName(), e);
        }
    }
}
