-
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.
Feat/new meta base helpers in neofs lens (#2834)
- Loading branch information
Showing
12 changed files
with
88 additions
and
0 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,28 @@ | ||
package meta | ||
|
||
import ( | ||
"github.com/mr-tron/base58" | ||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var idCMD = &cobra.Command{ | ||
Use: "id", | ||
Short: "Read shard ID the metabase is attached to", | ||
Args: cobra.NoArgs, | ||
Run: idFunc, | ||
} | ||
|
||
func init() { | ||
common.AddComponentPathFlag(idCMD, &vPath) | ||
} | ||
|
||
func idFunc(cmd *cobra.Command, _ []string) { | ||
db := openMeta(cmd, true) | ||
defer db.Close() | ||
|
||
idRaw, err := db.ReadShardID() | ||
common.ExitOnErr(cmd, common.Errf("metabase's `ReadShardID`: %w", err)) | ||
|
||
cmd.Println(base58.Encode(idRaw)) | ||
} |
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,49 @@ | ||
package meta | ||
|
||
import ( | ||
"fmt" | ||
|
||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal" | ||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var listCMD = &cobra.Command{ | ||
Use: "list", | ||
Short: "List objects in metabase (metabase's List method)", | ||
Args: cobra.NoArgs, | ||
Run: listFunc, | ||
} | ||
|
||
var vLimit uint32 | ||
|
||
const limitFlagName = "limit" | ||
|
||
func init() { | ||
listCMD.Flags().Uint32Var(&vLimit, limitFlagName, 0, "Number of objects to list") | ||
err := listCMD.MarkFlagRequired(limitFlagName) | ||
if err != nil { | ||
panic(fmt.Errorf("mark required flag %s failed: %w", limitFlagName, err)) | ||
} | ||
|
||
common.AddComponentPathFlag(listCMD, &vPath) | ||
} | ||
|
||
func listFunc(cmd *cobra.Command, _ []string) { | ||
db := openMeta(cmd, true) | ||
defer db.Close() | ||
|
||
if vLimit == 0 { | ||
common.ExitOnErr(cmd, fmt.Errorf("%s flag must be positive", limitFlagName)) | ||
} | ||
|
||
var prm meta.ListPrm | ||
prm.SetCount(vLimit) | ||
|
||
res, err := db.ListWithCursor(prm) | ||
common.ExitOnErr(cmd, common.Errf("metabase's `ListWithCursor`: %w", err)) | ||
|
||
for _, addressWithType := range res.AddressList() { | ||
cmd.Printf("%s, Type: %s\n", addressWithType.Address, addressWithType.Type) | ||
} | ||
} |
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
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