Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <admin@liudos.us>
  • Loading branch information
lhy1024 committed Nov 16, 2023
1 parent 50e0365 commit 23fa5f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/mcs/tso/server/apis/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package apis

import (
"fmt"
"net/http"
"strconv"
"sync"
Expand Down Expand Up @@ -150,6 +151,7 @@ type ResetTSParams struct {
// @Failure 400 {string} string "The input is invalid."
// @Failure 403 {string} string "Reset ts is forbidden."
// @Failure 500 {string} string "TSO server failed to proceed the request."
// @Failure 503 {string} string "It's a temporary failure, please retry."
// @Router /admin/reset-ts [post]
// if force-use-larger=true:
//
Expand Down Expand Up @@ -189,7 +191,8 @@ func ResetTS(c *gin.Context) {
// If the error is ErrEtcdTxnConflict, it means there is a temporary failure.
// Return 503 to let the client retry.
// Ref: https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4
c.String(http.StatusServiceUnavailable, err.Error())
c.String(http.StatusServiceUnavailable,
fmt.Sprintf("It's a temporary failure with error %s, please retry.", err.Error()))
} else {
c.String(http.StatusForbidden, err.Error())
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/tso/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package tso

import (
"fmt"
"net/http"
"strconv"

Expand Down Expand Up @@ -53,6 +54,7 @@ func NewAdminHandler(handler Handler, rd *render.Render) *AdminHandler {
// @Failure 400 {string} string "The input is invalid."
// @Failure 403 {string} string "Reset ts is forbidden."
// @Failure 500 {string} string "TSO server failed to proceed the request."
// @Failure 503 {string} string "It's a temporary failure, please retry."
// @Router /admin/reset-ts [post]
// if force-use-larger=true:
//
Expand Down Expand Up @@ -100,7 +102,8 @@ func (h *AdminHandler) ResetTS(w http.ResponseWriter, r *http.Request) {
// If the error is ErrEtcdTxnConflict, it means there is a temporary failure.
// Return 503 to let the client retry.
// Ref: https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4
h.rd.JSON(w, http.StatusServiceUnavailable, err.Error())
h.rd.JSON(w, http.StatusServiceUnavailable,
fmt.Sprintf("It's a temporary failure with error %s, please retry.", err.Error()))
} else {
h.rd.JSON(w, http.StatusForbidden, err.Error())
}
Expand Down

0 comments on commit 23fa5f0

Please sign in to comment.