• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

smarten: 高性能的分布式配置管理中心

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

smarten

开源软件地址:

https://gitee.com/abocode-source/smarten

开源软件介绍:

smarten

高性能的分布式配置管理中心

  • 配置管理中心提供系统参数配置管理,例如业务数据开关、数据库的配置信息等,配置参数修改以后可以实时推送到客户端(业务系统或者服务),方便系统动态修改运行参数。
  • 支持多个业务系统,每个系统可以配置多种环境如:(development、test、production)。
  • 所有参数由development environment配置,test和production 继承development environment配置,也可以覆盖其配置,test和production environment只提供修改功能。
  • 业务系统会缓存配置信息到本地文件系统,如果server不可用,可以使用本地备份。client 能够定时重连server,保证配置中心可用。
  • 配置中心备份配置到文件系统,如果数据库不用,能够保证对客户端提供配置信息。

HOW 怎么使用:

  • 启动服务

在项目中smarten-server-web运行SmartenServer.java

HOW 项目中集成:

  • POM配置
  <dependency>        <groupId>com.abocode.smarten</groupId>        <artifactId>smarten-client</artifactId>        <version>${project.parent.version}</version>   </dependency>

方式一:spring mvc Controller

    @Slf4j    @RestController    @RequestMapping("/tests")    public class HelloController {        @Autowired       private Properties properties;        @Value(" ${string}")        private String  val;        @GetMapping        public String hello() {            return properties.getProperty("string");        }    }    

方式二

    String host="127.0.0.1";    int port=5555;    String projectCode="smarten";    String moduleCodes="smarten-test"; //多个用逗号隔开    String profile="development";    ClientProperties clientProperties = new ClientProperties(host,port,projectCode,moduleCodes,profile);    clientProperties.addConfigurationListener(new ConfigTestListener());    for (int i=0;i<100000;i++){        Thread.sleep(2000);        System.out.println(clientProperties.getString("string"));    }

方式三:spring boot

    @Bean    public Properties properties() {         String host="127.0.0.1";         int port=5555;         String projectCode="smarten";         String moduleCodes="smarten-test"; //多个用逗号隔开         String profile="development";        return new ClientProperties(host,port,projectCode,moduleCodes,profile).getProperties();    }    @Bean    public  PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){        PropertySourcesPlaceholderConfigurer bean=new PropertySourcesPlaceholderConfigurer();        bean.setProperties(properties());       return bean;    }    

Rest 接口获取配置:

配置信息:

http://127.0.0.1:7077/swagger-ui.html

测试链接:

http://127.0.0.1:7078/swagger-ui.html


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap