Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Jun 22, 2023
1 parent 0678814 commit 7ef00c4
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 107 deletions.
100 changes: 66 additions & 34 deletions examples/social-media/backend/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,52 +1,84 @@
asyncapi: 2.2.0

asyncapi: 3.0.0
info:
title: Website Backend
version: 1.0.0

servers:
websiteWebSocketServer:
$ref: '../common/servers.yaml#/websiteWebSocketServer'
$ref: ../common/servers.yaml#/websiteWebSocketServer
mosquitto:
url: mqtt://test.mosquitto.org
host: test.mosquitto.org
protocol: mqtt
tags:
- name: 'env:production'
description: This environment is meant for production use case
- name: 'kind:remote'
description: This server is a remote server. Not exposed by the application
- name: 'visibility:public'
description: This resource is public and available to everyone
bindings:
mqtt:
clientId: websocketServer
tags:
- name: "env:production"
description: "This environment is meant for production use case"
- name: "kind:remote"
description: "This server is a remote server. Not exposed by the application"
- name: "visibility:public"
description: "This resource is public and available to everyone"

channels:
comment/liked:
address: comment/liked
messages:
subscribe.message:
$ref: ../common/messages.yaml#/commentLiked
description: Notify all the services that a comment has been liked.
servers: ['mosquitto']
subscribe:
message:
$ref: '../common/messages.yaml#/commentLiked'
servers:
- $ref: '#/servers/mosquitto'
like/comment:
address: like/comment
messages:
publish.message:
$ref: ../common/messages.yaml#/likeComment
description: When a comment like is received from the frontend.
servers: ['websiteWebSocketServer']
publish:
message:
$ref: '../common/messages.yaml#/likeComment'
comment/{commentId}/changed:
description: When an event from the broker arrives telling us to update the comment likes count on the frontend.
parameters:
servers:
- $ref: '#/servers/websiteWebSocketServer'
'comment/{commentId}/changed':
address: 'comment/{commentId}/changed'
messages:
publish.message:
$ref: ../common/messages.yaml#/commentChanged
description: >-
When an event from the broker arrives telling us to update the comment
likes count on the frontend.
servers:
- $ref: '#/servers/mosquitto'
parameters:
commentId:
schema:
$ref: '../common/schemas.yaml#/commentId'
servers: ['mosquitto']
publish:
message:
$ref: '../common/messages.yaml#/commentChanged'
schema:
$ref: ../common/schemas.yaml#/commentId
update/comment/likes:
address: update/comment/likes
messages:
subscribe.message:
$ref: ../common/messages.yaml#/updateCommentLikes
description: Update comment likes count in the frontend.
servers: ['websiteWebSocketServer']
subscribe:
message:
$ref: '../common/messages.yaml#/updateCommentLikes'
servers:
- $ref: '#/servers/websiteWebSocketServer'
operations:
comment/liked.subscribe:
action: send
channel:
$ref: '#/channels/comment~1liked'
messages:
- $ref: ../common/messages.yaml#/commentLiked
like/comment.publish:
action: receive
channel:
$ref: '#/channels/like~1comment'
messages:
- $ref: ../common/messages.yaml#/likeComment
'comment/{commentId}/changed.publish':
action: receive
channel:
$ref: '#/channels/comment~1{commentId}~1changed'
messages:
- $ref: ../common/messages.yaml#/commentChanged
update/comment/likes.subscribe:
action: send
channel:
$ref: '#/channels/update~1comment~1likes'
messages:
- $ref: ../common/messages.yaml#/updateCommentLikes
65 changes: 40 additions & 25 deletions examples/social-media/comments-service/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,53 @@
asyncapi: 2.2.0

asyncapi: 3.0.0
info:
title: Comments Service
version: 1.0.0
description: This service is in charge of processing all the events related to comments.

servers:
mosquitto:
url: mqtt://test.mosquitto.org
host: test.mosquitto.org
protocol: mqtt
tags:
- name: 'env:production'
description: This environment is meant for production use case
- name: 'kind:remote'
description: This server is a remote server. Not exposed by the application
- name: 'visibility:public'
description: This resource is public and available to everyone
bindings:
mqtt:
clientId: comment-service
tags:
- name: "env:production"
description: "This environment is meant for production use case"
- name: "kind:remote"
description: "This server is a remote server. Not exposed by the application"
- name: "visibility:public"
description: "This resource is public and available to everyone"

channels:
comment/liked:
description: Updates the likes count in the database and sends the new count to the broker.
publish:
message:
$ref: '../common/messages.yaml#/commentLiked'
comment/{commentId}/changed:
description: Sends the new count to the broker after it has been updated in the database.
parameters:
address: comment/liked
messages:
publish.message:
$ref: ../common/messages.yaml#/commentLiked
description: >-
Updates the likes count in the database and sends the new count to the
broker.
'comment/{commentId}/changed':
address: 'comment/{commentId}/changed'
messages:
subscribe.message:
$ref: ../common/messages.yaml#/commentChanged
description: >-
Sends the new count to the broker after it has been updated in the
database.
parameters:
commentId:
schema:
$ref: '../common/schemas.yaml#/commentId'
subscribe:
message:
$ref: '../common/messages.yaml#/commentChanged'

schema:
$ref: ../common/schemas.yaml#/commentId
operations:
comment/liked.publish:
action: receive
channel:
$ref: '#/channels/comment~1liked'
messages:
- $ref: ../common/messages.yaml#/commentLiked
'comment/{commentId}/changed.subscribe':
action: send
channel:
$ref: '#/channels/comment~1{commentId}~1changed'
messages:
- $ref: ../common/messages.yaml#/commentChanged
3 changes: 2 additions & 1 deletion examples/social-media/common/servers.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
websiteWebSocketServer:
url: ws://mycompany.com/ws
host: mycompany.com
pathname: /ws
protocol: ws
34 changes: 23 additions & 11 deletions examples/social-media/frontend/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
asyncapi: 2.2.0

asyncapi: 3.0.0
info:
title: Website WebSocket Client
version: 1.0.0

servers:
websiteWebSocketServer:
$ref: '../common/servers.yaml#/websiteWebSocketServer'

$ref: ../common/servers.yaml#/websiteWebSocketServer
channels:
like/comment:
address: like/comment
messages:
subscribe.message:
$ref: ../common/messages.yaml#/likeComment
description: Notify the backend that a comment has been liked.
subscribe:
message:
$ref: '../common/messages.yaml#/likeComment'
update/comment/likes:
address: update/comment/likes
messages:
publish.message:
$ref: ../common/messages.yaml#/updateCommentLikes
description: Update the UI when the comment likes count is updated.
publish:
message:
$ref: '../common/messages.yaml#/updateCommentLikes'
operations:
like/comment.subscribe:
action: send
channel:
$ref: '#/channels/like~1comment'
messages:
- $ref: ../common/messages.yaml#/likeComment
update/comment/likes.publish:
action: receive
channel:
$ref: '#/channels/update~1comment~1likes'
messages:
- $ref: ../common/messages.yaml#/updateCommentLikes
39 changes: 23 additions & 16 deletions examples/social-media/notification-service/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
asyncapi: 2.2.0

asyncapi: 3.0.0
info:
title: Notifications Service
version: 1.0.0

servers:
mosquitto:
url: mqtt://test.mosquitto.org
host: test.mosquitto.org
protocol: mqtt
tags:
- name: 'env:production'
description: This environment is meant for production use case
- name: 'kind:remote'
description: This server is a remote server. Not exposed by the application
- name: 'visibility:public'
description: This resource is public and available to everyone
bindings:
mqtt:
clientId: notification-service
tags:
- name: "env:production"
description: "This environment is meant for production use case"
- name: "kind:remote"
description: "This server is a remote server. Not exposed by the application"
- name: "visibility:public"
description: "This resource is public and available to everyone"

channels:
comment/liked:
description: When a "comment has been liked" message is received, it sends an SMS or push notification to the author.
publish:
message:
$ref: '../common/messages.yaml#/commentLiked'
address: comment/liked
messages:
publish.message:
$ref: ../common/messages.yaml#/commentLiked
description: >-
When a "comment has been liked" message is received, it sends an SMS or
push notification to the author.
operations:
comment/liked.publish:
action: receive
channel:
$ref: '#/channels/comment~1liked'
messages:
- $ref: ../common/messages.yaml#/commentLiked
43 changes: 25 additions & 18 deletions examples/social-media/public-api/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
asyncapi: 2.2.0

asyncapi: 3.0.0
info:
title: Public API
description: Public API for others to interact with the system
title: Public API
version: 1.0.0

description: Public API for others to interact with the system
servers:
mosquitto:
url: mqtt://test.mosquitto.org
host: test.mosquitto.org
protocol: mqtt
tags:
- name: 'env:production'
description: This environment is meant for production use case
- name: 'kind:remote'
description: This server is a remote server. Not exposed by the application
- name: 'visibility:public'
description: This resource is public and available to everyone
bindings:
mqtt:
clientId: public-api
tags:
- name: "env:production"
description: "This environment is meant for production use case"
- name: "kind:remote"
description: "This server is a remote server. Not exposed by the application"
- name: "visibility:public"
description: "This resource is public and available to everyone"

channels:
comment/liked:
description: Others are publishing to you, whenever a comment is liked, for you to do react to such an event.
publish:
message:
$ref: '../common/messages.yaml#/commentLiked'
address: comment/liked
messages:
publish.message:
$ref: ../common/messages.yaml#/commentLiked
description: >-
Others are publishing to you, whenever a comment is liked, for you to do
react to such an event.
operations:
comment/liked.publish:
action: receive
channel:
$ref: '#/channels/comment~1liked'
messages:
- $ref: ../common/messages.yaml#/commentLiked
Loading

0 comments on commit 7ef00c4

Please sign in to comment.