# swak **Repository Path**: junezero/swak ## Basic Information - **Project Name**: swak - **Description**: SWAK架构基于 Spring Boot2构建微服务架构,集成通用的基础技术模块和业务模块,快速搭建可直接部署。统一的接口出入参和公共规范,支持多业务多场景扩展点,支持容错,限流,隔离,集成通用工具类,支持白名单,穿越预演能力。 文档:https://mcolley.gitee.io/swak - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://mcolley.gitee.io/swak/#/ - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2023-03-30 - **Last Updated**: 2023-03-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SWAK架构 ## SWAK概要 SWAK架构基于 Spring Boot2构建微服务架构,集成通用的基础技术模块和业务模块,快速搭建可直接部署。统一的接口出入参和公共规范,支持多环境多机房,支持多业务多场景扩展点,支持容错,限流,隔离,兜底,支持接口监控业务监控。集成通用工具类,支持白名单,穿越预演能力。 SWAK分为三个部分,SWAK架构、SWAK组件以及SWAK脚手架。 文档地址:https://mcolley.gitee.io/swak/ ### SWAK架构图: ![SWAK架构图](docs/image/swakFrame.png) ### Latest Version: [![Maven Central](https://img.shields.io/maven-central/v/io.gitee.mcolley/swak-core.svg)](https://search.maven.org/search?q=g:io.gitee.mcolley%20a:swak*) ``` xml io.gitee.mcolley swak-bom Latest Version pom import io.gitee.mcolley swak-spring-boot-starter Latest Version ``` ### 依赖中间件版本 中间件名称 | 版本 |备注 ------ | ---- | ---- `spring boot` | 2.5.7 | spring boot `spring` | 5.3.13 | spring `log4j` | 2.17.1 | log4j2 `UMP` | 6.2.13 | UMP监控 `JSF/dubbo`| xx | rpc服务 `MQ` | xxx |RabbitMQ `redis` | xx |redis服务 `DSCC` | 0.0.2|自研配置中心 ### SWAK脚手架 我们提供了两个`archetype`,[SWAK脚手架使用](https://mcolley.gitee.io/swak/#/archetype) 点击了解详情。 具体如下: 1. `swak-archetype-service`:用来创建纯后端服务的`archetype`。 2. `swak-archetype-web`:用来创建`adapter`和后端服务一体的`web`应用`archetype`。 ### SWAK Components 此外,我们还提供了一些非常有用的通用组件,这些组件可以帮助我们提升研发效率。 这些功能组件被收拢在[` swak-components`目录](https://mcolley.gitee.io/swak/#/components/swak-component-catchlog)下面。到目前为止,我们已经沉淀了以下组件: 组件名称 | 功能 | 版本 | 依赖 ------ |----------------------------------|-------| ---- [swak-component-catchlog-starter](https://mcolley.gitee.io/swak/#/components/swak-component-catchlog)| 统一log日志处理 | 1.0.0 |无 [swak-component-extension-starter](https://mcolley.gitee.io/swak/#/components/swak-component-extension)| 扩展点组件-集成到core | 1.0.0 |无 `swak-component-config-starter` | 配置组件 | 1.0.0 |依赖DUCC/阿波罗 [swak-component-swagger-starter](https://mcolley.gitee.io/swak/#/components/swak-component-swagger) | 统一API接口生成组件 | 1.0.0 |swagger `swak-component-monitor-starter` | 监控组件 | 1.0.0 | ump或者扩展其它监控 `swak-component-redis-starter` | 缓存组件 | 1.0.0 |redis/eache/Caffeine [swak-component-distributedlock-starter](https://mcolley.gitee.io/swak/#/components/swak-component-distributedlock) | 分布式锁组件 | 1.0.0 |redis [swak-component-extspringcache-starter](https://mcolley.gitee.io/swak/#/components/swak-component-extspringcache) | 多级缓存组件 | 1.0.0 |redis/eache/Caffeine [swak-component-database-starter](https://mcolley.gitee.io/swak/#/components/swak-component-database) | 数据库组件,支持多数据源和读写分离 | 1.0.0 |无 [swak-component-datarchive-starter](https://mcolley.gitee.io/swak/#/components/swak-component-datarchive)| 历史数据归档组件 | 1.0.0 |无 [swak-component-filter-starter](https://mcolley.gitee.io/swak/#/components/swak-component-filter) | 基于spi的服务链处理,登录,限流,风控等(ApiFilter) | 1.0.0 |无 [swak-component-hystrix-starter](https://mcolley.gitee.io/swak/#/components/swak-component-hystrix) | 兜底容错组件 | 1.0.0 |hystrix [swak-component-ratelimit-starter](https://mcolley.gitee.io/swak/#/components/swak-component-ratelimit) | 限流组件 | 1.0.0 |本地限流/redis分布式限流 `swak-component-rpc-starter` | rpc组件,可扩展duboo等 | 1.0.0 |jsf或则dubbo `swak-component-channel-starter` | 多渠道组件 | 1.0.0 |多渠道服务 `swak-component-domain-starter` | Spring托管的领域实体组件 | 1.0.0 |无 `swak-component-sso-starter` | sso登录组件 | 1.0.0 |无 `swak-easyjob-boot-starter` | 嵌入式分布式任务调度 | 1.0.0 |无 `swak-excel-boot-starter` | excel处理 | 1.0.0 |无 ## SWAK基础架构 ### 原理 swak-framework 目前是版本号3.0.0-SNAPSHOT,集成通用的工具类和基础架构,是所有组件的基础架构依赖。 ### 架构模块 名称 | 功能 | 版本 | 依赖 ------ | ---- |-------| ---- `swak-common` | swakframe公共库,包含dto,exception等 | 1.0.0 |无 `swak-core` | swakframe核心库 | 1.0.0 |无 `swak-mybatis` | mybatis的封装 | 1.0.0 |依赖mybatis的封装 `swak-cache` | swakframe多级缓存 | 1.0.0 |无 `swak-spring-boot-starter` | swakframe的springboot autoconfigure | 1.0.0 | 无 ### 主要功能 - 基于时间轮的RefreshConfigurable自动刷新缓存解决方案。' - 入参统一封装为RpcParamRequest。body中的参数获取提供多种获取方式。getStrPara,getLongPara,getIntegerPara等。 - 增加统一的接口出入参和公共规范(ApiResponse、SysRestCode、RpcParamRequest等) - 增加monitor监控(内存监控、内存分代监控、系统运行时数据监控、垃圾回收已经nioBuffer等) - 基 于Eventbus机制的异步处理方案。(分异步和同步等) - 基于excel的处理工具封装(包含解析和生成等) - 统一异常封装返回(ApiException等)SwakAssert断言,ApiExceptionUtil等异常处理。 - 基于责任连的封装(FilterChain,Filter,FilterChainFactory)适配SPI模式。 - 增加基于 spring的RestTemplate的封装SwakRestTemplate,默认OKHttpClient ```xml SwakRestTemplate restTemplate = RestTemplateBuilder.newBuilder().setConnectTimeout(1000) .setReadTimeout(1000).setWriteTimeout(2000).build(); JSONObject result = restTemplate.postRequest(url,uriVariables,JSONObject.class); ``` - qps和白名单等抽象封装,提供扩展接口自己实现。 - 基于服务注解和自动注册单机限流LimitRater解决方案。 - 基于hystrix的隔离,容错,兜底的解决方案。 - 基于spring async异步封装。增加统一的线程池来实现spring async和增加线程池的监控。 - 提供@ExtCacheable多级缓存方案。 - 基于sql的ID生产器方案。 - 基于sso+shrio的权限控制解决方案。 - 重写ydd数据库等操作,实现读写分离。 - 通过swagger自动生成接口文档。集成Swagger实现接口文档可视化。 - 统一封装ump监控(包含自定义监控和业务监控)把ump自定义监控和业务监控采用异步的方式集成到BizAlarmAdapter中。使开发中方便使用。和不影响业务逻辑。 #### 使用说明文档 1. [Swak使用文档](https://mcolley.gitee.io/swak/#/) 2. xxxx 3. xxxx #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)