From aa8fa97887d64a709df0ac94408a2cb21492b08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haris=20Osmanagi=C4=87?= Date: Wed, 31 Jul 2024 15:48:01 +0200 Subject: [PATCH] Customize Conduit's built-in connectors (#105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Customize Conduit's built-in connectors * Update docs/connectors/additional-built-in-plugins.mdx Co-authored-by: Raúl Barroso --------- Co-authored-by: Raúl Barroso --- .../additional-built-in-plugins.mdx | 70 +++++++++++++++++++ docs/connectors/connector-lifecycle.mdx | 2 +- docs/connectors/kafka-connect-connector.mdx | 2 +- docs/connectors/output-formats.mdx | 2 +- 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 docs/connectors/additional-built-in-plugins.mdx diff --git a/docs/connectors/additional-built-in-plugins.mdx b/docs/connectors/additional-built-in-plugins.mdx new file mode 100644 index 00000000..7ed5a2b5 --- /dev/null +++ b/docs/connectors/additional-built-in-plugins.mdx @@ -0,0 +1,70 @@ +--- +title: "Adding built-in Connectors" +sidebar_position: 2 +--- + +Built-in connectors offer better performance when compared to standalone ones, +which is why in some cases it's desirable to have a custom build of Conduit that +includes additional built-in connectors. + +The simplest way to achieve so is to write a small application that embeds +Conduit (i.e. uses Conduit as a library) and adds one or more connectors to its +default configuration. + +In the example below we will add +the [HTTP connector](https://github.com/conduitio-labs/conduit-connector-http) +to Conduit as a built-in connector. + +First, we initialize a Go module with `go mod init github.com/conduitio-labs/custom-conduit`. + +Then , we need to add Conduit and the HTTP connector as dependencies: +```shell +go get github.com/conduitio/conduit +go get github.com/conduitio-labs/conduit-connector-http +go mod tidy +``` + +Once that is done, we need to write a `main` function that: +1. Adds the HTTP connector the default Conduit configuration +2. Runs Conduit with the custom configuration. + +That's done in the code below: + +```go +package main + +import ( + http "github.com/conduitio-labs/conduit-connector-http" + "github.com/conduitio/conduit/pkg/conduit" +) + +func main() { + // Get the default configuration, including all built-in connectors + cfg := conduit.DefaultConfig() + + // Add the HTTP connector to list of built-in connectors + cfg.ConnectorPlugins["http"] = http.Connector + + conduit.Serve(cfg) +} +``` + +This custom version of Conduit can be built with `go build main.go -o custom-conduit`. If +you run the built binary, you can check that the HTTP connector has been +included in the build by listing all the connector plugins: +```shell +curl 'http://localhost:8080/v1/connectors/plugins' + +[ + { + "name": "builtin:http@(devel)", + "summary": "HTTP source and destination connectors for Conduit.", + "description": "Conduit HTTP source and destination connectors, they connect to an HTTP URL and send HTTP requests.", + "version": "(devel)", + "author": "", + "destinationParams": {}, + "sourceParams": {} + } + // other plugins +] +``` diff --git a/docs/connectors/connector-lifecycle.mdx b/docs/connectors/connector-lifecycle.mdx index 40a995fd..8fc1075e 100644 --- a/docs/connectors/connector-lifecycle.mdx +++ b/docs/connectors/connector-lifecycle.mdx @@ -1,6 +1,6 @@ --- title: "Connector Lifecycle" -sidebar_position: 7 +sidebar_position: 6 --- :::info diff --git a/docs/connectors/kafka-connect-connector.mdx b/docs/connectors/kafka-connect-connector.mdx index 97f9f3aa..23c2ef4a 100644 --- a/docs/connectors/kafka-connect-connector.mdx +++ b/docs/connectors/kafka-connect-connector.mdx @@ -1,6 +1,6 @@ --- title: "Kafka Connect Connectors with Conduit" -sidebar_position: 8 +sidebar_position: 9 --- # Using Kafka Connect Connectors with Conduit diff --git a/docs/connectors/output-formats.mdx b/docs/connectors/output-formats.mdx index 8701873c..02a7023a 100644 --- a/docs/connectors/output-formats.mdx +++ b/docs/connectors/output-formats.mdx @@ -1,6 +1,6 @@ --- title: "Output Formats" -sidebar_position: 6 +sidebar_position: 5 --- One of the challenges to be solved when integrating Conduit with other systems, such as Kafka Connect and Debezium, is