frostfs-node/pkg/services/object/delete/delete.go
Evgenii Stratonikov 5f8093ec50
Some checks failed
DCO action / DCO (pull_request) Successful in 3m48s
Vulncheck / Vulncheck (pull_request) Successful in 3m56s
Build / Build Components (1.20) (pull_request) Successful in 7m43s
Build / Build Components (1.21) (pull_request) Successful in 7m45s
Tests and linters / Tests with -race (pull_request) Failing after 8m29s
Tests and linters / Staticcheck (pull_request) Successful in 9m22s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m46s
Tests and linters / Tests (1.20) (pull_request) Successful in 10m7s
Tests and linters / Lint (pull_request) Successful in 10m47s
[#648] objsvc/delete: Handle errors in Go style
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-08-25 11:19:50 +03:00

45 lines
1 KiB
Go

package deletesvc
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
"go.uber.org/zap"
)
// Delete serves requests to remote the objects.
func (s *Service) Delete(ctx context.Context, prm Prm) error {
// If session token is not found we will fail during tombstone PUT.
// Here we fail immediately to ensure no unnecessary network communication is done.
if tok := prm.common.SessionToken(); tok != nil {
_, err := s.keyStorage.GetKey(&util.SessionInfo{
ID: tok.ID(),
Owner: tok.Issuer(),
})
if err != nil {
return err
}
}
exec := &execCtx{
svc: s,
prm: prm,
}
exec.setLogger(s.log)
return exec.execute(ctx)
}
func (exec *execCtx) execute(ctx context.Context) error {
exec.log.Debug(logs.ServingRequest)
if err := exec.executeLocal(ctx); err != nil {
exec.log.Debug(logs.OperationFinishedWithError, zap.String("error", err.Error()))
return err
}
exec.log.Debug(logs.OperationFinishedSuccessfully)
return nil
}