Skip to content

Commit

Permalink
update as per suggetion
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmohona committed Nov 7, 2023
1 parent 40f961b commit c92e10d
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions pages/docs/concepts/asyncapi-document/dynamic-channel-address.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Dynamic Channel Address
weight: 80
---

Dynamic channel addresses are used to specify dynamic parts of a channel name, which becomes particularly useful when you want to use and reuse parameters in the channel name. It provides flexibility in how you structure your event-driven interfaces.
Dynamic channel addresses specify dynamic parts of a channel address, which becomes particularly useful when you want to use and reuse parameters in a channel address.

Here is the diagram explaining dynamic channel address:

Expand Down Expand Up @@ -60,7 +60,7 @@ graph TD

This diagram shows how the channel address includes the same parameters as the channel address, and each parameter's name matches the one used in the address.

Here is an example of parameter context:
Here is an example of a dynamic channel address and its parameter:

```yml
user/{userId}/signup:
Expand All @@ -73,13 +73,13 @@ user/{userId}/signup:
$ref: "#/components/messages/userSignedUp"
```

In the above document, `user/{userId}/signedup` is the endpoint where `{userId}` is a path parameter.
In the above document, `user/{userId}/signedup` is the address where `{userId}` is a parameter for that address.

## Reusing parameters

Parameters can be reused. This reuse optimizes the usage of parameters within the event-driven interface by letting you use the parameters again.
Parameters can be reused. This reuse optimizes the usage of parameters within the API by letting you use the parameters again.

If there is another message, for example, a `UserUpdated` message, which also requires the `userId`, the parameter can be reused like the following following diagram:
If there is another message, for example, a `UserUpdated` message, which also requires the `userId` parameter, it can be reused like in the following example:

```mermaid
graph TD
Expand All @@ -103,23 +103,22 @@ graph TD

In this diagram, a channel named `userSignedUp` that requires a parameter `userId` .Additionally, the parameter `userId` is reused for another message, `UserUpdated`.

Here is a code of reusing parameters:
Here is an example of reusing parameters:

```yml
channels:
userSignedUp:
UserSignedUp:
address: 'user/{userId}/signedup'
parameters:
userId:
description: Id of the user.
$ref: '#/components/parameters/userId'
UserUpdated:
address: 'user/{userId}/updated'
parameters:
UserUpdated:
description: Updated Id of the user.
operations:
userSignedUp:
action: receive
channel:
$ref: '#/channels/userSignedUp'
$ref: '#/components/parameters/userId'
components:
parameters:
userId:
description: Id of the user.
```

In this AsyncAPI document, the previously defined `userId` parameter is reused to form the channel address for `UserUpdated` message.
In the previous example, the `userId` parameter is defined under `components`, and both channels `UserSignedUp` and `UserUpdated` are reusing it in their address by referencing via `$ref`.

0 comments on commit c92e10d

Please sign in to comment.