Asynchronous patterns
Let's look at various general patterns that have been used in web applications.
Endpoint callback pattern
In this pattern, when a caller calls a service, it specifies an endpoint to be called when the operation is completed. This is similar to specifying callbacks in some programming languages like JavaScript. When used purely as an HTTP callback, it is called a WebHook.
The process is roughly as follows:
- The client calls a service through a channel such as REST, RPC, or UDP. It also provides its own endpoint to notify when the result becomes ready.
- The call returns immediately.
- When the task is completed, the service calls the defined endpoint to notify the initial sender.
Remember that the service provider or receiver must be able to access the sender. For sensitive data, there must be some form of authentication to identify the sender and encryption to protect the channel from eavesdropping.
This pattern is quite popular and implemented by various web applications, such...