zlt-mp v4.4.0 发布,基于 Spring Cloud Alibaba 的微服务平台

栏目: 软件资讯 · 发布时间: 3年前

内容简介:功能介绍 更新内容 特性/增强 新增工程zlt-oss-spring-boot-starter 新增工程zlt-zookeeper-spring-boot-starter 新增Zookeeper分布式锁 优化日志埋点工具类 升级zlt-register/nacos到2.0.0 内容说明 一、新增工程...

zlt-mp v4.4.0 发布,基于 Spring Cloud Alibaba 的微服务平台

功能介绍

zlt-mp v4.4.0 发布,基于 Spring Cloud Alibaba 的微服务平台

更新内容

特性/增强

  • 新增工程zlt-oss-spring-boot-starter
  • 新增工程zlt-zookeeper-spring-boot-starter
  • 新增Zookeeper分布式锁
  • 优化日志埋点 工具
  • 升级zlt-register/nacos到2.0.0

 

内容说明

一、新增工程oss-starter

既支持各种 「S3」 协议的对象存储如 阿里云OSS七牛云OSSMinIO 等,同时也支持阿里的 FastDFS

配置S3:

zlt:
  file-server:
    type: s3
    s3:
      access-key: ${zlt.s3.access-key}
      accessKeySecret: ${zlt.s3.accessKeySecret}
      endpoint: ${zlt.s3.endpoint}
      bucketName: ${zlt.s3.bucketName}

使用S3

@Resource
private S3Template s3Template;

s3Template.upload(...);

 

配置FastDFS:

zlt:
  file-server:
    type: fastdfs
    fdfs:
      web-url: ${zlt.fdfs.web-url}
      
fdfs:
  trackerList: ${zlt.fdfs.trackerList}

使用FastDFS

@Resource
private FdfsTemplate fdfsTemplate;

fdfsTemplate.upload(...);

 

二、新增工程zookeeper-starter

集成 curator 客户端

配置:

zlt:
  zookeeper:
    connectString: 127.0.0.1:2181

 

三、新增zookeeper分布式锁

依赖:

<dependency>
    <groupId>com.zlt</groupId>
    <artifactId>zlt-zookeeper-spring-boot-starter</artifactId>
</dependency>

配置:

zlt:
  lock:
    lockerType: ZK

手动加锁:

//lock
try (
        ZLock lock = locker.lock("test");
        ) {
    //......业务逻辑
}

//tryLock
try (
        ZLock lock = locker.tryLock("test"10, TimeUnit.SECONDS);
        ) {
    if (lock != null) {
        //......业务逻辑
    }
}

注解加锁:

/**
 * 等同于 locker.lock("test")
 */
@Lock(key = "test")
public void test() {}

/**
 * 等同于 locker.tryLock("test", 10, TimeUnit.SECONDS)
 */
@Lock(key = "test", waitTime = 10)
public void test2() {}

 

四、优化日志埋点工具类

埋点工具类 PointUtil 新增 「builder」 模式,如下代码所示:

Map properties = new HashMap(2);
properties.put("key1""value1");
properties.put("key2""value2");

PointUtil.builder()
        .id(1)
        .type("test")
        .properties(properties)
        .build();

输出日志:2021-04-03 23:18:19.112|user-center|1|test|key1=value1&key2=value2

 

五、升级zlt-register到2.0.0

zlt-register/nacos 替换为官方最新的 2.0.0 版本

内容与官网一致,只是方便大家直接使用

 

项目地址

Gitee地址: https://gitee.com/zlt2000/microservices-platform

Github地址: https://github.com/zlt2000/microservices-platform

项目文档

https://www.kancloud.cn/zlt2000/microservices-platform/919417

项目更新日志

https://www.kancloud.cn/zlt2000/microservices-platform/936235


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Pro JavaScript Design Patterns

Pro JavaScript Design Patterns

Dustin Diaz、Ross Harmes / Apress / 2007-12-16 / USD 44.99

As a web developer, you’ll already know that JavaScript™ is a powerful language, allowing you to add an impressive array of dynamic functionality to otherwise static web sites. But there is more power......一起来看看 《Pro JavaScript Design Patterns》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换