This is an automated email from the ASF dual-hosted git repository. duanzhengqiang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/shardingsphere-plugin.git
commit 37babf3097458386e902e162b1753e785d32c01f Author: duanzhengqiang <[email protected]> AuthorDate: Wed Sep 27 18:22:13 2023 +0800 Add pom for plugins --- README.md | 166 ++++++++++++++++++++ README_ZH.md | 170 ++++++++++++++++++++- jdbc/driver/{ => apollo}/pom.xml | 4 +- .../jdbc/driver/ApolloURLProvider.java | 0 ...iver.jdbc.core.driver.ShardingSphereURLProvider | 0 jdbc/driver/pom.xml | 27 +--- 6 files changed, 341 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index fb5f4ad..bded266 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,23 @@ +# Table of Contents + +* [Table of Contents](#table-of-contents) +* [OVERVIEW](#overview) +* [Instruction](#instruction) +* [Plug-in Implementation](#plug-in-implementation) + * [Feature Plug-in](#feature-plug-in) + * [Encrypt Feature Plug-in](#encrypt-feature-plug-in) + * [Like Encrypt Algorithm](#like-encrypt-algorithm) + * [Standard Encrypt Algorithm](#standard-encrypt-algorithm) + * [Sharding Feature Plug-in](#sharding-feature-plug-in) + * [Distributed Key Generator](#distributed-key-generator) + * [Sharding Algorithm](#sharding-algorithm) + * [Infra Plug-in](#infra-plug-in) + * [Connection Pool Plug-in](#connection-pool-plug-in) + * [JDBC Adaptor Plug-in](#jdbc-adaptor-plug-in) + * [JDBC Driver Config Plug-in](#jdbc-driver-config-plug-in) + * [Mode Plug-in](#mode-plug-in) + * [Mode Cluster Repository Plug-in](#mode-cluster-repository-plug-in) + # OVERVIEW ShardingSphere Plugin is designed to provide a plug-in implementation for ShardingSphere pluggable architecture. You can refer to [ShardingSphere dev manual](https://shardingsphere.apache.org/document/current/en/dev-manual/) to extend the SPI. @@ -6,6 +26,14 @@ Developers are welcome to contribute to the implementation of plug-ins and build [](https://github.com/apache/shardingsphere-plugin/blob/main/README.md) [](https://github.com/apache/shardingsphere-plugin/blob/main/README_ZH.md) +# Instruction + +These plugins can be found in [ShardingSphere Plugins](https://github.com/apache/shardingsphere-plugin) repository. Plugins in ShardingSphere Plugin repository would remain the same release plan with ShardingSphere, they can be retrieved at https://central.sonatype.com/, and install into ShardingSphere. +When using ShardingSphere-JDBC, users only need to add maven dependencies to the project to complete the plug-in installation. When using ShardingSphere-Proxy, they need to download the plug-in jar package and the jar packages that the plug-in may depend on, and then copy them to ShardingSphere-Proxy `ext-lib` directory. + +When developers contribute new plug-ins, they need to refer to [Contributor Guide](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/) and first execute `./mvnw clean install -DskipITs -DskipTests -Prelease` to package ShardingSphere basic SPI and test components, and then create a new module for plug-in development. +Newly developed plug-in code needs to follow [ShardingSphere development specifications](https://shardingsphere.apache.org/community/en/involved/conduct/code/). + # Plug-in Implementation ## Feature Plug-in @@ -27,6 +55,16 @@ Attributes: | start | int | Ciphertext Unicode initial code(decimal number) | | dict | String | Common words | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-encrypt-like</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + #### Standard Encrypt Algorithm * RC4 Encrypt Algorithm @@ -39,6 +77,16 @@ Attributes: |---------------|------------|---------------| | rc4-key-value | String | RC4 KEY | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-encrypt-rc4</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * SM3 Encrypt Algorithm Type: SM3 @@ -49,6 +97,16 @@ Attributes: |----------|------------|--------------------------------------------| | sm3-salt | String | SM3 SALT (should be blank or 8 bytes long) | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-encrypt-sm</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * SM4 Encrypt Algorithm Type: SM4 @@ -62,6 +120,16 @@ Attributes: | sm4-iv | String | SM4 IV (should be specified on CBC, 16 bytes long) | | sm4-padding | String | SM4 PADDING (should be PKCS5Padding or PKCS7Padding, NoPadding excepted) | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-encrypt-sm</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + ### Sharding Feature Plug-in #### Distributed Key Generator @@ -72,6 +140,16 @@ Type:NANOID Configurable Property:none +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-nanoid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * CosId Type: COSID @@ -83,6 +161,16 @@ Attributes: | id-name | String | ID generator name | `__share__` | | as-string | bool | Whether to generate a string type ID: Convert `long` type ID to Base-62 `String` type (`Long.MAX_VALUE` maximum string length is 11 digits), and ensure the ordering of string IDs | `false` | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * CosId-Snowflake Type: COSID_SNOWFLAKE @@ -94,6 +182,16 @@ Attributes: | epoch | String | EPOCH of Snowflake ID Algorithm | `1477929600000` | | as-string | bool | Whether to generate a string type ID: Convert `long` type ID to Base-62 `String` type (`Long.MAX_VALUE` maximum string length is 11 digits), and ensure the ordering of string IDs | `false` | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + #### Sharding Algorithm * Fixed interval sharding algorithm provided by CosId @@ -116,6 +214,16 @@ Attributes: | datetime-interval-unit | String | Unit of sharding value interval, must can be transformed to Java ChronoUnit's Enum value. For example: MONTHS | | | datetime-interval-amount | int | Interval of sharding value, after which the next shard will be entered | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * Snowflake key-based fixed interval sharding algorithm provided by CosId Snowflake ID sharding algorithm with fixed time range implemented by tool class based on `me.ahoo.cosid:cosid-core`. @@ -136,6 +244,16 @@ Attributes: | datetime-interval-unit | String | Unit of sharding value interval, must can be transformed to Java ChronoUnit's Enum value. For example: MONTHS | | | datetime-interval-amount | int | Interval of sharding value, after which the next shard will be entered | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * Modulo sharding algorithm provided by CosId Modulo sharding algorithm implemented by the tool class based on `me.ahoo.cosid:cosid-core`. @@ -150,6 +268,16 @@ Attributes: | mod | int | Sharding count | | logic-name-prefix | String | Prefix pattern of sharding data sources or tables | +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + ## Infra Plug-in ### Connection Pool Plug-in @@ -171,6 +299,16 @@ dataSources: password: ``` +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-infra-data-source-pool-c3p0</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * DBCP Connection Pool Sample: @@ -184,6 +322,14 @@ dataSources: password: ``` +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-infra-data-source-pool-dbcp</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + ## JDBC Adaptor Plug-in ### JDBC Driver Config Plug-in @@ -197,6 +343,16 @@ Load JDBC URL of the yaml configuration file in the specified namespace of apoll jdbc:shardingsphere:apollo:TEST.test_namespace ``` +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-jdbc-driver-apollo</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + ## Mode Plug-in ### Mode Cluster Repository Plug-in @@ -215,3 +371,13 @@ Attributes: | retryIntervalMilliseconds | long | Milliseconds of retry interval | 500 | | maxRetries | int | Max retries for client to check data availability | 3 | | timeToLiveSeconds | int | Seconds of ephemeral instance live | 30 | + +Maven dependency: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-mode-cluster-repository-nacos</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` diff --git a/README_ZH.md b/README_ZH.md index 528b257..ce54cf8 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,3 +1,23 @@ +# 目录 + +* [目录](#目录) +* [概述](#概述) +* [说明](#说明) +* [插件实现](#插件实现) + * [功能插件](#功能插件) + * [加密功能插件](#加密功能插件) + * [模糊加密算法插件](#模糊加密算法插件) + * [标准加密算法插件](#标准加密算法插件) + * [分片功能插件](#分片功能插件) + * [分布式主键生成插件](#分布式主键生成插件) + * [分片算法插件](#分片算法插件) + * [基础设施插件](#基础设施插件) + * [连接池插件](#连接池插件) + * [JDBC 接入端插件](#jdbc-接入端插件) + * [JDBC Driver 配置插件](#jdbc-driver-配置插件) + * [治理中心插件](#治理中心插件) + * [治理中心集群模式持久化插件](#治理中心集群模式持久化插件) + # 概述 ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现,可以参考 [ShardingSphere 开发者手册](https://shardingsphere.apache.org/document/current/cn/dev-manual/) 对 SPI 进行扩展。 @@ -6,6 +26,14 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 [](https://github.com/apache/shardingsphere-plugin/blob/main/README.md) [](https://github.com/apache/shardingsphere-plugin/blob/main/README_ZH.md) +# 说明 + +ShardingSphere Plugin 仓库中的插件会和 ShardingSphere 保持相同的发布节奏,可以在 https://central.sonatype.com/ 进行检索,并安装到 ShardingSphere 中。 +用户使用 ShardingSphere-JDBC 时,只需要将 maven 依赖添加到项目中即可完成插件安装,使用 ShardingSphere-Proxy 时,需要下载插件 jar 包及插件可能依赖的 jar 包,然后拷贝到 ShardingSphere-Proxy 的 `ext-lib` 目录下。 + +开发者贡献新的插件时,需要参考 [贡献者指南](https://shardingsphere.apache.org/community/cn/involved/contribute/contributor/),先执行 `./mvnw clean install -DskipITs -DskipTests -Prelease` 打包 ShardingSphere 基础 SPI 及测试组件,然后再新建模块进行插件开发。 +新开发的插件代码需要遵循 [ShardingSphere 开发规范](https://shardingsphere.apache.org/community/cn/involved/conduct/code/)。 + # 插件实现 ## 功能插件 @@ -27,6 +55,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 | start | int | 密文Unicode初始码(十进制) | | dict | String | 常见字 | +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-encrypt-like</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + #### 标准加密算法插件 * RC4 加密算法 @@ -39,6 +77,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 |---------------|--------|-------------| | rc4-key-value | String | RC4 使用的 KEY | +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-encrypt-rc4</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * SM3 加密算法 类型:SM3 @@ -49,6 +97,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 | ------------- | --------- | ------------- | | sm3-salt | String | SM3 使用的 SALT(空 或 8 Bytes) | +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-encrypt-sm</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * SM4 加密算法 类型:SM4 @@ -62,6 +120,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 | sm4-iv | String | SM4 使用的 IV (MODE为CBC时需指定,16 Bytes)| | sm4-padding | String | SM4 使用的 PADDING (PKCS5Padding 或 PKCS7Padding,暂不支持NoPadding)| +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-encrypt-sm</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + ### 分片功能插件 #### 分布式主键生成插件 @@ -72,6 +140,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 可配置属性: 无 +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-nanoid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * CosId 类型: COSID @@ -83,6 +161,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 | id-name | String | ID 生成器名称 | `__share__` | | as-string | bool | 是否生成字符串类型ID: 将 `long` 类型 ID 转换成 62 进制 `String` 类型(`Long.MAX_VALUE` 最大字符串长度11位),并保证字符串 ID 有序性 | `false` | +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * CosId-Snowflake 类型: COSID_SNOWFLAKE @@ -94,6 +182,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 | epoch | String | 雪花 ID 算法的 EPOCH | `1477929600000` | | as-string | bool | 是否生成字符串类型ID: 将 `long` 类型 ID 转换成 62 进制 `String` 类型(`Long.MAX_VALUE` 最大字符串长度11位),并保证字符串 ID 有序性 | `false` | +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + #### 分片算法插件 * 基于 CosId 的固定时间范围的分片算法 @@ -116,6 +214,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 | datetime-interval-unit | String | 分片键时间间隔单位,必须遵循 Java ChronoUnit 的枚举值。例如:MONTHS | | | datetime-interval-amount | int | 分片键时间间隔,超过该时间间隔将进入下一分片 | | +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * 基于 CosId 的雪花ID固定时间范围的分片算法 基于 `me.ahoo.cosid:cosid-core` 的工具类实现的雪花ID固定时间范围的分片算法。 @@ -136,6 +244,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 | datetime-interval-unit | String | 分片键时间间隔单位,必须遵循 Java ChronoUnit 的枚举值。例如:MONTHS | | | datetime-interval-amount | int | 分片键时间间隔,超过该时间间隔将进入下一分片 | | +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * 基于 CosId 的取模分片算法 基于 `me.ahoo.cosid:cosid-core` 的工具类实现的取模分片算法。 @@ -150,6 +268,16 @@ ShardingSphere Plugin 旨在为 ShardingSphere 可插拔架构提供插件实现 | mod | int | 分片数量 | | logic-name-prefix | String | 分片数据源或真实表的前缀格式 | +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-features-sharding-cosid</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + ## 基础设施插件 ### 连接池插件 @@ -171,6 +299,16 @@ dataSources: password: ``` +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-infra-data-source-pool-c3p0</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + * DBCP 连接池 配置示例: @@ -184,6 +322,16 @@ dataSources: password: ``` +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-infra-data-source-pool-dbcp</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + ## JDBC 接入端插件 ### JDBC Driver 配置插件 @@ -197,6 +345,16 @@ ShardingSphere-JDBC 提供了 JDBC 驱动,可以仅通过配置变更即可使 jdbc:shardingsphere:apollo:TEST.test_namespace ``` +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-jdbc-driver-apollo</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` + ## 治理中心插件 ### 治理中心集群模式持久化插件 @@ -214,4 +372,14 @@ jdbc:shardingsphere:apollo:TEST.test_namespace | clusterIp | String | 集群中的唯一标识 | 真实主机IP | | retryIntervalMilliseconds | long | 重试间隔毫秒数 | 500 | | maxRetries | int | 客户端检查数据可用性的最大重试次数 | 3 | -| timeToLiveSeconds | int | 临时实例失效的秒数 | 30 | \ No newline at end of file +| timeToLiveSeconds | int | 临时实例失效的秒数 | 30 | + +Maven 依赖: + +```xml +<dependency> + <groupId>org.apache.shardingsphere</groupId> + <artifactId>shardingsphere-plugin-mode-cluster-repository-nacos</artifactId> + <version>${RELEASE.VERSION}</version> +</dependency> +``` diff --git a/jdbc/driver/pom.xml b/jdbc/driver/apollo/pom.xml similarity index 93% copy from jdbc/driver/pom.xml copy to jdbc/driver/apollo/pom.xml index 4af282b..b42b479 100644 --- a/jdbc/driver/pom.xml +++ b/jdbc/driver/apollo/pom.xml @@ -20,10 +20,10 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-plugin-jdbc</artifactId> + <artifactId>shardingsphere-plugin-jdbc-driver</artifactId> <version>5.4.1-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-plugin-jdbc-driver</artifactId> + <artifactId>shardingsphere-plugin-jdbc-driver-apollo</artifactId> <name>${project.artifactId}</name> <properties> diff --git a/jdbc/driver/src/main/java/org/apache/shardingsphere/jdbc/driver/ApolloURLProvider.java b/jdbc/driver/apollo/src/main/java/org/apache/shardingsphere/jdbc/driver/ApolloURLProvider.java similarity index 100% rename from jdbc/driver/src/main/java/org/apache/shardingsphere/jdbc/driver/ApolloURLProvider.java rename to jdbc/driver/apollo/src/main/java/org/apache/shardingsphere/jdbc/driver/ApolloURLProvider.java diff --git a/jdbc/driver/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLProvider b/jdbc/driver/apollo/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLProvider similarity index 100% rename from jdbc/driver/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLProvider rename to jdbc/driver/apollo/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.jdbc.core.driver.ShardingSphereURLProvider diff --git a/jdbc/driver/pom.xml b/jdbc/driver/pom.xml index 4af282b..989ac4f 100644 --- a/jdbc/driver/pom.xml +++ b/jdbc/driver/pom.xml @@ -24,29 +24,10 @@ <version>5.4.1-SNAPSHOT</version> </parent> <artifactId>shardingsphere-plugin-jdbc-driver</artifactId> + <packaging>pom</packaging> <name>${project.artifactId}</name> - <properties> - <nacos.version>1.4.2</nacos.version> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-jdbc-core</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-test-util</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>com.ctrip.framework.apollo</groupId> - <artifactId>apollo-client</artifactId> - </dependency> - </dependencies> + <modules> + <module>apollo</module> + </modules> </project>
