forked from TrueCloudLab/frostfs-sdk-go
Compare commits
2 commits
master
...
support/v1
Author | SHA1 | Date | |
---|---|---|---|
8412b075a5 | |||
e5040d35e9 |
1 changed files with 20 additions and 4 deletions
|
@ -26,6 +26,16 @@ const (
|
||||||
defaultStreamTimeout = 10 * time.Second
|
defaultStreamTimeout = 10 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SubTreeSort defines an order of nodes returned from GetSubTree RPC.
|
||||||
|
type SubTreeSort int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
// NoneOrder does not specify order of nodes returned in GetSubTree RPC.
|
||||||
|
NoneOrder SubTreeSort = iota
|
||||||
|
// AscendingOrder specifies ascending alphabetical order of nodes based on FilePath attribute.
|
||||||
|
AscendingOrder
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrNodeNotFound is returned from Tree service in case of not found error.
|
// ErrNodeNotFound is returned from Tree service in case of not found error.
|
||||||
ErrNodeNotFound = errors.New("not found")
|
ErrNodeNotFound = errors.New("not found")
|
||||||
|
@ -119,6 +129,7 @@ type GetSubTreeParams struct {
|
||||||
RootID uint64
|
RootID uint64
|
||||||
Depth uint32
|
Depth uint32
|
||||||
BearerToken []byte
|
BearerToken []byte
|
||||||
|
Order SubTreeSort
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddNodeParams groups parameters of Pool.AddNode operation.
|
// AddNodeParams groups parameters of Pool.AddNode operation.
|
||||||
|
@ -388,12 +399,17 @@ func (p *Pool) GetSubTree(ctx context.Context, prm GetSubTreeParams) (*SubTreeRe
|
||||||
RootId: prm.RootID,
|
RootId: prm.RootID,
|
||||||
Depth: prm.Depth,
|
Depth: prm.Depth,
|
||||||
BearerToken: prm.BearerToken,
|
BearerToken: prm.BearerToken,
|
||||||
OrderBy: &grpcService.GetSubTreeRequest_Body_Order{
|
OrderBy: new(grpcService.GetSubTreeRequest_Body_Order),
|
||||||
Direction: grpcService.GetSubTreeRequest_Body_Order_Asc,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch prm.Order {
|
||||||
|
case AscendingOrder:
|
||||||
|
request.Body.OrderBy.Direction = grpcService.GetSubTreeRequest_Body_Order_Asc
|
||||||
|
default:
|
||||||
|
request.Body.OrderBy.Direction = grpcService.GetSubTreeRequest_Body_Order_None
|
||||||
|
}
|
||||||
|
|
||||||
if err := p.signRequest(request.Body, func(key, sign []byte) {
|
if err := p.signRequest(request.Body, func(key, sign []byte) {
|
||||||
request.Signature = &grpcService.Signature{
|
request.Signature = &grpcService.Signature{
|
||||||
Key: key,
|
Key: key,
|
||||||
|
@ -583,7 +599,7 @@ func handleError(msg string, err error) error {
|
||||||
}
|
}
|
||||||
if strings.Contains(err.Error(), "not found") {
|
if strings.Contains(err.Error(), "not found") {
|
||||||
return fmt.Errorf("%w: %s", ErrNodeNotFound, err.Error())
|
return fmt.Errorf("%w: %s", ErrNodeNotFound, err.Error())
|
||||||
} else if strings.Contains(err.Error(), "is denied by") {
|
} else if strings.Contains(err.Error(), "denied") {
|
||||||
return fmt.Errorf("%w: %s", ErrNodeAccessDenied, err.Error())
|
return fmt.Errorf("%w: %s", ErrNodeAccessDenied, err.Error())
|
||||||
}
|
}
|
||||||
return fmt.Errorf("%s: %w", msg, err)
|
return fmt.Errorf("%s: %w", msg, err)
|
||||||
|
|
Loading…
Reference in a new issue