Skip to content

Commit

Permalink
document danube_pubsub cli
Browse files Browse the repository at this point in the history
  • Loading branch information
danrusei committed Aug 8, 2024
1 parent 7578ffb commit a84e170
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 57 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,6 @@ This command creates a new non-partitioned topic with the specified name. Replac
Topic Created: true
```

### `danube-admin topics create-partitioned-topic TOPIC --partitions #`

Create a partitioned topic.

**Usage:**

```sh
danube-admin topics create-partitioned-topic TOPIC --partitions #
```

**Description:**

This command creates a new partitioned topic with the specified name and number of partitions. Replace `TOPIC` with the desired name for the topic and `#` with the number of partitions.

**Example Output:**

```sh
Partitioned Topic Created: true
```

### `danube-admin topics delete TOPIC`

Delete a specified topic.
Expand All @@ -86,26 +66,6 @@ This command deletes the specified topic. Replace `TOPIC` with the name of the t
Topic Deleted: true
```

### `danube-admin topics unsubscribe --subscription SUBSCRIPTION TOPIC`

Delete a subscription from a topic.

**Usage:**

```sh
danube-admin topics unsubscribe --subscription SUBSCRIPTION TOPIC
```

**Description:**

This command deletes a subscription from a specified topic. Replace `SUBSCRIPTION` with the name of the subscription and `TOPIC` with the name of the topic.

**Example Output:**

```sh
Unsubscribed: true
```

### `danube-admin topics subscriptions TOPIC`

Get the list of subscriptions on a specified topic.
Expand All @@ -126,24 +86,24 @@ This command retrieves and displays all subscriptions associated with a specifie
Subscriptions: [subscription1, subscription2]
```

### `danube-admin topics create-subscription --subscription SUBSCRIPTION TOPIC`
### `danube-admin topics unsubscribe --subscription SUBSCRIPTION TOPIC`

Create a new subscription for a specified topic.
Delete a subscription from a topic.

**Usage:**

```sh
danube-admin topics create-subscription --subscription SUBSCRIPTION TOPIC
danube-admin topics unsubscribe --subscription SUBSCRIPTION TOPIC
```

**Description:**

This command creates a new subscription for a specified topic. Replace `SUBSCRIPTION` with the name of the subscription and `TOPIC` with the name of the topic.
This command deletes a subscription from a specified topic. Replace `SUBSCRIPTION` with the name of the subscription and `TOPIC` with the name of the topic.

**Example Output:**

```sh
Subscription Created: true
Unsubscribed: true
```

## Error Handling
Expand All @@ -160,18 +120,12 @@ Here are a few example commands for quick reference:
danube-admin topics list my-namespace
```

- Create a non-partitioned topic:
- Create a topic:

```sh
danube-admin topics create my-topic
```

- Create a partitioned topic with 5 partitions:

```sh
danube-admin topics create-partitioned-topic my-partitioned-topic --partitions 5
```

- Delete a topic:

```sh
Expand Down
61 changes: 61 additions & 0 deletions docs/danube_clis/danube_pubsub/consumer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Danube-Pubsub CLI - Consume messages

The `consume` command retrieves messages from a specified topic.

## Usage

```bash
danube-pubsub consume [OPTIONS] --service-addr <SERVICE_ADDR> --subscription <SUBSCRIPTION>
```

### Options

- `-s, --service-addr <SERVICE_ADDR>`
**Description:** The service URL for the Danube broker.
**Example:** `http://127.0.0.1:6650`

- `-t, --topic <TOPIC>`
**Description:** The topic to consume messages from.
**Default:** `/default/test_topic`

- `-c, --consumer <CONSUMER>`
**Description:** The consumer name.
**Default:** `consumer_pubsub`

- `-m, --subscription <SUBSCRIPTION>`
**Description:** The subscription name.
**Required:** Yes

- `--sub-type <SUB_TYPE>`
**Description:** The subscription type.
**Default:** `shared`
**Possible values:** `exclusive`, `shared`, `fail-over`

- `-h, --help`
**Description:** Print help information.

### Example: Shared Subscription

To receive messages from a shared subscription:

```bash
danube-pubsub consume -s http://127.0.0.1:6650 -m my_shared_subscription
```

### Example: Exclusive Subscription

To receive messages from an exclusive subscription:

```bash
danube-pubsub consume -s http://127.0.0.1:6650 -m my_exclusive --sub-type exclusive
```

**To create a new exclusive subscription:**

```bash
danube-pubsub consume -s http://127.0.0.1:6650 -m my_exclusive2 --sub-type exclusive
```

## Resources

Check [this article](https://dev-state.com/posts/danube_pubsub/) that covers how to combine the subscription types in order to obtain message queueing or fan-out pub-sub messaging patterns.
54 changes: 54 additions & 0 deletions docs/danube_clis/danube_pubsub/producer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Danube-Pubsub CLI - Produce messages

The `produce` command sends messages to a specified topic.

## Usage

```bash
danube-pubsub produce [OPTIONS] --service-addr <SERVICE_ADDR> --message <MESSAGE>
```

### Options

- `-s, --service-addr <SERVICE_ADDR>`
**Description:** The service URL for the Danube broker.
**Example:** `http://127.0.0.1:6650`

- `-t, --topic <TOPIC>`
**Description:** The topic to produce messages to.
**Default:** `/default/test_topic`

- `-p, --schema <SCHEMA>`
**Description:** The schema type of the message.
**Possible values:** `bytes`, `string`, `int64`, `json`

- `-m, --message <MESSAGE>`
**Description:** The message to send.
**Required:** Yes

- `--json-schema <JSON_SCHEMA>`
**Description:** The JSON schema, required if schema type is `json`.

- `-c, --count <COUNT>`
**Description:** Number of times to send the message.
**Default:** `1`

- `-i, --interval <INTERVAL>`
**Description:** Interval between messages in milliseconds.
**Default:** `500`
**Minimum:** `100`

- `-a, --attributes <ATTRIBUTES>`
**Description:** Attributes in the form `'parameter:value'`.
**Example:** `'key1:value1,key2:value2'`

- `-h, --help`
**Description:** Print help information

### Example

To send 1000 messages with the content "Hello, Danube!" to the default topic:

```bash
danube-pubsub produce -s http://127.0.0.1:6650 -c 1000 -m "Hello, Danube!"
```
13 changes: 8 additions & 5 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ nav:
- Create Producer: client_libraries/producer.md
- Create Consumer: client_libraries/consumer.md

- Admin API:
- Danube CLI:
- Brokers: admin_API/danube_admin/brokers.md
- Namespaces: admin_API/danube_admin/namespaces.md
- Topics: admin_API/danube_admin/topics.md
- Danube CLIs:
- Danube Admin:
- Brokers: danube_clis/danube_admin/brokers.md
- Namespaces: danube_clis/danube_admin/namespaces.md
- Topics: danube_clis/danube_admin/topics.md
- Danube PubSub:
- Producer: danube_clis/danube_pubsub/producer.rs
- Consumer: danube_clis/danube_pubsub/consumer.rs
- Development:
- Development Environment: development/dev_environment.md
- Metadata Resources: development/internal_resources.md
Expand Down

0 comments on commit a84e170

Please sign in to comment.