001/**
002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com).
003 * <p>
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * <p>
008 * http://www.apache.org/licenses/LICENSE-2.0
009 * <p>
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package io.jboot.support.sentinel.datasource;
017
018import io.jboot.app.config.annotation.ConfigModel;
019import io.jboot.exception.JbootIllegalConfigException;
020import io.jboot.utils.StrUtil;
021
022@ConfigModel(prefix = "jboot.sentinel.datasource.apollo")
023public class ApolloDatasourceConfig {
024
025    private String serverAddress; // 例如: http://localhost:8080
026    private String appId;
027    private String namespaceName; // application
028    private String ruleKey = "jboot-sentinel-rule";
029    private String defaultFlowRules = "[]";
030
031    public String getServerAddress() {
032        return serverAddress;
033    }
034
035    public void setServerAddress(String serverAddress) {
036        this.serverAddress = serverAddress;
037    }
038
039    public String getAppId() {
040        return appId;
041    }
042
043    public void setAppId(String appId) {
044        this.appId = appId;
045    }
046
047    public String getNamespaceName() {
048        return namespaceName;
049    }
050
051    public void setNamespaceName(String namespaceName) {
052        this.namespaceName = namespaceName;
053    }
054
055    public String getRuleKey() {
056        return ruleKey;
057    }
058
059    public void setRuleKey(String ruleKey) {
060        this.ruleKey = ruleKey;
061    }
062
063    public String getDefaultFlowRules() {
064        return defaultFlowRules;
065    }
066
067    public void setDefaultFlowRules(String defaultFlowRules) {
068        this.defaultFlowRules = defaultFlowRules;
069    }
070
071    public void assertConfigOk() {
072        if (StrUtil.isAnyBlank(namespaceName, ruleKey)) {
073            throw new JbootIllegalConfigException("jboot.sentinel.datasource.apollo not config well in jboot.properties");
074        }
075    }
076}