-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node/control: add
object list
control command
Includes API definition extending; server side implementation; protoc version update. The command requests server's storage engine list of objects, that are known by node. Signed-off-by: Andrey Butusov <andrey@nspcc.io>
- Loading branch information
Showing
12 changed files
with
1,289 additions
and
544 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package control | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" | ||
"github.com/nspcc-dev/neofs-node/pkg/services/control" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
func (s *Server) ListObjects(_ context.Context, req *control.ListObjectsRequest) (*control.ListObjectsResponse, error) { | ||
// verify request | ||
if err := s.isValidRequest(req); err != nil { | ||
return nil, status.Error(codes.PermissionDenied, err.Error()) | ||
} | ||
|
||
// check availability | ||
err := s.ready() | ||
if err != nil { | ||
return nil, err | ||
} | ||
// create and fill response | ||
resp := new(control.ListObjectsResponse) | ||
|
||
body := new(control.ListObjectsResponse_Body) | ||
resp.SetBody(body) | ||
|
||
objectsIds, err := engine.List(s.storage, 0) | ||
if err != nil { | ||
return nil, status.Error(codes.Internal, err.Error()) | ||
} | ||
|
||
objects := make([]*control.ObjectInfo, 0, len(objectsIds)) | ||
for _, objectId := range objectsIds { | ||
objectInfo := &control.ObjectInfo{ | ||
Address: objectId.EncodeToString(), | ||
} | ||
objects = append(objects, objectInfo) | ||
} | ||
|
||
body.SetObjects(objects) | ||
|
||
// sign the response | ||
if err := SignMessage(s.key, resp); err != nil { | ||
return nil, status.Error(codes.Internal, err.Error()) | ||
} | ||
|
||
return resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.