diff --git a/.gitbook/assets/1623316769(1).jpg b/.gitbook/assets/1623316769(1).jpg new file mode 100644 index 000000000..9d3bfaba5 Binary files /dev/null and b/.gitbook/assets/1623316769(1).jpg differ diff --git a/.gitbook/assets/1623316875(1) (1).jpg b/.gitbook/assets/1623316875(1) (1).jpg new file mode 100644 index 000000000..1769edd1c Binary files /dev/null and b/.gitbook/assets/1623316875(1) (1).jpg differ diff --git a/.gitbook/assets/1623316875(1).jpg b/.gitbook/assets/1623316875(1).jpg new file mode 100644 index 000000000..1769edd1c Binary files /dev/null and b/.gitbook/assets/1623316875(1).jpg differ diff --git a/.gitbook/assets/image (1).png b/.gitbook/assets/image (1).png new file mode 100644 index 000000000..8a939cf05 Binary files /dev/null and b/.gitbook/assets/image (1).png differ diff --git a/.gitbook/assets/image (10).png b/.gitbook/assets/image (10).png new file mode 100644 index 000000000..c8cd61baa Binary files /dev/null and b/.gitbook/assets/image (10).png differ diff --git a/.gitbook/assets/image (11).png b/.gitbook/assets/image (11).png new file mode 100644 index 000000000..c8cd61baa Binary files /dev/null and b/.gitbook/assets/image (11).png differ diff --git a/.gitbook/assets/image (12).png b/.gitbook/assets/image (12).png new file mode 100644 index 000000000..97b67f133 Binary files /dev/null and b/.gitbook/assets/image (12).png differ diff --git a/.gitbook/assets/image (13).png b/.gitbook/assets/image (13).png new file mode 100644 index 000000000..97b67f133 Binary files /dev/null and b/.gitbook/assets/image (13).png differ diff --git a/.gitbook/assets/image (14).png b/.gitbook/assets/image (14).png new file mode 100644 index 000000000..61cedd90a Binary files /dev/null and b/.gitbook/assets/image (14).png differ diff --git a/.gitbook/assets/image (15).png b/.gitbook/assets/image (15).png new file mode 100644 index 000000000..60321cf7c Binary files /dev/null and b/.gitbook/assets/image (15).png differ diff --git a/.gitbook/assets/image (16).png b/.gitbook/assets/image (16).png new file mode 100644 index 000000000..0dbda9ace Binary files /dev/null and b/.gitbook/assets/image (16).png differ diff --git a/.gitbook/assets/image (17).png b/.gitbook/assets/image (17).png new file mode 100644 index 000000000..66d2939b0 Binary files /dev/null and b/.gitbook/assets/image (17).png differ diff --git a/.gitbook/assets/image (18).png b/.gitbook/assets/image (18).png new file mode 100644 index 000000000..10a9428ac Binary files /dev/null and b/.gitbook/assets/image (18).png differ diff --git a/.gitbook/assets/image (19).png b/.gitbook/assets/image (19).png new file mode 100644 index 000000000..b648e5257 Binary files /dev/null and b/.gitbook/assets/image (19).png differ diff --git a/.gitbook/assets/image (2).png b/.gitbook/assets/image (2).png new file mode 100644 index 000000000..b360607b9 Binary files /dev/null and b/.gitbook/assets/image (2).png differ diff --git a/.gitbook/assets/image (20).png b/.gitbook/assets/image (20).png new file mode 100644 index 000000000..f6d08e7bc Binary files /dev/null and b/.gitbook/assets/image (20).png differ diff --git a/.gitbook/assets/image (21).png b/.gitbook/assets/image (21).png new file mode 100644 index 000000000..fbf76c33f Binary files /dev/null and b/.gitbook/assets/image (21).png differ diff --git a/.gitbook/assets/image (22).png b/.gitbook/assets/image (22).png new file mode 100644 index 000000000..f0d56d501 Binary files /dev/null and b/.gitbook/assets/image (22).png differ diff --git a/.gitbook/assets/image (23).png b/.gitbook/assets/image (23).png new file mode 100644 index 000000000..f95370c49 Binary files /dev/null and b/.gitbook/assets/image (23).png differ diff --git a/.gitbook/assets/image (3).png b/.gitbook/assets/image (3).png new file mode 100644 index 000000000..3127fe090 Binary files /dev/null and b/.gitbook/assets/image (3).png differ diff --git a/.gitbook/assets/image (4).png b/.gitbook/assets/image (4).png new file mode 100644 index 000000000..bf88d6ddd Binary files /dev/null and b/.gitbook/assets/image (4).png differ diff --git a/.gitbook/assets/image (5).png b/.gitbook/assets/image (5).png new file mode 100644 index 000000000..f5a6e2ff4 Binary files /dev/null and b/.gitbook/assets/image (5).png differ diff --git a/.gitbook/assets/image (6).png b/.gitbook/assets/image (6).png new file mode 100644 index 000000000..3a8449ec4 Binary files /dev/null and b/.gitbook/assets/image (6).png differ diff --git a/.gitbook/assets/image (7).png b/.gitbook/assets/image (7).png new file mode 100644 index 000000000..0dbda9ace Binary files /dev/null and b/.gitbook/assets/image (7).png differ diff --git a/.gitbook/assets/image (8).png b/.gitbook/assets/image (8).png new file mode 100644 index 000000000..cd6649677 Binary files /dev/null and b/.gitbook/assets/image (8).png differ diff --git a/.gitbook/assets/image (9).png b/.gitbook/assets/image (9).png new file mode 100644 index 000000000..d955f9b2c Binary files /dev/null and b/.gitbook/assets/image (9).png differ diff --git a/.gitbook/assets/image.png b/.gitbook/assets/image.png new file mode 100644 index 000000000..f873f1d91 Binary files /dev/null and b/.gitbook/assets/image.png differ diff --git a/README.md b/README.md index 5c4b4d58a..a9144221d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ -# Page +--- +description: Java 全栈式微服务开源框架 +--- + +# 简介 + + Redkale(中文名: 红菜苔,湖北特产蔬菜)是基于Java 11全新的微服务开源框架, 包含HTTP、WebSocket、TCP/UDP、数据序列化、数据缓存、依赖注入等功能。 本框架致力于简化集中式和微服务架构的开发,在增强开发敏捷性的同时保持高性能。 + + Redkale 有如下主要特点: \ + 1、大量使用Java 8新特性(接口默认值、Stream、Lambda、JDk8内置的ASM等) \ + 2、提供HTTP服务,同时内置JSON功能与限时缓存功能 \ + 3、TCP层使用NIO,并统一TCP与UDP的接口 \ + 4、提供分布式与集中式部署的无缝切换 \ + 5、提供类似JPA功能,包含数据缓存自动同步、分表分库与简洁的数据层操作接口 \ + 6、支持依赖注入的资源的动态修改 \ + 7、Servlet、Service、Source组件均支持异步接口 + +\ + 作为一个全新的微服务框架,Redkale在接口定义上使用了Java 8大量的新语法,接口有默认实现、接口带静态方法、重复注解等特性,同时在设计上与主流框架有很大不同。Redkale是按组件形式设计的,而非以容器为主,几乎每个子包都是能提供独立功能的组件。如Tomcat是按容器设计的,所有web资源/配置由Tomcat控制,开发者很能难控制到Tomcat内部,而Redkale的HTTP服务只是个组件,开发者既可以自己启动和配置HttpServer,也可以把Redkale当成容器通过Redkale进程来初始化服务。Spring的Ioc容器也是如此,Redkale提供的依赖注入仅通过ResouceFactory一个类来控制,非常轻量,并且可动态更改已注入的资源。Spring提倡控制反转思想,而自身的容器却让开发者很难控制。Redkale是一个既能以组件形式也能以容器形式存在的框架。从整体上看,Redkale的架构分两层:接口和默认实现。开发者若想替换掉Redkale内置的HTTP服务而使用符合JavaEE规范的HttpServlet, 可以采用自定义协议基于JSR 340(Servlet 3.1)来实现自己的HTTP服务;若想使用Hibernate作为数据库操作,可以写一个自己的DataSource实现类;JSON的序列化和反序列化也可以使用第三方的实现;Memcached或Redis也可以作为另一个CacheSource的实现替换Redkale的默认实现。这其实包含了控制反转的思想,让框架里的各个组件均可让开发者控制。 \ + 与主流框架比,功能上Redkale显得很简单,这体现了Redkale的简易性,而并非是不足,从一个良好的设计习惯或架构上来看,有些常用功能是不需要提供的,如Redkale的HTTP服务不支持HTTPS和JSP,HTTPS比HTTP多了一层加密解密,这种密集型的计算不是Java的专长,通常提供HTTP服务的架构不会将Java动态服务器放在最前端,而是在前方会放nginx或apache,除了负载均衡还能静动分离,因此HTTPS的加解密应交给nginx这样的高性能服务器处理。Redkale再提供HTTPS服务就显得鸡肋。JSP其实算是一个落后的技术,现在是一个多样化终端的时代,终端不只局限于桌面程序和PC浏览器,还有原生App、混合式App、微信端、移动H5、提供第三方接口等各种形式的终端,这些都不是JSP能方便兼顾的,而HTTP+JSON作为通用性接口可以避免重复开发,模版引擎的功能加上各种强大的JS框架足以取代JSP。Redkale在功能上做了筛选,不会为了迎合主流而提供,而是以良好的设计思想为指导。这是Redkale的主导思维。 diff --git a/SUMMARY.md b/SUMMARY.md index 4439a14cc..22c8d23a7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -1,3 +1,17 @@ # Table of contents -* [Page](README.md) +* [简介](README.md) +* [快速入门](quick-start.md) +* [Service 组件](service-zu-jian.md) +* [Convert 组件](convert-zu-jian.md) +* [HTTP 服务](http-fu-wu.md) +* [SNCP 服务](sncp-fu-wu.md) +* [WATCH 服务](watch-fu-wu.md) +* [CacheSource缓存组件](cachesource-huan-cun-zu-jian.md) +* [DataSource数据库组件](datasource-shu-ju-ku-zu-jian.md) +* [Client 组件](client-zu-jian.md) +* [PropertiesAgent 配置中心](propertiesagent-pei-zhi-zhong-xin.md) +* [ClusterAgent 服务注册中心](clusteragent-fu-wu-zhu-ce-zhong-xin.md) +* [MessageAgent MQ中心](messageagent-mq-zhong-xin.md) +* [配置文件](readme.md) +* [版本更新](ban-ben-geng-xin.md) diff --git a/ban-ben-geng-xin.md b/ban-ben-geng-xin.md new file mode 100644 index 000000000..a361fc00f --- /dev/null +++ b/ban-ben-geng-xin.md @@ -0,0 +1,39 @@ +# 版本更新 + +## v2.7.0 - 2022-07-07 + +### Fixed + +* 修复 HttpResponse.finish 结果 status=404 时按 200 输出的 bug +* 修复 HttpMessageLocalClient 创建 request 时没有赋值给 currentUserid 值 +* 修复 Rest.createRestServlet 带特定泛型问题 +* 修复 Convert 模块中父类含 public field,subclass 不传父类会导致 NoSuchFieldError 的 bug +* 修复 ApiDocCommand 在没有运行时不能生成 doc 的 bug +* 修复 JsonWriter.writeWrapper 按 latin1 编码写的 bug +* 修复 JsonDynEncoder 在定制字段情况下会被全量字段的动态类覆盖的 bug + +### Changed + +* 优化 PrepareServlet 中 HttpRender 的初始化顺序 +* 日志支持 java.util.logging.ConsoleHandler.denyreg 配置 +* FilterColumn 支持 least=0 时空字符串也参与过滤 +* HttpRequest 兼容参数名为空字符串 +* 移除 CryptColumn、CryptHandler 功能 +* PrepareServlet 更名为 DispatcherServlet +* @WebServlet 合并 url + +### Added + +* 增加 ConvertCoder 功能,可以自定义字段的序列化 +* 增加 JsonMultiDecoder、JsonMultiObjectDecoder、OneOrList 功能 +* JsonConvert 全面兼容 JSON5 +* 增加 redkale 命令行 +* 增加 HttpRpcAuthenticator 功能 +* MessageAgent 增加配置 MessageCoder 功能 +* 实现 LoggingSearchHandler 功能 +* ConvertFactory 增加 mapFieldFunc、ignoreMapColumns 功能 +* 增加 PropertiesAgent 功能 +* 增加链路 ID Traces +* 增加 ResourceListener.different 功能 +* 增加 Environment 类 +* 增加 RestLocale 功能 diff --git a/cachesource-huan-cun-zu-jian.md b/cachesource-huan-cun-zu-jian.md new file mode 100644 index 000000000..03909029a --- /dev/null +++ b/cachesource-huan-cun-zu-jian.md @@ -0,0 +1,2 @@ +# CacheSource缓存组件 + diff --git a/client-zu-jian.md b/client-zu-jian.md new file mode 100644 index 000000000..2bd5e3727 --- /dev/null +++ b/client-zu-jian.md @@ -0,0 +1,2 @@ +# Client 组件 + diff --git a/clusteragent-fu-wu-zhu-ce-zhong-xin.md b/clusteragent-fu-wu-zhu-ce-zhong-xin.md new file mode 100644 index 000000000..c9da6d4c7 --- /dev/null +++ b/clusteragent-fu-wu-zhu-ce-zhong-xin.md @@ -0,0 +1,2 @@ +# ClusterAgent 服务注册中心 + diff --git a/convert-zu-jian.md b/convert-zu-jian.md new file mode 100644 index 000000000..2103d4701 --- /dev/null +++ b/convert-zu-jian.md @@ -0,0 +1,2 @@ +# Convert 组件 + diff --git a/datasource-shu-ju-ku-zu-jian.md b/datasource-shu-ju-ku-zu-jian.md new file mode 100644 index 000000000..e83ff35a0 --- /dev/null +++ b/datasource-shu-ju-ku-zu-jian.md @@ -0,0 +1,2 @@ +# DataSource数据库组件 + diff --git a/http-fu-wu.md b/http-fu-wu.md new file mode 100644 index 000000000..ade5b6460 --- /dev/null +++ b/http-fu-wu.md @@ -0,0 +1,2 @@ +# HTTP 服务 + diff --git a/messageagent-mq-zhong-xin.md b/messageagent-mq-zhong-xin.md new file mode 100644 index 000000000..0d30419e8 --- /dev/null +++ b/messageagent-mq-zhong-xin.md @@ -0,0 +1,2 @@ +# MessageAgent MQ中心 + diff --git a/propertiesagent-pei-zhi-zhong-xin.md b/propertiesagent-pei-zhi-zhong-xin.md new file mode 100644 index 000000000..8d8677949 --- /dev/null +++ b/propertiesagent-pei-zhi-zhong-xin.md @@ -0,0 +1,2 @@ +# PropertiesAgent 配置中心 + diff --git a/quick-start.md b/quick-start.md new file mode 100644 index 000000000..7fee87993 --- /dev/null +++ b/quick-start.md @@ -0,0 +1,104 @@ +# 快速入门 + +## 安装 + +使用maven: + +```markup + + org.redkale + redkale + 2.7.0 + +``` + +{% hint style="info" %} + Super-powers are granted randomly so please submit an issue if you're not happy with yours. +{% endhint %} + +如果工程需要用到Redis、Kafka、Elasticsearch、SQL模板、模板引擎等,可使用redkale的官方插件: + +```markup + + org.redkalex + redkale-plugins + 2.7.0 + +``` + + + +## 创建工程 + +在IDE中使用ant或maven方式创建工程,增加redkale的依赖。然后下载 ˚ 解压并覆盖到工程目录下。\ + + +![](<.gitbook/assets/image (19).png>) + + bin: 存放启动/关闭脚本(start.sh、shutdown.sh、redkale.sh等)\ +conf : 存放服务器所需配置文件: \ + application.xml: 服务配置文件 (必需); \ + logging.properties:日志配置文件 (可选); \ + source.properties: 数据库配置文件 (可选); \ + lib : 存放服务所依赖jar \ + logs : logging.properties 配置中默认的日志存放目录。 + +## Hello World + +演示工程: + +![](<.gitbook/assets/image (23).png>) + +![](<.gitbook/assets/image (17).png>) + +![](<.gitbook/assets/image (6).png>) + +下载 [redkale-2.7.0.tar.gz ](https://repo1.maven.org/maven2/org/redkale/redkale/2.7.0/redkale-2.7.0.tar.gz)解压并覆盖到工程目录下 + +![](<.gitbook/assets/image (2).png>) + +![](<.gitbook/assets/image (21).png>) + +编写HelloService: + +```java +package org.redkalex.example; + +import org.redkale.net.http.*; +import org.redkale.service.Service; + +@RestService(automapping = true) +public class HelloService implements Service { + + public String sayHello() { + return "Hello World!"; + } + + public String hi(String name) { + return "Hi, " + name + "!"; + } +} +``` + +调试运行: + +![](<.gitbook/assets/image (4).png>) + +![选择 Application 模式](<.gitbook/assets/image (16).png>) + +![](<.gitbook/assets/image (10).png>) + +运行日志: + +![](<.gitbook/assets/image (1).png>) + +在浏览器输入: http://127.0.0.1:6060/pipes/hello/say 可以看到结果: + +![](<.gitbook/assets/image (5).png>) + +在浏览器输入: http://127.0.0.1:6060/pipes/hello/hi?name=Redkale 可以看到结果: + +![](.gitbook/assets/image.png) + + + diff --git a/readme.md b/readme.md new file mode 100644 index 000000000..07433c1f3 --- /dev/null +++ b/readme.md @@ -0,0 +1,449 @@ +# 配置文件 + +## application.xml + +系统**必不可少**的配置文件, 包含了核心配置信息。. + +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## source.properties + +数据源(含数据库、缓存)配置文件 + +``` + +# CacheSource @Resource(name="usersession") +# type可以不用设置,框架会根据url判断使用哪个CacheSource实现类 +redkale.cachesource.usersession.type = org.redkalex.cache.redis.RedisCacheSource +# 最大连接数 +redkale.cachesource.usersession.maxconns = 16 +# 节点地址 +redkale.cachesource.usersession.node[0].url = redis://127.0.0.1:6363 +# 节点密码 +redkale.cachesource.usersession.node[0].password = 12345678 +# 节点db +redkale.cachesource.usersession.node[0].db = 0 + +#简化写法: 可以不用.node[0], 将参数都合并到url中 +redkale.cachesource.usersession.url = redis://user:123456@127.0.0.1:6363?db=0 + + +# DataSource @Resource(name="platf") +# type可以不用设置,框架会根据url判断使用哪个DataSource实现类,默认值: org.redkale.source.DataJdbcSource +redkale.datasource.platf.type = org.redkale.source.DataJdbcSource +# 是否开启缓存(标记为@Cacheable的Entity类),值目前只支持两种: ALL: 所有开启缓存。 NONE: 关闭所有缓存, 非NONE字样统一视为ALL +redkale.datasource.platf.cachemode = ALL +# 是否自动建表当表不存在的时候, 目前只支持mysql、postgres, 默认为false +redkale.datasource.platf.table-autoddl = false +# 用户 +redkale.datasource.platf.user = root +# 密码 +redkale.datasource.platf.password = 12345678 +# 多个URL用;隔开,如分布式SearchSource需要配多个URL +redkale.datasource.platf.url = jdbc:mysql://127.0.0.1:3306/platf?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8 +# 最大连接数,默认值:CPU数 +redkale.datasource.platf.maxconns = 16 +# 包含的SQL模板,相当于反向LIKE,不同的JDBC驱动的SQL语句不一样,Redkale内置了MySQL的语句 +redkale.datasource.platf.contain-sqltemplate = LOCATE(${keystr}, ${column}) > 0 +# 包含的SQL模板,相当于反向LIKE,不同的JDBC驱动的SQL语句不一样,Redkale内置了MySQL的语句 +redkale.datasource.platf.notcontain-sqltemplate = LOCATE(${keystr}, ${column}) = 0 +# 复制表结构的SQL模板,Redkale内置了MySQL的语句 +redkale.datasource.platf.tablenotexist-sqlstates = 42000;42S02 +# 复制表结构的SQL模板,Redkale内置了MySQL的语句 +redkale.datasource.platf.tablecopy-sqltemplate = CREATE TABLE IF NOT EXISTS ${newtable} LIKE ${oldtable} + + +# DataSource 读写分离 +redkale.datasource.platf.read.url = jdbc:mysql://127.0.0.1:3306/platf_r?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8 +redkale.datasource.platf.read.user = root +redkale.datasource.platf.read.password = 12345678 + +redkale.datasource.platf.write.url = jdbc:mysql://127.0.0.1:3306/platf_w?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8 +redkale.datasource.platf.write.user = root +redkale.datasource.platf.write.password = 12345678 +``` + +## logging.properties + +日志配置文件 + +``` + +handlers = java.util.logging.ConsoleHandler,java.util.logging.FileHandler +.handlers = java.util.logging.ConsoleHandler,java.util.logging.FileHandler + +############################################################ +.level = FINE + +sun.level = INFO +java.level = INFO +javax.level = INFO +com.sun.level = INFO + +#java.util.logging.FileHandler.level = FINE + +java.util.logging.FileHandler.limit = 20M +java.util.logging.FileHandler.count = 100 +java.util.logging.FileHandler.encoding = UTF-8 +java.util.logging.FileHandler.pattern = ${APP_HOME}/logs-%tY%tm/log-%tY%tm%td.log +#java.util.logging.FileHandler.unusual 属性表示将 WARNING、SEVERE 级别的日志复制写入单独的文件中 +java.util.logging.FileHandler.unusual = ${APP_HOME}/logs-%tY%tm/log-warnerr-%tY%tm%td.log +#需要屏蔽消息内容的正则表达式 +java.util.logging.FileHandler.denyreg = +java.util.logging.FileHandler.append = true + +#java.util.logging.ConsoleHandler.level = FINE + +#将日志写进SearchSource, 必须指定source资源名,在source.properties中定义 +#java.util.logging.SearchHandler.source = platfsearch +#指定写进SearchSource的表名,默认值为log-record +#java.util.logging.SearchHandler.tag = log-${APP_NAME}-%tY%tm%td + +``` diff --git a/service-zu-jian.md b/service-zu-jian.md new file mode 100644 index 000000000..823e17a19 --- /dev/null +++ b/service-zu-jian.md @@ -0,0 +1,6 @@ +--- +description: Service是Redkale最核心的类, 几乎所有组件都是围绕Service来服务。 +--- + +# Service 组件 + diff --git a/sncp-fu-wu.md b/sncp-fu-wu.md new file mode 100644 index 000000000..4a1730ae4 --- /dev/null +++ b/sncp-fu-wu.md @@ -0,0 +1,2 @@ +# SNCP 服务 + diff --git a/watch-fu-wu.md b/watch-fu-wu.md new file mode 100644 index 000000000..eeb3a3554 --- /dev/null +++ b/watch-fu-wu.md @@ -0,0 +1,2 @@ +# WATCH 服务 +