2022-02-21 17:57:27 +00:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status"
|
|
|
|
statusgrpc "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status/grpc"
|
2022-02-21 17:57:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// LocalizeFailStatus checks if passed global status.Code is related to session failure and:
|
2022-09-15 05:20:13 +00:00
|
|
|
//
|
|
|
|
// then localizes the code and returns true,
|
|
|
|
// else leaves the code unchanged and returns false.
|
2022-02-21 17:57:27 +00:00
|
|
|
//
|
|
|
|
// Arg must not be nil.
|
|
|
|
func LocalizeFailStatus(c *status.Code) bool {
|
|
|
|
return status.LocalizeIfInSection(c, uint32(statusgrpc.Section_SECTION_SESSION))
|
|
|
|
}
|
|
|
|
|
|
|
|
// GlobalizeFail globalizes local code of session failure.
|
|
|
|
//
|
|
|
|
// Arg must not be nil.
|
|
|
|
func GlobalizeFail(c *status.Code) {
|
|
|
|
c.GlobalizeSection(uint32(statusgrpc.Section_SECTION_SESSION))
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
// StatusTokenNotFound is a local status.Code value for
|
|
|
|
// TOKEN_NOT_FOUND session failure.
|
|
|
|
StatusTokenNotFound status.Code = iota
|
|
|
|
// StatusTokenExpired is a local status.Code value for
|
|
|
|
// TOKEN_EXPIRED session failure.
|
|
|
|
StatusTokenExpired
|
|
|
|
)
|