CSID Labs have developed tools and libraries that allow you to write and run Python source connectors and SMTs.
In addition to letting you use your favourite language (Python), they are also very simple to use. You can write a Hello World source connector with just 2 lines of code.
More details:
This tutorial uses a complete cluster running on docker. Just make sure you have Docker Desktop installed on your computer and you're ready to go!
From there, you have to create a connector in the Connect cluster.
There are 3 examples provided with this tutorial in the jsonfolder. They all use a Python connector and the last one also includes a Python SMT.
To create a connector you can use curl or you can use the Control Center UI. Since we already have a terminal open, let's use that. Wait a minute or two while the Connect container initializes. If you get a 404 error when running the command below, wait a little bit more and try again.
Run curl localhost:8083/connectors -X POST --json @./json/connector-fields.json to create a connector with the example 1 above.
To check that everything is running you can either:
Open Control Center at http://localhost:9021 and go to the Topics panel. Select the topic starting with test-topic and click on the Messages tab. If your Docker environment is slow, you may have to wait a few minutes for the test topic to show up. When it does, you should see messages coming in.
Open the Docker Desktop dashboard, expand the cluster, click on the connect container. The Logs tab should list messages being published by the connector and modified by the SMT if there's one.
SMTs are functions that transform the messages before they are saved into the source topic by the source connector.
They receive the messages with some context and return the transformed (or not) messages. They can even return None to filter messages out (in other words, those won't be saved into the input topic).
In our example (no 3 above), the connector and the SMT are on the same script. This is for convenience but not mandatory at all. As a matter of fact, in the vast majority of the case, the SMTs will be fully separated from the connectors.
When you submit a json file to create a connector, it includes some settings for the Python connector. The main one is the entry.point property that is telling the connector which Python script to use and which method to call repeatedly. (Usually this method is called poll but it can be anything.)
All the configuration properties and the technical are described in the tech-details.md file.