Skip to content

Commit d37fdb3

Browse files
authored
[Doc]Adjust Seatunnel Doc Structure (#10395)
1 parent 81ddef7 commit d37fdb3

21 files changed

+1107
-2
lines changed

docs/en/developer/coding-guide.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Coding Guide
2+
3+
This guide documents an overview of the current Apache SeaTunnel modules and best practices on how to submit a high quality pull request to Apache SeaTunnel.
4+
5+
## Modules Overview
6+
7+
| Module Name | Introduction |
8+
|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
9+
| seatunnel-api | SeaTunnel connector V2 API module |
10+
| seatunnel-common | SeaTunnel common module |
11+
| seatunnel-connectors-v2 | SeaTunnel connector V2 module, currently connector V2 is under development and the community will focus on it |
12+
| seatunnel-core/seatunnel-spark-starter | SeaTunnel core starter module of connector V2 on Spark engine |
13+
| seatunnel-core/seatunnel-flink-starter | SeaTunnel core starter module of connector V2 on Flink engine |
14+
| seatunnel-core/seatunnel-starter | SeaTunnel core starter module of connector V2 on SeaTunnel engine |
15+
| seatunnel-e2e | SeaTunnel end-to-end test module |
16+
| seatunnel-examples | SeaTunnel local examples module, developer can use it to do unit test and integration test |
17+
| seatunnel-engine | SeaTunnel engine module, seatunnel-engine is a new computational engine developed by the SeaTunnel Community that focuses on data synchronization. |
18+
| seatunnel-formats | SeaTunnel formats module, used to offer the ability of formatting data |
19+
| seatunnel-plugin-discovery | SeaTunnel plugin discovery module, used to offer the ability of loading SPI plugins from classpath |
20+
| seatunnel-transforms-v2 | SeaTunnel transform V2 module, currently transform V2 is under development and the community will focus on it |
21+
| seatunnel-translation | SeaTunnel translation module, used to adapt Connector V2 and other computing engines such as Spark, Flink etc... |
22+
23+
## How To Submit A High Quality Pull Request
24+
25+
1. Create entity classes using annotations in the `lombok` plugin (`@Data` `@Getter` `@Setter` `@NonNull` etc...) to reduce the amount of code. It's a good practice to prioritize the use of lombok plugins in your coding process.
26+
27+
2. If you need to use log4j to print logs in a class, preferably use the annotation `@Slf4j` in the `lombok` plugin.
28+
29+
3. SeaTunnel uses issue to track logical issues, including bugs and improvements, and uses Github's pull requests to manage the review and merge of specific code changes. So making a clear issue or pull request helps the community better understand the developer's intent. The best practice of creating issue or pull request is as the following shown:
30+
31+
> [purpose] [module name] [sub-module name] Description
32+
33+
1. Pull request purpose includes: `Hotfix`, `Feature`, `Improve`, `Docs`, `WIP`. Note that if your pull request's purpose is `WIP`, then you need to use github's draft pull request
34+
2. Issue purpose includes: `Feature`, `Bug`, `Docs`, `Discuss`
35+
3. Module name: the current pull request or issue involves the name of the module, for example: `Core`, `Connector-V2`, `Connector-V1`, etc.
36+
4. Sub-module name: the current pull request or issue involves the name of the sub-module, for example:`File` `Redis` `Hbase` etc.
37+
5. Description: provide a brief, clear summary of the current pull request and issue's main goals and aim for a title that conveys the core purpose at a glance.
38+
39+
Tips:**For more details, you can refer to [Issue Guide](https://seatunnel.apache.org/community/contribution_guide/contribute#issue) and [Pull Request Guide](https://seatunnel.apache.org/community/contribution_guide/contribute#pull-request)**
40+
41+
4. Code segments are never repeated. If a code segment is used multiple times, define it multiple times is not a good option, make it a public segment for other modules to use is a best practice.
42+
43+
5. When throwing an exception, throw it along with a hint message and the exception should be smaller in scope. Throwing overly broad exceptions promotes complex error handling code that is more likely to contain security vulnerabilities. For example, if your connector encounters an `IOException` while reading data, a reasonable approach would be to the following:
44+
45+
```java
46+
try {
47+
// read logic
48+
} catch (IOException e) {
49+
throw SeaTunnelORCFormatException("This orc file is corrupted, please check it", e);
50+
}
51+
```
52+
53+
6. The Apache project has very strict licensing requirements, so every file in an Apache project should contain a license statement. Check that each new file you add contains the `Apache License Header` before submitting pull request:
54+
55+
```java
56+
/*
57+
* Licensed to the Apache Software Foundation (ASF) under one or more
58+
* contributor license agreements. See the NOTICE file distributed with
59+
* this work for additional information regarding copyright ownership.
60+
* The ASF licenses this file to You under the Apache License, Version 2.0
61+
* (the "License"); you may not use this file except in compliance with
62+
* the License. You may obtain a copy of the License at
63+
*
64+
* http://www.apache.org/licenses/LICENSE-2.0
65+
*
66+
* Unless required by applicable law or agreed to in writing, software
67+
* distributed under the License is distributed on an "AS IS" BASIS,
68+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
69+
* See the License for the specific language governing permissions and
70+
* limitations under the License.
71+
*/
72+
```
73+
74+
7. Apache SeaTunnel uses `Spotless` for code style and formatting checks. You could run the following command and `Spotless` will automatically fix the code style and formatting errors for you:
75+
76+
```shell
77+
./mvnw spotless:apply
78+
```
79+
80+
8. Before you submit your pull request, make sure the project will compile properly after adding your code, you can use the following commands to package the whole project:
81+
82+
```shell
83+
# multi threads compile
84+
./mvnw -T 1C clean package
85+
```
86+
87+
```shell
88+
# single thread compile
89+
./mvnw clean package
90+
```
91+
92+
9. Before submitting pull request, do a full unit test and integration test locally can better verify the functionality of your code, best practice is to use the `seatunnel-examples` module's ability to self-test to ensure that the multi-engine is running properly and the results are correct.
93+
94+
10. If you submit a pull request with a feature that requires updated documentation, always remember to update the documentation.
95+
96+
11. Submit the pull request of connector type can write e2e test to ensure the robustness and robustness of the code, e2e test should include the full data type, and e2e test as little as possible to initialize the docker image, write the test cases of sink and source together to reduce the loss of resources, while using asynchronous features to ensure the stability of the test. A good example can be found at: [MongodbIT.java](https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-mongodb-e2e/src/test/java/org/apache/seatunnel/e2e/connector/v2/mongodb/MongodbIT.java)
97+
98+
12. The priority of property permission in the class is set to `private`, and mutability is set to `final`, which can be changed reasonably if special circumstances are encountered.
99+
100+
13. The properties in the class and method parameters prefer to use the base type(int boolean double float...), not recommended to use the wrapper type(Integer Boolean Double Float...), if encounter special circumstances reasonable change.
101+
102+
14. When developing a sink connector you need to be aware that the sink will be serialized, and if some properties cannot be serialized, encapsulate the properties into classes and use the singleton pattern.
103+
104+
15. If there are multiple `if` process judgments in the code flow, try to simplify the flow to multiple ifs instead of if-else-if.
105+
106+
16. Pull request has the characteristic of single responsibility, not allowed to include irrelevant code of the feature in pull request, once this situation deal with their own branch before submitting pull request, otherwise the Apache SeaTunnel community will actively close pull request.
107+
108+
17. Contributors should be responsible for their own pull request. If your pull request contains new features or modifies old features, add test cases or e2e tests to prove the reasonableness and functional integrity of your pull request is a good practice.
109+
110+
18. If you think which part of the community's current code is unreasonable (especially the core `core` module and the `api` module), the function needs to be updated or modified, the first thing to do is to propose a `discuss issue` or `email` with the community to discuss the need to modify this part of the function, if the community agrees to submit pull request again, do not submit the issue and pull request directly without discussion, so the community will directly consider this pull request is useless, and will be closed down.
111+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Contribute Connector-V2 Plugins
2+
3+
If you want to contribute Connector-V2, please click the Connector-V2 Contribution Guide below for reference. It can help you enter development more quickly.
4+
5+
[Connector-v2 Contribution Guide](https://github.com/apache/seatunnel/blob/dev/seatunnel-connectors-v2/README.md)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Contribute Transform-V2 Plugins
2+
3+
If you want to contribute Transform-V2, please click the Transform-V2 Contribution Guide below for reference. It can help you enter development more quickly.
4+
5+
[Connector-v2 Contribution Guide](https://github.com/apache/seatunnel/blob/dev/seatunnel-transforms-v2/README.md)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Docs Format Specification
2+
## Admonitions
3+
4+
We have special admonitions syntax by wrapping text with a set of 3 colons, followed by a label denoting its type. When you want to emphasize the content, it is recommended to use admonitions.
5+
6+
In use, the following specifications need to be followed:
7+
8+
- Tip: mainly used for operational tips and tricks.
9+
10+
- Note: used for more details and explanations.
11+
12+
- Caution: used for warnings and precautions.
13+
14+
You may also specify an optional title. Here are the examples of admonitions syntax:
15+
16+
```Markdown
17+
:::tip Tip
18+
Some content with tips
19+
:::
20+
21+
:::info Note
22+
Some content with explanations
23+
:::
24+
25+
:::caution Warning
26+
Some content with precuations and warnings
27+
:::
28+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Develop Your Own Connector
2+
3+
If you want to develop your own connector for the new SeaTunnel connector API (Connector V2), please check [here](https://github.com/apache/seatunnel/blob/dev/seatunnel-connectors-v2/README.md).

docs/en/developer/new-license.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# How To Add New License
2+
3+
### ASF 3RD PARTY LICENSE POLICY
4+
5+
You have to pay attention to the following open-source software protocols which Apache projects support when you intend to add a new feature to the SeaTunnel (or other Apache projects), which functions refers to other open-source software references.
6+
7+
[ASF 3RD PARTY LICENSE POLICY](https://apache.org/legal/resolved.html)
8+
9+
If the 3rd party software is not present at the above policy, we wouldn't accept your code.
10+
11+
### How to Legally Use 3rd Party Open-source Software In The SeaTunnel
12+
13+
Moreover, when we intend to refer a new software ( not limited to 3rd party jar, text, CSS, js, pics, icons, audios etc and modifications based on 3rd party files) to our project, we need to use them legally in addition to the permission of ASF. Refer to the following article:
14+
15+
* [COMMUNITY-LED DEVELOPMENT "THE APACHE WAY"](https://apache.org/dev/licensing-howto.html)
16+
17+
For example, we should contain the NOTICE file (most of open-source project has NOTICE file, generally under root directory) of ZooKeeper in our project when we are using ZooKeeper. As the Apache explains, "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.
18+
19+
We are not going to dive into every 3rd party open-source license policy in here, you may look up them if interested.
20+
21+
### SeaTunnel-License Check Rules
22+
23+
In general, we would have our License-check scripts to our project. SeaTunnel-License-Check is provided by [SkyWalking](https://github.com/apache/skywalking) which differ a bit from other open-source projects. All in all, we are trying to make sure avoiding the license issues at the first time.
24+
25+
We need to follow the following steps when we need to add new jars or external resources:
26+
27+
* Add the name and the version of the jar file in the known-dependencies.txt
28+
* Add relevant maven repository address under 'seatunnel-dist/release-docs/LICENSE' directory
29+
* Append relevant NOTICE files under 'seatunnel-dist/release-docs/NOTICE' directory and make sure they are no different to the original repository
30+
* Add relevant source code protocols under 'seatunnel-dist/release-docs/licenses' directory and the file name should be named as license+filename.txt. e.g.: license-zk.txt
31+
* check dependency license fail
32+
33+
```
34+
--- /dev/fd/63 2020-12-03 03:08:57.191579482 +0000
35+
+++ /dev/fd/62 2020-12-03 03:08:57.191579482 +0000
36+
@@ -1,0 +2 @@
37+
+HikariCP-java6-2.3.13.jar
38+
@@ -16,0 +18 @@
39+
+c3p0-0.9.5.2.jar
40+
@@ -149,0 +152 @@
41+
+mchange-commons-java-0.2.11.jar
42+
43+
- commons-lang-2.1.3.jar
44+
Error: Process completed with exit code 1.
45+
```
46+
47+
Generally speaking, the work of adding a jar is often not so easy to end, because it often depends on various other jars, and we also need to add corresponding licenses for these jars. In this case, we will get the error message of check dependency license fail in check. As above, we are missing the license declaration of `HikariCP-java6-2.3.13`, `c3p0`, etc. (`+` means new, `-` means need to delete ), follow the steps to add jar to add
48+
49+
### References
50+
51+
* [COMMUNITY-LED DEVELOPMENT "THE APACHE WAY"](https://apache.org/dev/licensing-howto.html)
52+
* [ASF 3RD PARTY LICENSE POLICY](https://apache.org/legal/resolved.html)
53+

0 commit comments

Comments
 (0)