-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
Changes from all commits
b1a4c14
cd7eff7
0d88348
9dcf307
e6f2c0e
fbd3da8
40f961b
c92e10d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: 'AsyncAPI Document' | ||
weight: 50 | ||
--- |
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 | ||
``` | ||
|
||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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`. |
There was a problem hiding this comment.
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.