Skip to content

Commit bde0e6b

Browse files
committed
More text
1 parent 17ce951 commit bde0e6b

6 files changed

+71
-1
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,16 @@ The bot should respond with an embed card and an image.
174174

175175
## Delayed responses
176176

177-
Discord requires that interaction URL callbacks respond within 3 seconds. This can be a problem for lambdas because of the cold start problem. In order to be able to take the time needed to respond to
177+
Discord requires that interaction URL callbacks respond within 3 seconds. This can be a problem for lambdas because of the cold start problem. In order to be able to take the time needed to respond to queries we separate the acknowledgement of interactions from the response.
178+
179+
Here are some pictures to illustrate what that process looks like
180+
181+
![Deferred Message Processing Overview](./images/deferred-message-processing.png)
182+
183+
![Deferred Message Processing Sequence](./images/deferred-msg-sequence.png)
184+
185+
Result:
186+
![example](./images/deferred_interaction.gif)
178187

179188
## Invite link
180189

42.1 KB
Loading

images/deferred-msg-sequence.png

59.3 KB
Loading

images/deferred-msg-sequence.puml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@startuml deferred-msg-sequence
2+
!include <awslib/AWSCommon>
3+
!include <awslib/Compute/Lambda>
4+
!include <awslib/Database/DynamoDB>
5+
!include <awslib/Storage/SimpleStorageServiceS3>
6+
!include <awslib/ApplicationIntegration/SQS>
7+
!include <awslib/ApplicationIntegration/SNS>
8+
!include <material/common>
9+
!include <material/discord>
10+
11+
skinparam componentStyle rectangle
12+
13+
title Deferred processing sequence
14+
15+
participant "<<Discord>>\n==Interaction outgoing<color:blue><$ma_discord>" as discord_interaction
16+
LambdaParticipant(discord_lambda, "Interaction callback", "Responds to Discord interaction events")
17+
SNSParticipant(deferred_topic, "Deferred message topic", "Topic to publish deferred messages to")
18+
SQSParticipant(deferred_queue, "Deferred message queue", "Queue for deferred messages")
19+
LambdaParticipant(deferred_lambda, "Deferred messaging", "Updates existing messages with new content")
20+
participant "<<Discord>>\n==API Response<color:blue><$ma_discord>" as discord_api
21+
22+
discord_interaction -> discord_lambda: On interaction event
23+
discord_lambda -> discord_interaction: Ack msg
24+
discord_lambda -> deferred_topic: Defer msg
25+
discord_lambda <- deferred_topic: Success
26+
deferred_topic -> deferred_queue: queue msg
27+
deferred_queue -> deferred_lambda: Process msg
28+
deferred_lambda -> discord_api: Update msg
29+
deferred_lambda <- discord_api: Success
30+
deferred_lambda -> deferred_queue: Done
31+
32+
@enduml

images/deferred-msg.puml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@startuml deferred-message-processing
2+
!include <awslib/AWSCommon>
3+
!include <awslib/Compute/Lambda>
4+
!include <awslib/Database/DynamoDB>
5+
!include <awslib/Storage/SimpleStorageServiceS3>
6+
!include <awslib/ApplicationIntegration/SQS>
7+
!include <awslib/ApplicationIntegration/SNS>
8+
!include <material/common>
9+
!include <material/discord>
10+
11+
skinparam componentStyle rectangle
12+
13+
title Deferred Message Processing
14+
15+
Lambda(discord_lambda, "Interaction callback", "Responds to Discord interaction events")
16+
Lambda(deferred_lambda, "Deferred messaging", "Updates existing messages with new content")
17+
SQS(deferred_queue, "Deferred message queue", "Queue for deferred messages")
18+
SNS(deferred_topic, "Deferred message topic", "Topic to publish deferred messages to")
19+
MA_DISCORD(Blue, 1.5, discord_interaction, rectangle, "[Discord interaction outgoing]")
20+
MA_DISCORD(Blue, 1.5, discord_api, rectangle, "[Discord webhook message update]")
21+
22+
discord_interaction -d-> discord_lambda: On interaction event
23+
discord_lambda -u-> discord_interaction: Ack msg
24+
discord_lambda -> deferred_topic: Defer msg
25+
deferred_topic -> deferred_queue: queue msg
26+
deferred_queue -> deferred_lambda: Process msg
27+
deferred_lambda -u-> discord_api: Update msg
28+
29+
@enduml

images/deferred_interaction.gif

1.54 MB
Loading

0 commit comments

Comments
 (0)