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

Function filterTablets

edgraph/server.go:1269–1292  ·  view source on GitHub ↗

Filter out the tablets that do not belong to the requestor's namespace.

(ctx context.Context, ms *pb.MembershipState)

Source from the content-addressed store, hash-verified

1267
1268// Filter out the tablets that do not belong to the requestor's namespace.
1269func filterTablets(ctx context.Context, ms *pb.MembershipState) error {
1270 if !x.WorkerConfig.AclEnabled {
1271 return nil
1272 }
1273 namespace, err := x.ExtractNamespaceFrom(ctx)
1274 if err != nil {
1275 return errors.Errorf("Namespace not found in JWT.")
1276 }
1277 if namespace == x.RootNamespace {
1278 // For galaxy namespace, we don't want to filter out the predicates.
1279 return nil
1280 }
1281 for _, group := range ms.GetGroups() {
1282 tablets := make(map[string]*pb.Tablet)
1283 for pred, tablet := range group.GetTablets() {
1284 if ns, attr := x.ParseNamespaceAttr(pred); namespace == ns {
1285 tablets[attr] = tablet
1286 tablets[attr].Predicate = attr
1287 }
1288 }
1289 group.Tablets = tablets
1290 }
1291 return nil
1292}
1293
1294// State handles state requests
1295func (s *Server) State(ctx context.Context) (*api.Response, error) {

Callers 1

StateMethod · 0.85

Calls 5

ExtractNamespaceFromFunction · 0.92
ParseNamespaceAttrFunction · 0.92
GetGroupsMethod · 0.80
ErrorfMethod · 0.45
GetTabletsMethod · 0.45

Tested by

no test coverage detected