11 Star 27 Fork 7

apple888 / platform

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

彩虹微服务中台

介绍

彩虹中台服务基于springCloudAlibaba+SpringCloud+SpringBoot开发的一套微服务集中式组件,为其他业务微服务系统提供一键接入微服务的能力,方便项目管理与维护!  项目示例

中台概述

彩虹中台提供微服务权限和任务集中管理,集成微服务管理可视化组件,为微服务提供一键落地的快速部署方案,感兴趣请联系我!,邮箱:1335157415@qq.com

相关链接

中台控制台  彩虹商城

依赖工具

依赖环境

jdk(1.8/11)+maven3.0+nexus3.9.0+nacos2.1.2+mysql5.7+pgsql-14

版本说明

彩虹中台 SpringCloud SpringCloudAlibaba SpringBoot
1.0.0.RELEASE Spring Cloud Hoxton.SR9 2.2.6.RELEASE 2.3.12.RELEASE
2.0.0.RELEASE Spring Cloud Hoxton.SR12 2.2.9.RELEASE 2.3.12.RELEASE
3.0.0.RELEASE Spring Cloud 2021.0.4 2021.0.4.0 2.6.11
4.0.0.RELEASE Spring Cloud 2021.0.5 2021.0.5.0 2.6.13

系统架构

系统架构

权限设计

权限设计

技术架构

● 系统核心框架:SpringCloud.Hoxton.SR12
● 系统核心框架:SpringCloudAlibaba2.2.9.RELEASE
● 系统核心框架:SpringBoot2.3.12.RELEASE
● 服务配置注册:Nacos2.1.2
● 服务流量管控:Sentinel1.8.5
● 事务处理框架:Seata1.5.2
● 定时任务调度:XxlJob2.3.0
● 服务链路追踪:SkyWalking8.7.0
● 数据持久框架:MyBatis-plus3.4.3.4
● 系统监控插件:SpringBootAdmin2.3.1
● 时序数据处理:InfluxDb1.8.0
● 系统缓存处理:Redis5.0.5
● 分布式业务键:美团Leaf
● 灰度发布组件:Nepxion6.21.0
● 分布式线程锁:Redisson3.17.2
● 分布式限流器:Redisson3.17.2
● 系统消息队列:RocketMq5.1.0
● 安全授权框架:Oauth2+Jwt 
● 对象文件存储:Minio(推荐OSS/S3)
● 接口文档工具:Yapi/Knife4j
● 代码分析插件:SonarQube9.0.1
● 项目文件服务:Gitlab/Gitea
● 项目文档工具:语雀+Jira(wiki)
● 项目管理工具:禅道/Jira
● EXCEL工具包:EasyExcel3.0.5

项目结构

platform

├─framwork 彩虹中台微服务组件
│  │
│  ├─document    彩虹中台初始化文档
│  │
│  ├─dependencies 彩虹中台组件依赖声明
│  │
│  ├─common 彩虹中台微服务公共组件
│  │   ├─common-core    微服务公共核心组件
│  │   ├─common-event   微服务事件总线组件
│  │   ├─common-frame   微服务基础公共依赖
│  │   ├─common-handler 微服务公共拦截组件
│  │   └─common-remote  微服务远程调用组件
│  │
│  └─support 彩虹中台微服务组件增强模块
│      ├─base-support-spring-boot-starter   服务增强公共依赖组件库
│      ├─cache-mongdb-spring-boot-starter   Mongdb内存缓存组件模块
│      ├─redis-enhance-spring-boot-starter  Redis增强缓存处理模块
│      ├─influxdb-extra-spring-boot-starter Influxdb时序处理模块
│      ├─lock-zookeeper-spring-boot-starter Zookeeper分布式锁块
│      ├─message-notify-spring-boot-starter 通用消息通知处理模块
│      ├─minio-storage-spring-boot-starter  Minio分布式存储模块
│      ├─mybatis-extra-spring-boot-starter  MybatisPlus增强模块
│      ├─action-printer-spring-boot-starter 服务通用日志处理模块 
│      ├─task-compose-spring-boot-starter   任务组合编排处理模块
│      ├─half-message-spring-boot-starter   RocketMq半事务模块 
│      ├─csrf-defender-spring-boot-starter  Csrf安全防御处理模块       
│      ├─seata-enhance-spring-boot-starter  Seata统一配置的模块
│      ├─gray-selector-spring-boot-starter  版本号负载均衡模块
│      └─xxljob-extra-spring-boot-starter   分布式的任务调度模块

├─dashboard 彩虹中台可视化组件
│  ├─document    中台可视化组件文档
│  ├─visual-authority 微服务后台用户权限维护系统   端口:8000
│  ├─visual-monitor   SpringBootAdmin服务监控  端口:8010
│  ├─visual-autocode  微服务Mysql代码的生成工具   端口:8020
│  ├─visual-xxl-job   XxlJob分布式任务控制台     端口:8030
│  ├─visual-sentinel  sentinel服务熔断器控制台   端口:8040
│  └─visual-codepgsql  微服务Pgsql代码的生成工具  端口:8050

使用示例

Maven引入依赖

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.rainbow.framework</groupId>
                <artifactId>dependencies</artifactId>
                <version>${lastestVersion}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

快速启动

  • 1.启动系统之前,请仔细参考中台部分的doc文档,了解系统的信息,快速入门上手使用。
  • 2.在顶层的pom.xml配置好,对应的服务参数,先执行mvn versions:set -DnewVersion=1.0.0.RELEASE,在执行mvn -N versions:update-child-modules,最后执行maven clean install打包。
  • 3.按照2步骤打包完毕,依次启动对应的中台服务,即可对外提供对应的业务服务。
  • 4.中台的微服务接入示例,请参考用户服务

注意事项

  • 1 项目发版时,设置统一版本号可以在顶级pom.xml,在maven中运行:mvn versions:set -DnewVersion=1.0.1-SNAPSHOT,然后mvn -N versions:update-child-modules控制台会打印All child modules are up to date.表示所有版本号已修改,最后执行:mvn:clean install -DskipTests 版本统一更新

  • 2 项目发版时,versions-maven-plugin在最顶级POM,从(dev,fat,uat,pro)选择一个profile打包,整个项目会统一打包成对应环境程序

  • 3 微服务需要在网关接口的header传递对应版本号和clientId还有token,header被Nepxion启动版本灰度发布,clientId鉴权认证服务验证token合法性,当三者满足时,才允许请求通过。

  • 4 权限管理服务采用pb_cms,后台配置的微服务系统资源数据,微服务授权登录时,可直接读取权限资源并鉴权处理,可生产环境使用该项目。

  • 5 微服务权限认证,采用resetTemplate集成loadbanlce方式远程请求,需要跟微服务环境配置在相同的nacos的namespace中便于负载均衡,微服务鉴权auth和gateway放在微服务端,一起部署到相同nacos的namespace

  • 6 部署在线LEAF,微服务集中UUID生成中心,提供号段和雪花两种模式,集中生成对应的业务唯一编号。体验地址为:leaf

  • 7 中台采用sentinel作为熔断降级处理方案,微服务代码块需要注意关闭hystrix熔断降级的处理方案,切换到sentinel的模式下的熔断降级处理解决方案。

  • 8 common-core添加全局自定义参数验证方法,需要个性化验证统一自己写验证处理逻辑,手机号验证代码示例如下:public class PhoneValidHandler extends DefaultValidHandler{}

  • 9 添加i18n国际化支持,common-core里面只是写了部分国际化配置,具体微服务里面需要写自己的国际化配置文件,程序国际化响应以微服务配置为准,国际化参数是在header传递(Accept-Language=zh-CN/en-US)切换中英文。

  • 10 集成mongdb和influxdb内存缓存和时序数据库支持,配置springBootAdmin集成钉钉机器人,调整springBootAdmin组件代码结构,增加mybatis代码增强组件工具。

  • 11 提供minio对象存储组件包,线上演示环境可以体验minio简单存储的快捷使用,生产环境建议采用阿里OSS或者亚马逊S3对象存储服务功能,大厂花钱的产品还是靠谱滴

  • 12 新增message消息通知模块,方便快捷集成与使用,目前支持email和钉钉消息两种通知方式,具体使用示例请参考对应message-notify-spring-boot-starter的readme.md文档说明

  • 13 mysql数据库的时间戳推荐使用timestamp,不推荐使用datetime。seata1.4.2针对datetime反序列化存在无法解析的问题,同时涉及UTC国际化处理时datetime也不方便,建议使用timestamp。

  • 14 feign调用时,被调用方出现异常的时候,默认会被全局异常处理掉,此时处理结果向发起方返回时,会提示feign.decode的类型不一致异常,这个属于正常的情况,如果需要正确返回可以自己捕获异常然后返回或者降级处理。

  • 15 引入数据库文档处理工具screw,方便快速生成数据库的文档结构,建议针对废弃的表和备份表分别采用不同的后缀来区分,比如备份表:as_assets_20220330_bak表示备份表

  • 16 使用sentinel做服务熔断处理时,接口资源被流控处理时,此时资源会直接被拒绝请求,建议添加degrade方法处理,可以在degrade里面知道熔断了,后续可以显示的抛出异常或者提示处理等。

  • 17 配置统一valid,方便快捷自定义控制层入参校验,使用@NeedCustomValid(required = true,message = "user.phone.notnull",customHandlerClass = PhoneValidHandler.class)标注在字段上,示例请参考彩虹商城服务;

  • 18 配置统一rocketMq半事务消息处理,消息生产者和消息消费者可快速接入使用,两方只需要关注本地业务处理即可,组件封装了消费者幂等处理逻辑。半事务消息体的JSON字符串中必须含字段{"globalId":"全局事务id","branchId":"分支事务id"},否则系统会报错。

  • 19 对于延迟处理的方式,在用户服务示例中,已经分别接入rocketMq延迟队列和redis过期时间监听两种方式皆可实现,基于消息可靠性而言建议采用rocketMq的延迟消息方式处理,配合spring-retry模块,可以在延迟消费失败时,优雅重试。

  • 20 中台封装了统一批量更新处理(拼接多条更新sql,最终每次1000条执行,返回结果1),若需要保证更新数据时,严格一致性(比如:更新一批数据中存在一条更新失败,mybatis更新失败返回0,并不会报错,此种场景下数据不存在导致),避免此问题场景建议更新之前检查好数据,出现不存在抛异常处理。

  • 21 中台封装了统一批量更新和新增处理,时间格式采用Instant接收,(mysql时间戳到微秒无法直接接收Instant的默认纳秒需要转换成微秒),pgsql可以正常接收处理,框架目前支持mysql和pgsql其他数据库敬请期待.............

  • 22 服务熔断建议采用sentinel方式,在需要降级处理的方法上加上@SentinelResource注解方式来配置对应降级处理逻辑,实例参考用户服务

项目截图

版本打包: 版本更新
用户服务: 用户服务
SpringBootAdmin: boot-admin
钉钉告警: 钉钉告警
Leaf号段: leaf
sentinel: sentinel
xxlJob: xxlJob
SonarQube: SonarQube

加入我们

  • 钉钉群 钉钉群 微信群微信群

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

微服务基础中台组件库,其他业务微服务仅需要依赖对应中台组件 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/bootstrap2table/platform.git
git@gitee.com:bootstrap2table/platform.git
bootstrap2table
platform
platform
master

搜索帮助