Add /v3/cluster/snapshot endpoint

This commit is contained in:
Ingo Oppermann
2023-06-27 15:11:31 +02:00
parent dd128ac99b
commit 89379b2acd
10 changed files with 110 additions and 13 deletions

View File

@@ -242,7 +242,13 @@ func (a *api) RemoveServer(c echo.Context) error {
// @Success 500 {array} Error
// @Router /v1/snapshot [get]
func (a *api) Snapshot(c echo.Context) error {
data, err := a.cluster.Snapshot()
origin := c.Request().Header.Get("X-Cluster-Origin")
if origin == a.id {
return Err(http.StatusLoopDetected, "", "breaking circuit")
}
data, err := a.cluster.Snapshot(origin)
if err != nil {
a.logger.Debug().WithError(err).Log("Unable to create snaphot")
return Err(http.StatusInternalServerError, "", "unable to create snapshot: %s", err.Error())