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
Add hello-world example #3
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
content/docs/getting-started.md → content/docs/getting-started/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
title: "Hello world" | ||
date: 2019-04-01T10:56:52+01:00 | ||
menu: | ||
docs: | ||
parent: 'getting-started' | ||
weight: 101 | ||
--- | ||
|
||
Let's define an application that's capable of receiving a "hello {name}" message. | ||
|
||
```yaml | ||
asyncapi: '2.0.0' | ||
id: hello-world-app | ||
channels: | ||
hello: | ||
subscribe: | ||
message: | ||
payload: | ||
type: string | ||
pattern: '^hello .+$' | ||
``` | ||
|
||
Let's get into the details of the sample specification: | ||
|
||
<pre class="language-yaml line-numbers" data-line="1,2"><code>asyncapi: '2.0.0' | ||
id: hello-world-app | ||
channels: | ||
hello: | ||
subscribe: | ||
message: | ||
payload: | ||
type: string | ||
pattern: '^hello .+$'</code></pre> | ||
|
||
The first line of the specification starts with the document type (AsyncAPI) and the version (2.0.0) as a recommended practice. | ||
|
||
The second line identifies the application and is both required and unique. In a real environment using 'urn:com:mycompany:hello-world-app' is considered unique and preferred rather than 'hello-world-app', for example. | ||
fmvilas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<pre class="language-yaml line-numbers" data-line="3-9"><code>asyncapi: '2.0.0' | ||
id: hello-world-app | ||
channels: | ||
hello: | ||
subscribe: | ||
message: | ||
payload: | ||
type: string | ||
pattern: '^hello .+$'</code></pre> | ||
|
||
The 'channels' section of the specification houses all of the mediums where messages flow through. For example, some systems use 'topic, 'event name' or 'routing key'. Different kinds of information flow through each channel similar to the analogy of TV channels. | ||
|
||
In our example, we only have one channel called `hello`. The sample app subscribes to this channel to receive "hello {name}" messages. | ||
|
||
<pre class="language-yaml line-numbers" data-line="4-7"><code>asyncapi: '2.0.0' | ||
id: hello-world-app | ||
channels: | ||
hello: | ||
subscribe: | ||
message: | ||
payload: | ||
type: string | ||
pattern: '^hello .+$'</code></pre> | ||
|
||
You can read the highlighted lines as "this is the **payload** of the **message** your app is **subscribed** to on the «**hello**» channel". | ||
|
||
<pre class="language-yaml line-numbers" data-line="7-9"><code>asyncapi: '2.0.0' | ||
id: hello-world-app | ||
channels: | ||
hello: | ||
subscribe: | ||
message: | ||
payload: | ||
type: string | ||
pattern: '^hello .+$'</code></pre> | ||
|
||
The 'payload' object defines how the message must be structured. In this example, the message must be a string and match the given regular expression in the format "hello {name}" string. | ||
|
||
## Conclusion | ||
|
||
We've seen how to define our simple Hello World app but, **how do we send a message to our Hello World application?** | ||
|
||
Go to the next chapter to [learn more about the `servers` property](/docs/servers). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@lifewingmate I meant the recommended practice is to put this line as the first one. However, the line is mandatory. It just doesn't have to be the first.