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: added content for operations in AsyncAPI Document #2171

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7c6b514
document adding-operations
BhaswatiRoy Sep 26, 2023
4fff5f3
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
d361b7f
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
46f9487
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
c59b9fd
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
26e0044
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
e5d0e60
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
7a9903f
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
2ea6b05
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
f23afda
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
ea07641
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 3, 2023
551940c
updated the adding operations sub section
BhaswatiRoy Oct 30, 2023
9749db3
updated adding operations subsection
BhaswatiRoy Oct 30, 2023
b3643a8
removed unwanted characters
BhaswatiRoy Oct 30, 2023
5b4767e
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 30, 2023
8ab1445
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 30, 2023
dc93f5a
updated the changes including diagrams, and addition of content
BhaswatiRoy Oct 30, 2023
c8ef443
Merge branch 'gsod-work-1' of https://github.com/BhaswatiRoy/website …
BhaswatiRoy Oct 30, 2023
9e7a602
updated changes
BhaswatiRoy Oct 30, 2023
aaf499f
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 31, 2023
61679a6
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Oct 31, 2023
c0da456
removed duplicate lines
BhaswatiRoy Oct 31, 2023
debd164
aligned mermaid diagram code with other writers
BhaswatiRoy Oct 31, 2023
8f5f1da
updated mermaid diagram to align with the style guide
BhaswatiRoy Nov 1, 2023
af6fa6c
added field name details in operations
BhaswatiRoy Nov 1, 2023
511e89a
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Nov 7, 2023
436b618
Update pages/docs/concepts/asyncapi-document/adding-operations.md
BhaswatiRoy Nov 7, 2023
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
---
132 changes: 132 additions & 0 deletions pages/docs/concepts/asyncapi-document/adding-operations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
title: Adding Operations
weight: 60
---

In a messaging system, the term "operations" refers to the various methods by which messages are exchanged between participants or components.
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved

## Features

- Operations describe the behaviors and capabilities of the messaging channels described in the AsyncAPI document.

- In a messaging channel, an operation represents a particular action or interaction that can be performed.

- The purpose of these operations is to provide a standardized means for describing the process of publishing, subscribing to, requesting, or replying to messages within the messaging system.
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved

## Adding Operations

`operations` are no longer under `channels` in AsyncAPI Spec 3.0.0, instead, `operations` are separate objects in the AsyncAPI document on the same level.
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved
`channels` can be linked within `operations` by referencing them within the `channels`, just like the following example -
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved
For adding operations to an AsyncAPI document, we need to define them within the channels section of the document. You can add operations to an AsyncAPI document as follows -
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved

```
onUserSignUp:
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved
title: User sign up
summary: Action to sign a user up.
description: A longer description
channel:
$ref: '#/channels/userSignup'
```

Operations can be defined as an independent object in the AsyncAPI document. Operations have the following components for it's definition -
- Locate the `channels` section in your AsyncAPI document. The `channels` section defines the messaging channels and their associated operations.

| Field Name | Type | Description |
|---|---|---|
| title | string | An easy to understand headline about the operation |
| summary | string | A brief overview of the purpose of the operation |
| description | string | A detailed explanation of the operation |
| Channel | Reference Object Link | A `ref` pointer to the definition of the channel in which the operation is performed |
| Action | "send" or "receive" | Uses `send` when the application sends a message to the given channel, and uses `receive` when the application receives a message from the given channel |
| Tags | Tag Object | List of tags for logical grouping and categorization of operations |
| Bindings | Bindings Object | A map where keys store the name of protocol and the values store protocol-specific definitions for the operation |
| Traits | Traits Object | A list of traits to apply to the operation object. Traits must be merged using Traits Merge Mechanism. The resulting object should be a valid Operation Object |

```
onUserSignUp:
title: User sign up
summary: Action to sign a user up.
description: A longer description
channel:
$ref: '#/channels/userSignup'
action: send
tags:
- name: user
- name: signup
- name: register
bindings:
amqp:
ack: false
traits:
- $ref: '#/components/operationTraits/kafka'
```
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved

## Types
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved

The operations of the AsyncAPI document are divided into the following categories based on the purpose they serve -

- <b> Publishing: </b> In the publish operation, components are able to send messages to specific channels. This operation allows publishers to publish messages or events for consumption by other components.

```mermaid
flowchart TD
BhaswatiRoy marked this conversation as resolved.
Show resolved Hide resolved
style A fill:#E5EE8C,stroke:#333,stroke-width:2px
style B fill:#CBF399,stroke:#333,stroke-width:2px
style C fill:#F5B5EF,stroke:#333,stroke-width:2px
style D fill:#F568A8,stroke:#333,stroke-width:2px
A[Components] -- Send messages --> B(Publish Operation)
B -- Messages/Events --> C[Specific Channels]
C --> D[Consumption by Other Components]
classDef labelStyle color:#000000;
class A,B,C,D,E,F,G,H,I,J labelStyle;
```

- <b> Subscribing: </b> By using the subscribe operation, components are able to receive messages from a particular channel. The subscriber can use this operation to indicate whether they are interested in receiving messages from a particular channel.

```mermaid
flowchart TD
style A fill:#E5EE8C,stroke:#333,stroke-width:2px
style B fill:#CBF399,stroke:#333,stroke-width:2px
style C fill:#F5B5EF,stroke:#333,stroke-width:2px
style D fill:#F568A8,stroke:#333,stroke-width:2px
A[Particular Channels] -- Messages --> B(Subscribe Operation)
B --> D[Indicate Interest in Receiving]
D -- Receive messages--> C[Components]
classDef labelStyle color:#000000;
class A,B,C,D,E,F,G,H,I,J labelStyle;
```

- <b> Request-Reply: </b> Request/Reply establishes a pattern of request-response communication between components. The client can send a request message, and the server will respond with a corresponding reply message. Typically, this operation is used for synchronous communication in which the client anticipates a response from the server.

```mermaid
flowchart TD
style A fill:#E5EE8C,stroke:#333,stroke-width:2px
style B fill:#F5B5EF,stroke:#333,stroke-width:2px
A[Client] -- Request message --> B(Server)
B -- Reply message --> A
classDef labelStyle color:#000000;
class A,B,C,D,E,F,G,H,I,J labelStyle;
```

- <b> Request: </b> A request operation allows components to submit a request message without requiring a response from the server. This is typically used in situations where the client does not need a direct response from the server, such as fire-and-forget or one-way communication.

```mermaid
flowchart TD
style A fill:#CBF399,stroke:#333,stroke-width:2px
style B fill:#F568A8,stroke:#333,stroke-width:2px
A[Client] -- Request message --> B[Server]
classDef labelStyle color:#000000;
class A,B,C,D,E,F,G,H,I,J labelStyle;
```

- <b> Publish-Subscribe: </b> With the publishSubscribe operation, messages published to a channel are distributed to multiple subscribers in a publish-subscribe pattern. Messages can be broadcast to a number of consumers interested in a particular topic or event at the same time.

```mermaid
flowchart TD
style A fill:#FFD700,stroke:#333,stroke-width:2px
style B fill:#F3A06A,stroke:#333,stroke-width:2px
style C fill:#3386FF,stroke:#333,stroke-width:2px
A(Publisher) -- Publish messages --> B[Channel]
B -- Messages --> C[Subscribers]
classDef labelStyle color:#000000;
class A,B,C,D,E,F,G,H,I,J labelStyle;
```