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

Method UpdateExtSnapshotStreamingState

edgraph/server.go:2054–2086  ·  view source on GitHub ↗
(ctx context.Context,
	req *api.UpdateExtSnapshotStreamingStateRequest)

Source from the content-addressed store, hash-verified

2052}
2053
2054func (s *Server) UpdateExtSnapshotStreamingState(ctx context.Context,
2055 req *api.UpdateExtSnapshotStreamingStateRequest) (v *api.UpdateExtSnapshotStreamingStateResponse, err error) {
2056
2057 if req == nil {
2058 return nil, errors.New("UpdateExtSnapshotStreamingStateRequest must not be nil")
2059 }
2060
2061 // External-snapshot import is a destructive admin operation: it arms import mode and
2062 // (via StreamExtSnapshot) replaces a group store. Gate it on both authorization paths so
2063 // it is protected under ACL and under an --security auth-token. Each gate fails open when
2064 // its feature is unconfigured, so the arming requirement on the stream path backstops the
2065 // bare-OSS case.
2066 if err := AuthorizeGuardians(ctx); err != nil {
2067 return nil, err
2068 }
2069 if err := hasPoormansAuth(ctx); err != nil {
2070 return nil, err
2071 }
2072
2073 if req.Start && req.Finish {
2074 return nil, errors.New("UpdateExtSnapshotStreamingStateRequest cannot have both Start and Finish set to true")
2075 }
2076
2077 groups, err := worker.ProposeDrain(ctx, req)
2078 if err != nil {
2079 glog.Errorf("[import] failed to propose drain mode: %v", err)
2080 return nil, err
2081 }
2082
2083 resp := &api.UpdateExtSnapshotStreamingStateResponse{Groups: groups}
2084
2085 return resp, nil
2086}
2087
2088func (s *Server) StreamExtSnapshot(stream api.Dgraph_StreamExtSnapshotServer) error {
2089 defer x.ExtSnapshotStreamingState(false)

Callers

nothing calls this directly

Calls 4

ProposeDrainFunction · 0.92
AuthorizeGuardiansFunction · 0.85
hasPoormansAuthFunction · 0.70
ErrorfMethod · 0.45

Tested by

no test coverage detected