package com.ytpm.lemonios.config.datasource;


import com.ytpm.app.enums.DataSourceType;

public class DynamicDataSourceContextHolder {
    private static final ThreadLocal<DataSourceType> CONTEXT = new ThreadLocal<>();

    public static void setDataSourceType(DataSourceType type) {
        CONTEXT.set(type);
    }

    public static DataSourceType getDataSourceType() {
        return CONTEXT.get() == null ? DataSourceType.MASTER : CONTEXT.get();
    }

    public static void clear() {
        CONTEXT.remove();
    }
}
