I was surprised that there isn’t any webhook support since it is easy to implement and it can make life easy for consumers, however, that isn’t much of a problem for me, I started looking for events endpoints if there is any, which fortunately I found one, but unfortunately is for WebSocket.
WebSocket although see their uses for real-time communication (e.g, the console end-point), they are not reliable in terms of message delivery that does not pertain to real-time communication, I don’t need real-time communication when an instance is being created, just let me know the request is successful, and give me an end-point that deals with all events which I can further distill later.
With WebSocket, if a message is lost during transmission or the server can’t send it or the client for some unforeseen reason, can’t handle the response, is there any retry mechanism?
It would be more beneficial to have an events endpoint that provides a reliable and robust method of retrieving container-related events that do not solely rely on WebSocket, which would be an alternative to WebSocket.
This approach could include a cursor-based pagination system, where events are returned based on a specified cursor position. By implementing this approach, you would have the ability to consume events selectively, based on your requirements and preferences.
Utilizing an events endpoint would not only ensure reliability but also offer robustness. With a dedicated endpoint, consumers would have a centralized source of events, making it easier to track and manage events effectively.
Here is just a hypothetical example that returns a list of events that has occurred:
{
"events": [
{
"id": "1",
"timestamp": "2023-05-28T10:00:00Z",
"type": "container_created",
"container_id": "container-1",
"message": "Container 'container-1' has been created."
},
{
"id": "2",
"timestamp": "2023-05-28T10:05:00Z",
"type": "container_started",
"container_id": "container-1",
"message": "Container 'container-1' has started."
},
{
"id": "3",
"timestamp": "2023-05-28T10:10:00Z",
"type": "container_stopped",
"container_id": "container-1",
"message": "Container 'container-1' has stopped."
}
],
"cursor": "eyJpZCI6Mn0="
}
The cursor field indicates the position of the next set of events. In this case, the cursor value is eyJpZCI6Mn0=
. To fetch the next set of events, you would include this cursor value in your subsequent request: GET /events?cursor=eyJpZCI6Mn0=
The response would contain the next set of events along with a new cursor, enabling you to continue paginating through the events.
This gives granular control over which events to retrieve and consume, this does not have to be a cursor-based pagination, it can be anything as long as it supports a way to move forward and backward, with support for what type of events to query.