|
2 | 2 |
|
3 | 3 | ## Programming Languages |
4 | 4 |
|
5 | | -This directory includes examples of Apache Pulsar client applications, showcasing producers and consumers, written in various programming languages. The README for each language walks through the necessary steps to run each example. When each client establishes a connection with the Pulsar cluster through OAuth2, it needs to obtain the specified options from the Pulsar cluster and OAuth2 services. [How to get OAuth2 options](#How to get OAuth2 options) explains how you get these options. |
| 5 | +This directory includes examples of Apache Pulsar client applications, showcasing producers and consumers, written in various programming languages. The README for each language walks through the necessary steps to run each example. When each client establishes a connection with the Pulsar cluster through **OAuth2** or **Token**. |
| 6 | + |
| 7 | +For the OAuth2, it needs to obtain the specified options from the Pulsar cluster and OAuth2 services. [How to get OAuth2 options](#How to get OAuth2 options) explains how you get these options. |
6 | 8 |
|
7 | 9 | Currently, we support the following three languages to connect through OAuth2: |
8 | 10 |
|
9 | 11 | - Java |
10 | 12 | - Go |
11 | 13 | - CPP |
12 | 14 |
|
13 | | -For clients in other languages, you can connect through token, reference to [here](https://pulsar.apache.org/docs/en/security-tls-transport/#client-configuration). |
| 15 | +The following clients and Pulsar CLI tools are supported to connect to cluster through the Token. And [How to get Token options](#How to get Token options) explains how you get these options. |
| 16 | + |
| 17 | +- Java |
| 18 | +- Go |
| 19 | +- CPP |
| 20 | +- Python |
| 21 | +- CSharp(TODO) |
| 22 | +- NodeJS |
| 23 | +- pulsarctl |
| 24 | +- pulsar-admin |
| 25 | +- pulsar-client |
| 26 | +- pulsar-perf |
| 27 | + |
| 28 | +## How to get token options |
| 29 | + |
| 30 | +When you use Token to connect to Pulsar cluster, you need to provide the following options: |
| 31 | + |
| 32 | +- `SERVICE_URL` |
| 33 | +- `WEB_SERVICE_URL` |
| 34 | +- `AUTH_PARAMS` |
| 35 | + |
| 36 | +For the `SERVICE_URL` field, you can get the **hostname** through the following command: |
| 37 | + |
| 38 | +```shell script |
| 39 | +$ snctl get pulsarclusters [CLUSTER_NAME] -n [NAMESPACE] -o json | jq '.spec.serviceEndpoints[0].dnsName' |
| 40 | +``` |
| 41 | + |
| 42 | +Output: |
| 43 | + |
| 44 | +```text |
| 45 | +api.test.cloud.xxx.streamnative.dev |
| 46 | +``` |
| 47 | + |
| 48 | +A `SERVICE_URL` is a combination of protocol, hostname and port, so an example of a complete `SERVICE_URL` is as follows: |
| 49 | + |
| 50 | + |
| 51 | +```text |
| 52 | +pulsar://api.test.cloud.xxx.streamnative.dev:6650 |
| 53 | +
|
| 54 | +# For tls |
| 55 | +pulsar+ssl://api.test.cloud.xxx.streamnative.dev:6651 |
| 56 | +``` |
| 57 | + |
| 58 | +For the `WEB_SERVICE_URL` field, you can get the **hostname** through the following command: |
| 59 | + |
| 60 | +```shell script |
| 61 | +$ snctl get pulsarclusters [CLUSTER_NAME] -n [NAMESPACE] -o json | jq '.spec.serviceEndpoints[0].dnsName' |
| 62 | +``` |
| 63 | + |
| 64 | +Output: |
| 65 | + |
| 66 | +```text |
| 67 | +api.test.cloud.xxx.streamnative.dev |
| 68 | +``` |
| 69 | + |
| 70 | +A `WEB_SERVICE_URL` is a combination of protocol, hostname and port, so an example of a complete `WEB_SERVICE_URL` is as follows: |
| 71 | + |
| 72 | +```text |
| 73 | +http://api.test.cloud.xxx.streamnative.dev:8080 |
| 74 | +
|
| 75 | +# For tls |
| 76 | +https://api.test.cloud.xxx.streamnative.dev:8443 |
| 77 | +``` |
| 78 | + |
| 79 | +For the `AUTH_PARAMS` field, you can get it through the following command: |
| 80 | + |
| 81 | +```shell script |
| 82 | +$ snctl auth get-token [INSTANCE] [flags] |
| 83 | +``` |
| 84 | + |
| 85 | +> Tips: In code implementation, for safety and convenience, you can consider setting `AUTH_PARAMS` as an environment variable. |
14 | 86 |
|
15 | 87 | ## How to get OAuth2 options |
16 | 88 |
|
|
0 commit comments