From db6689f6a89e1c3fbc9b4ccc8b7a299d531f81c8 Mon Sep 17 00:00:00 2001 From: Baodi Shi Date: Mon, 11 Dec 2023 16:35:44 +0800 Subject: [PATCH] Refactor create a connector section docs. --- docs/amqp-1-0-sink.md | 74 +++++++++++++++++++++++++---------------- docs/amqp-1-0-source.md | 74 +++++++++++++++++++++++++---------------- 2 files changed, 92 insertions(+), 56 deletions(-) diff --git a/docs/amqp-1-0-sink.md b/docs/amqp-1-0-sink.md index 3d2ceeb4..b12cc1af 100644 --- a/docs/amqp-1-0-sink.md +++ b/docs/amqp-1-0-sink.md @@ -20,36 +20,54 @@ docker run -d -p 8080:8080 -p:8008:8008 -p:1883:1883 -p:8000:8000 -p:5672:5672 - ### 2. Create a connector -Depending on the environment, there are several ways to create an AMQP 1.0 sink connector: - -- [Create Connector on StreamNative Cloud](https://docs.streamnative.io/docs/connector-create). -- [Create Connector with Function worker](https://pulsar.apache.org/docs/3.0.x/io-quickstart/). - Using this way requires you to download a **NAR** package to create a built-in or non-built-in connector. You can download the version you need from [here](https://github.com/streamnative/pulsar-io-amqp-1-0/releases). -- [Create Connector with Function mesh](https://functionmesh.io/docs/connectors/run-connector). - Using this way requires you to set the docker image. You can choose the version you want to launch from [here](https://hub.docker.com/r/streamnative/pulsar-io-amqp-1-0/tags) - -No matter how you create an AMQP 1.0 sink connector, the minimum configuration contains the following parameters. - -```yaml - configs: - connection: - failover: - useFailover: true - uris: - - protocol: amqp - host: localhost - port: 5672 - urlOptions: - - transport.tcpKeepAlive=true - username: guest - password: guest - queue: user-op-queue-pulsar +The following command shows how to use [pulsarctl](https://github.com/streamnative/pulsarctl) to create a `builtin` connector. If you want to create a `non-builtin` connector, +you need to replace `--sink-type amqp1_0` with `--archive /path/to/pulsar-io-amqp1_0.nar`. You can find the button to download the `nar` package at the beginning of the document. + +{% callout title="For StreamNative Cloud User" type="note" %} +If you are a StreamNative Cloud user, you need [set up your environment](https://docs.streamnative.io/docs/connector-setup) first. +{% /callout %} + +```bash +pulsarctl sinks create \ + --sink-type amqp1_0 \ + --name amqp1_0-sink \ + --tenant public \ + --namespace default \ + --inputs "Your topic name" \ + --parallelism 1 \ + --sink-config \ + '{ + "connection": { + "failover": { + "useFailover": true + }, + "uris": [ + { + "protocol": "amqp", + "host": "localhost", + "port": 5672, + "urlOptions": [ + "transport.tcpKeepAlive=true" + ] + } + ] + }, + "username": "guest", + "password": "guest", + "queue": "user-op-queue-pulsar" + }' ``` -> * The configuration structure varies depending on how you create the AMQP 1.0 sink connector. - > For example, some are **JSON**, some are **YAML**, and some are **Kubernetes YAML**. You need to adapt the configs to the corresponding format. -> -> * If you want to configure more parameters, see [Configuration Properties](#configuration-properties) for reference. +The `--sink-config` is the minimum necessary configuration for starting this connector, and it is a JSON string. You need to substitute the relevant parameters with your own. +If you want to configure more parameters, see [Configuration Properties](#configuration-properties) for reference. + +{% callout title="Note" type="note" %} +You can also choose to use a variety of other tools to create a connector: +- [pulsar-admin](https://pulsar.apache.org/docs/3.1.x/io-use/): The command arguments for `pulsar-admin` are similar to those of `pulsarctl`. You can find an example for [StreamNative Cloud Doc](https://docs.streamnative.io/docs/connector-create#create-a-built-in-connector ). +- [RestAPI](https://pulsar.apache.org/sink-rest-api/?version=3.1.1): You can find an example for [StreamNative Cloud Doc](https://docs.streamnative.io/docs/connector-create#create-a-built-in-connector). +- [Terraform](https://github.com/hashicorp/terraform): You can find an example for [StreamNative Cloud Doc](https://docs.streamnative.io/docs/connector-create#create-a-built-in-connector). +- [Function Mesh](https://functionmesh.io/docs/connectors/run-connector): The docker image can be found at the beginning of the document. + {% /callout %} ### 2. Send messages to the topic diff --git a/docs/amqp-1-0-source.md b/docs/amqp-1-0-source.md index 05b6916f..167a0ccc 100644 --- a/docs/amqp-1-0-source.md +++ b/docs/amqp-1-0-source.md @@ -20,36 +20,54 @@ docker run -d -p 8080:8080 -p:8008:8008 -p:1883:1883 -p:8000:8000 -p:5672:5672 - ### 2. Create a connector -Depending on the environment, there are several ways to create an AMQP 1.0 sink connector: - -- [Create Connector on StreamNative Cloud](https://docs.streamnative.io/docs/connector-create). -- [Create Connector with Function worker](https://pulsar.apache.org/docs/3.0.x/io-quickstart/). - Using this way requires you to download a **NAR** package to create a built-in or non-built-in connector. You can download the version you need from [here](https://github.com/streamnative/pulsar-io-amqp-1-0/releases). -- [Create Connector with Function mesh](https://functionmesh.io/docs/connectors/run-connector). - Using this way requires you to set the docker image. You can choose the version you want to launch from [here](https://hub.docker.com/r/streamnative/pulsar-io-amqp-1-0/tags) - -No matter how you create an AMQP 1.0 sink connector, the minimum configuration contains the following parameters. - -```yaml - configs: - connection: - failover: - useFailover: true - uris: - - protocol: amqp - host: localhost - port: 5672 - urlOptions: - - transport.tcpKeepAlive=true - username: guest - password: guest - queue: user-op-queue-pulsar +The following command shows how to use [pulsarctl](https://github.com/streamnative/pulsarctl) to create a `builtin` connector. If you want to create a `non-builtin` connector, +you need to replace `--source-type amqp1_0` with `--archive /path/to/pulsar-io-amqp1_0.nar`. You can find the button to download the `nar` package at the beginning of the document. + +{% callout title="For StreamNative Cloud User" type="note" %} +If you are a StreamNative Cloud user, you need [set up your environment](https://docs.streamnative.io/docs/connector-setup) first. +{% /callout %} + +```bash +pulsarctl sources create \ + --source-type amqp1_0 \ + --name amqp1_0-source \ + --tenant public \ + --namespace default \ + --destination-topic-name "Your topic name" \ + --parallelism 1 \ + --source-config \ + '{ + "connection": { + "failover": { + "useFailover": true + }, + "uris": [ + { + "protocol": "amqp", + "host": "localhost", + "port": 5672, + "urlOptions": [ + "transport.tcpKeepAlive=true" + ] + } + ] + }, + "username": "guest", + "password": "guest", + "queue": "user-op-queue-pulsar" + }' ``` -> * The configuration structure varies depending on how you create the AMQP 1.0 sink connector. - > For example, some are **JSON**, some are **YAML**, and some are **Kubernetes YAML**. You need to adapt the configs to the corresponding format. -> -> * If you want to configure more parameters, see [Configuration Properties](#configuration-properties) for reference. +The `--source-config` is the minimum necessary configuration for starting this connector, and it is a JSON string. You need to substitute the relevant parameters with your own. +If you want to configure more parameters, see [Configuration Properties](#configuration-properties) for reference. + +{% callout title="Note" type="note" %} +You can also choose to use a variety of other tools to create a connector: +- [pulsar-admin](https://pulsar.apache.org/docs/3.1.x/io-use/): The command arguments for `pulsar-admin` are similar to those of `pulsarctl`. You can find an example for [StreamNative Cloud Doc](https://docs.streamnative.io/docs/connector-create#create-a-built-in-connector ). +- [RestAPI](https://pulsar.apache.org/source-rest-api/?version=3.1.1): You can find an example for [StreamNative Cloud Doc](https://docs.streamnative.io/docs/connector-create#create-a-built-in-connector). +- [Terraform](https://github.com/hashicorp/terraform): You can find an example for [StreamNative Cloud Doc](https://docs.streamnative.io/docs/connector-create#create-a-built-in-connector). +- [Function Mesh](https://functionmesh.io/docs/connectors/run-connector): The docker image can be found at the beginning of the document. + {% /callout %} ### 2. Send messages to the AMQP 1.0 service