MCPcopy
hub / github.com/dgraph-io/dgraph / memoryLimitPutHandler

Function memoryLimitPutHandler

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

Source from the content-addressed store, hash-verified

157}
158
159func memoryLimitPutHandler(w http.ResponseWriter, r *http.Request) {
160 body, err := io.ReadAll(r.Body)
161 if err != nil {
162 http.Error(w, err.Error(), http.StatusInternalServerError)
163 return
164 }
165 memoryMB, err := strconv.ParseFloat(string(body), 64)
166 if err != nil {
167 http.Error(w, err.Error(), http.StatusBadRequest)
168 return
169 }
170 gqlReq := &schema.Request{
171 Query: `
172 mutation config($cacheMb: Float) {
173 config(input: {cacheMb: $cacheMb}) {
174 response {
175 code
176 }
177 }
178 }`,
179 Variables: map[string]interface{}{"cacheMb": memoryMB},
180 }
181 resp := resolveWithAdminServer(gqlReq, r, adminServer)
182
183 if len(resp.Errors) != 0 {
184 w.WriteHeader(http.StatusBadRequest)
185 x.Check2(fmt.Fprint(w, resp.Errors[0].Message))
186 return
187 }
188 w.WriteHeader(http.StatusOK)
189}
190
191func memoryLimitGetHandler(w http.ResponseWriter, r *http.Request) {
192 gqlReq := &schema.Request{

Callers 1

memoryLimitHandlerFunction · 0.85

Calls 4

Check2Function · 0.92
resolveWithAdminServerFunction · 0.85
WriteHeaderMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected