MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / drainingHandler

Function drainingHandler

dgraph/cmd/alpha/admin.go:100–128  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

98}
99
100func drainingHandler(w http.ResponseWriter, r *http.Request) {
101 enableStr := r.URL.Query().Get("enable")
102
103 enable, err := strconv.ParseBool(enableStr)
104 if err != nil {
105 x.SetStatus(w, x.ErrorInvalidRequest,
106 "Found invalid value for the enable parameter")
107 return
108 }
109
110 gqlReq := &schema.Request{
111 Query: `
112 mutation draining($enable: Boolean) {
113 draining(enable: $enable) {
114 response {
115 code
116 }
117 }
118 }`,
119 Variables: map[string]interface{}{"enable": enable},
120 }
121 if resp := resolveWithAdminServer(gqlReq, r, adminServer); len(resp.Errors) != 0 {
122 x.SetStatus(w, resp.Errors[0].Message, "draining mode request failed.")
123 return
124 }
125 w.Header().Set("Content-Type", "application/json")
126 x.Check2(w.Write([]byte(fmt.Sprintf(`{"code": "Success",`+
127 `"message": "draining mode has been set to %v"}`, enable))))
128}
129
130func shutDownHandler(w http.ResponseWriter, r *http.Request) {
131 gqlReq := &schema.Request{

Callers

nothing calls this directly

Calls 7

SetStatusFunction · 0.92
Check2Function · 0.92
resolveWithAdminServerFunction · 0.85
GetMethod · 0.65
SetMethod · 0.65
WriteMethod · 0.65
QueryMethod · 0.45

Tested by

no test coverage detected