Skip to content

Commit 2e2675b

Browse files
Add Connectors contribution guide (#546)
Co-authored-by: Tun <stereosky@users.noreply.github.com>
1 parent 94b9143 commit 2e2675b

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ In general, we follow the ["fork-and-pull" Git workflow](https://github.com/susa
3939
6. Push changes to your fork.
4040
7. Open a PR in our repository and follow the PR template so that we can efficiently review the changes.
4141

42+
## Contributing new Connectors
43+
If you want to contribute a new Source or Sink, check out the [Connectors Contribution Guide](https://quix.io/docs/quix-streams/connectors/contribution-guide.html) page to get started.
44+
4245
## Coding standards
4346

4447
To keep the code as consistent as possible, please familiarize yourself with the existing style of the project. If you're contributing to the Python code base, follow the [PEP 8 - Style Guide for Python Code](https://peps.python.org/pep-0008/).

docs/connectors/community-and-core.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Community and Core Connectors
2+
3+
Quix Streams provides two kinds of Sinks and Sources with different levels of support:
4+
5+
- **Core connectors**: these connectors are developed or maintained by the Quix Streams team.
6+
They live in [quixstreams/sources/core](https://github.com/quixio/quix-streams/tree/main/quixstreams/sources/core) and [quixstreams/sinks/core](https://github.com/quixio/quix-streams/tree/main/quixstreams/sinks/core) folders.
7+
They are production-ready, thoroughly tested, documented, and updated regularly.
8+
9+
- **Community connectors**: these connectors are developed by the community members.
10+
They live in [quixstreams/sources/community](https://github.com/quixio/quix-streams/tree/main/quixstreams/sources/community) and [quixstreams/sinks/community](https://github.com/quixio/quix-streams/tree/main/quixstreams/sinks/community) folders.
11+
Quix Streams' maintainers review them before merging, but they don't add or maintain new features directly.
12+
Community connectors are not guaranteed to be fully tested and stable.
13+
Community connectors can become core if they are widely used.
14+
15+
To contribute a new community connector, check out the [Connectors Contribution Guide](contribution-guide.md).

docs/connectors/contribution-guide.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Contributing new Connectors
2+
3+
Quix Streams provide APIs to build custom Sources and Sinks.
4+
5+
In this guide, we will explain how to contribute a new Source or Sink to Quix Streams
6+
and share your work with the community.
7+
8+
## Where to start
9+
Before submitting a new connector, we encourage you to try out Quix Streams
10+
and build an application with it.
11+
12+
It will help you to better understand how the library works.
13+
14+
Check out our [Tutorials](../tutorials/README.md) to get started.
15+
16+
## Steps
17+
18+
1. Check the [list of GitHub issues with a `connector` label](https://github.com/quixio/quix-streams/labels/connector) to see if a request for the connector has already been submitted.
19+
2. If it doesn't exist, create a new one named `"New {source/sink}: {name}"`, and describe your idea.
20+
3. At this point, you can either ask for help from the Quix Streams maintainers, or implement it yourself and contribute it to the library.
21+
If you want to develop it yourself, proceed to the next section.
22+
23+
24+
### Contributing a new Sink or Source
25+
26+
1. Fork [the Quix Streams repository](https://github.com/quixio/quix-streams/).
27+
28+
2. Clone the repo locally.
29+
30+
3. Create a branch for your connector as a new feature in the format `{feature}/{connector-name}` (e.g. `feature/mqtt-source`)
31+
32+
4. Read ["Creating a Custom Source"](sources/custom-sources.md) and ["Creating a Custom Sink"](sinks/custom-sinks.md) to learn how to build a connector.
33+
34+
5. Create a new Python module in `quixstreams/sources/community/{connector-name}` for Sources or `quixstreams/sinks/community/{connector-name}` for Sinks.
35+
36+
6. In this module, add a new class for your connector following the format `"{Technology}Sink"` or `"{Technology}Source"` (e.g. `MQTTSource` , `PostgreSQLSink` ).
37+
Read the [Best Practices](#best-practices-for-the-connectors-code) section on how to structure your code and test it.
38+
39+
7. Test your changes locally in some sandbox environment to make sure it works.
40+
41+
8. Commit your changes and push to your fork.
42+
43+
9. Create a Pull Request to Quix Streams `main` branch.
44+
See [How to describe your PR](#how-to-describe-your-pr) section to learn how to structure the PR.
45+
46+
10. Wait for feedback from a Quix Streams maintainer and adjust the code if necessary.
47+
48+
11. Feel free to join the `#contributors` channel in [the community Slack](https://quix.io/slack-invite) and announce your work!
49+
50+
12. After the PR is accepted, the maintainers will take care of releasing it in the next version of Quix Streams.
51+
52+
53+
## Best practices for the connector's code
54+
55+
### Adding external libraries
56+
In many cases, the connector needs an external library to work.
57+
58+
These libraries are considered optional, and they should not be required for the default
59+
`quixstreams` installation.
60+
61+
When using an external library:
62+
63+
1. Add new optional dependency to `pyproject.toml` in the `[project.optional-dependencies]`
64+
section.
65+
For example, for MQTTSource you need to add `mqtt = [paho-mqtt>=2.1.0,<3]`.
66+
2. Add a dependency to `tests/requirements.txt` for the tests to run.
67+
3. To provide nice exception messages for users, wrap the library import in try-except in the connector's code like this:
68+
69+
```python
70+
try:
71+
import influxdb_client_3
72+
except ImportError as exc:
73+
raise ImportError(
74+
'Package "influxdb3-python" is missing: '
75+
"run pip install quixstreams[influxdb3] to fix it"
76+
) from exc
77+
```
78+
79+
80+
### Writing docstrings
81+
Add a docstring to your connector class briefly describing how it works and covering
82+
parameters it accepts.
83+
84+
Look at [InfluxDB3Sink](../api-reference/sinks.md#influxdb3sink) as an example.
85+
86+
### Writing tests
87+
Add unit tests to the `tests/test_quixstreams/test_{sources/sinks}/test_community/test_{connector-name}` folder.
88+
Use tests for existing connectors in `tests/test_quixstreams/test_{sources/sinks}/test_core/*` folders as examples.
89+
90+
91+
## How to describe your PR
92+
To streamline the review process, describe your PR in the following format
93+
94+
- Link the PR to the previously created issue.
95+
- Describe new libraries used by the connector.
96+
- Briefly describe how the connector works and provide some context for how to use it.
97+
- Describe the processing guarantees the connector provides (e.g. at-least-once, at-most-once, exactly-once).
98+
- Add examples how to instantiate the connector class.
99+
- Explain how to set up a sandbox environment for Quix Streams maintainers to test your PR.

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ nav:
5858
- Kafka Replicator Source: connectors/sources/kafka-source.md
5959
- Quix Source: connectors/sources/quix-source.md
6060
- Creating a Custom Source: connectors/sources/custom-sources.md
61+
- Contribution Guide: 'connectors/contribution-guide.md'
62+
- Community and Core Connectors: 'connectors/community-and-core.md'
6163
- Upgrading Guide:
6264
- Upgrading from Quix Streams v0.5: upgrading-legacy.md
6365

0 commit comments

Comments
 (0)