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.redis")
023public class RedisDatasourceConfig {
024
025    private String host;
026    private int port = 6379;
027    private String password;
028    private int database = 0;
029    private String ruleKey = "jboot-sentinel-rule";
030    private String channel = "jboot-sentinel-channel";
031
032    public String getHost() {
033        return host;
034    }
035
036    public void setHost(String host) {
037        this.host = host;
038    }
039
040    public int getPort() {
041        return port;
042    }
043
044    public void setPort(int port) {
045        this.port = port;
046    }
047
048    public String getPassword() {
049        return password;
050    }
051
052    public void setPassword(String password) {
053        this.password = password;
054    }
055
056    public int getDatabase() {
057        return database;
058    }
059
060    public void setDatabase(int database) {
061        this.database = database;
062    }
063
064    public String getRuleKey() {
065        return ruleKey;
066    }
067
068    public void setRuleKey(String ruleKey) {
069        this.ruleKey = ruleKey;
070    }
071
072    public String getChannel() {
073        return channel;
074    }
075
076    public void setChannel(String channel) {
077        this.channel = channel;
078    }
079
080    public void assertConfigOk() {
081        if (StrUtil.isAnyBlank(host)) {
082            throw new JbootIllegalConfigException("jboot.sentinel.datasource.redis not config well in jboot.properties");
083        }
084    }
085}