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

Method State

edgraph/server.go:1295–1320  ·  view source on GitHub ↗

State handles state requests

(ctx context.Context)

Source from the content-addressed store, hash-verified

1293
1294// State handles state requests
1295func (s *Server) State(ctx context.Context) (*api.Response, error) {
1296 if ctx.Err() != nil {
1297 return nil, ctx.Err()
1298 }
1299
1300 if err := AuthorizeGuardians(ctx); err != nil {
1301 return nil, err
1302 }
1303
1304 ms := worker.GetMembershipState()
1305 if ms == nil {
1306 return nil, errors.Errorf("No membership state found")
1307 }
1308
1309 if err := filterTablets(ctx, ms); err != nil {
1310 return nil, err
1311 }
1312
1313 m := protojson.MarshalOptions{EmitUnpopulated: true}
1314 jsonState, err := m.Marshal(ms)
1315 if err != nil {
1316 return nil, errors.Errorf("Error marshalling state information to JSON")
1317 }
1318
1319 return &api.Response{Json: jsonState}, nil
1320}
1321
1322func getAuthMode(ctx context.Context) AuthMode {
1323 if auth := ctx.Value(Authorize); auth == nil || auth.(bool) {

Callers 2

stateHandlerFunction · 0.80
resolveStateFunction · 0.80

Calls 4

GetMembershipStateFunction · 0.92
AuthorizeGuardiansFunction · 0.85
filterTabletsFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected