Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: adding dynamic channel page #1959

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pages/docs/concepts/asyncapi-document/_section.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: 'AsyncAPI Document'
weight: 50
---
124 changes: 124 additions & 0 deletions pages/docs/concepts/asyncapi-document/dynamic-channel-address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: Dynamic Channel Address
weight: 80
---

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:

```mermaid
graph TD
A[AsyncAPI]
B[Dynamic Channel Address]
D[Variable Usage in Channel Address]
E[Adapted to Multiple APIs and Protocols]
F[Reused Across Channels]

style B fill:#47BCEE,stroke:#47BCEE;

A --> B
B --> D
D --> E
D --> F
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #1959 (comment), I still believe this diagram doesn't clarify anything to the user but rather can lead to confusion. I would suggest we remove it.


The diagram shows how dynamic channel addresses allow flexible event-driven interfaces by using and reusing parameters in channel names, adapting well to various APIs and protocols.

Here is an example of dynamic channel address:

```yml
userSignedUp:
address: 'user.signedup'
messages:
userSignedUp:
$ref: '#/components/messages/userSignedUp'
Comment on lines +31 to +35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is not showing any parameter in the address. You are already providing one example below in https://github.com/asyncapi/website/pull/1959/files#diff-798204f3a6dff3c49407fb1af6e8d8d4a10a5b26e328844fe1e03e17173e3c98R66.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here shall I remove the code example? Or I should provide a new example?

```

This document defines a dynamic channel address for a `userSignedUp` event message, making it easy to include and reuse specific details in the channel address.

## Parameter context

In a channel address, there's a map of parameters, which needs to include all the same parameters that are in the main channel address. The names you use for the parameters in this map must be exactly the same as the names you used in the channel address.
mhmohona marked this conversation as resolved.
Show resolved Hide resolved

Here is a diagram explaining parameter context:

```mermaid
graph TD
A[Channel Address] --> B{Parameter Map}
B --> C{Parameters}
C --> D[Parameter 1]
C --> E[Parameter 2]
C --> F[Parameter 3]
D --> G{Parameter Name}
E --> G
F --> G
A --> G

style B fill:#47BCEE,stroke:#47BCEE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #1959 (comment), I still believe these diagrams don't clarify anything to the user but rather can lead to confusion. I would suggest we remove it.

```

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 a dynamic channel address and its parameter:

```yml
user/{userId}/signup:
parameters:
userId:
description: Id of the user.
location: $message.payload#/user/id
subscribe:
message:
$ref: "#/components/messages/userSignedUp"
```

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 API by letting you use the parameters again.

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
subgraph Channels
userSignedUp["userSignedUp"]
end

subgraph Parameters
userId["userId"]
end

userSignedUp -->|requires| userId

subgraph Reused Parameters
UserUpdated["UserUpdated"]
style UserUpdated fill:#47BCEE,stroke:#47BCEE;

end
UserUpdated -->|reuses| userId
```

In this diagram, a channel named `userSignedUp` that requires a parameter `userId` .Additionally, the parameter `userId` is reused for another message, `UserUpdated`.
Comment on lines +84 to +104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #1959 (comment), I still believe these diagrams don't clarify anything to the user but rather can lead to confusion. I would suggest we remove it.

The example below is more than enough to illustrate


Here is an example of reusing parameters:

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

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`.