package com.lanyuanxiaoyao.service.sync.configuration;

import com.lanyuanxiaoyao.service.common.entity.TableMeta;
import java.io.Serializable;

/**
 * 同步静态配置
 *
 * @author ZhangJiacheng
 * @date 2022-06-13
 */
public class GlobalConfiguration implements Serializable {
    private final String cluster;
    private final String applicationId;
    private final Boolean metricEnable = false;
    private final String metricPublishUrl;
    private final String metricPublishPrometheusUrl;
    private final String metricsPublishCustomUrl;
    private final Integer metricPublishDelay;
    private final Integer metricPublishPeriod;
    private final Integer metricPublishTimeout;
    private final Integer metricPublishBatch;

    public GlobalConfiguration(String cluster, String applicationId, TableMeta meta) {
        this.cluster = cluster;
        this.applicationId = applicationId;
        this.metricPublishUrl = meta.getConfig().getMetricPublishUrl();
        this.metricPublishPrometheusUrl = meta.getConfig().getMetricPrometheusUrl();
        this.metricsPublishCustomUrl = meta.getConfig().getMetricApiUrl();
        this.metricPublishDelay = meta.getConfig().getMetricPublishDelay();
        this.metricPublishPeriod = meta.getConfig().getMetricPublishPeriod();
        this.metricPublishTimeout = meta.getConfig().getMetricPublishTimeout();
        this.metricPublishBatch = meta.getConfig().getMetricPublishBatch();
    }

    public String getCluster() {
        return cluster;
    }

    public String getApplicationId() {
        return applicationId;
    }

    public Boolean getMetricEnable() {
        return metricEnable;
    }

    public String getMetricPublishUrl() {
        return metricPublishUrl;
    }

    public String getMetricPublishPrometheusUrl() {
        return metricPublishPrometheusUrl;
    }

    public String getMetricsPublishCustomUrl() {
        return metricsPublishCustomUrl;
    }

    public Integer getMetricPublishDelay() {
        return metricPublishDelay;
    }

    public Integer getMetricPublishPeriod() {
        return metricPublishPeriod;
    }

    public Integer getMetricPublishTimeout() {
        return metricPublishTimeout;
    }

    public Integer getMetricPublishBatch() {
        return metricPublishBatch;
    }


    @Override
    public String toString() {
        return "GlobalConfiguration{" +
               "cluster='" + cluster + '\'' +
               ", applicationId='" + applicationId + '\'' +
               ", metricEnable=" + metricEnable +
               ", metricPublishUrl='" + metricPublishUrl + '\'' +
               ", metricPublishPrometheusUrl='" + metricPublishPrometheusUrl + '\'' +
               ", metricsPublishCustomUrl='" + metricsPublishCustomUrl + '\'' +
               ", metricPublishDelay=" + metricPublishDelay +
               ", metricPublishPeriod=" + metricPublishPeriod +
               ", metricPublishTimeout=" + metricPublishTimeout +
               ", metricPublishBatch=" + metricPublishBatch +
               '}';
    }
}
