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

Function ExtractNamespace

x/x.go:262–276  ·  view source on GitHub ↗

ExtractNamespace parses the namespace value from the incoming gRPC context. For the non-ACL mode, it is caller's responsibility to set the galaxy namespace.

(ctx context.Context)

Source from the content-addressed store, hash-verified

260// ExtractNamespace parses the namespace value from the incoming gRPC context. For the non-ACL mode,
261// it is caller's responsibility to set the galaxy namespace.
262func ExtractNamespace(ctx context.Context) (uint64, error) {
263 md, ok := metadata.FromIncomingContext(ctx)
264 if !ok {
265 return 0, errors.New("No metadata in the context")
266 }
267 ns := md.Get("namespace")
268 if len(ns) == 0 {
269 return 0, errors.New("No namespace in the metadata of context")
270 }
271 namespace, err := strconv.ParseUint(ns[0], 0, 64)
272 if err != nil {
273 return 0, errors.Wrapf(err, "Error while parsing namespace from metadata")
274 }
275 return namespace, nil
276}
277
278func IsRootNsOperation(ctx context.Context) bool {
279 md, ok := metadata.FromIncomingContext(ctx)

Callers 15

alterMethod · 0.92
doMutateMethod · 0.92
QueryNoGrpcMethod · 0.92
doQueryMethod · 0.92
addQueryIfUniqueFunction · 0.92
upsertGuardianFunction · 0.92
upsertGrootFunction · 0.92
AssignIdsMethod · 0.92
UpdateGraphQLSchemaMethod · 0.92
createTaskQueryFunction · 0.92
expandSubgraphFunction · 0.92

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected