status

package
v0.0.0-...-0352b5b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DetailIDCorrectMagic is an identifier of details with correct network magic
	// which can be attached to WrongMagicNumber code.
	DetailIDCorrectMagic = iota
)

details for WrongMagicNumber code.

Variables

This section is empty.

Functions

func CodeToGRPC

func CodeToGRPC(v Code) uint32

func GlobalizeCommonFail

func GlobalizeCommonFail(c *Code)

GlobalizeCommonFail globalizes the Code to the common fail section.

func GlobalizeSuccess

func GlobalizeSuccess(c *Code)

GlobalizeSuccess globalizes the Code to the success section.

func IsCommonFail

func IsCommonFail(c Code) bool

IsCommonFail checks if the Code is a common failure code.

func IsInSection

func IsInSection(code Code, sec uint32) bool

IsInSection returns true if the Code belongs to sec-th section.

func IsSuccess

func IsSuccess(c Code) bool

IsSuccess checks if the Code is a success code.

func LocalizeCommonFail

func LocalizeCommonFail(c *Code)

LocalizeCommonFail localizes the Code to the common fail section.

func LocalizeIfInSection

func LocalizeIfInSection(c *Code, sec uint32) bool

LocalizeIfInSection checks if passed global status.Code belongs to the section and:

then localizes the code and returns true,
else leaves the code unchanged and returns false.

Arg must not be nil.

func LocalizeSuccess

func LocalizeSuccess(c *Code)

LocalizeSuccess localizes the Code to the success section.

func SetStatusDetails

func SetStatusDetails(dst *Status, ds []Detail)

SetStatusDetails sets Detail list of the Status.

Types

type Code

type Code uint32

Code represents NeoFS API V2-compatible status code.

const (
	// Internal is a local Code value for INTERNAL failure status.
	Internal Code = iota
	// WrongMagicNumber is a local Code value for WRONG_MAGIC_NUMBER failure status.
	WrongMagicNumber
	// SignatureVerificationFail is a local Code value for SIGNATURE_VERIFICATION_FAIL status.
	SignatureVerificationFail
	// NodeUnderMaintenance is a local Code value for NODE_UNDER_MAINTENANCE status.
	NodeUnderMaintenance
	// InvalidArgument is a local Code value for INVALID_ARGUMENT status.
	InvalidArgument
)

Common failure codes.

const (
	// OK is a local status Code value for default success.
	OK Code = iota
)

Success codes.

func CodeFromGRPC

func CodeFromGRPC(v uint32) Code

func (Code) EqualNumber

func (x Code) EqualNumber(num uint32) bool

EqualNumber checks if the numerical Code equals num.

func (*Code) GlobalizeSection

func (x *Code) GlobalizeSection(sec uint32)

GlobalizeSection globalizes the Code of the sec-th section.

Does not make sense if the Code is outside the section.

func (Code) InSections

func (x Code) InSections(i, j uint32) bool

InSections checks if the Code is in [i,j] section list.

func (*Code) LocalizeSection

func (x *Code) LocalizeSection(sec uint32)

LocalizeSection localizes the Code to the sec-th section.

Does not make sense if the Code is outside the section.

type Detail

type Detail struct {
	// contains filtered or unexported fields
}

Detail represents structure of NeoFS API V2-compatible status detail message.

func (*Detail) FromGRPCMessage

func (x *Detail) FromGRPCMessage(m grpc.Message) error

func (*Detail) ID

func (x *Detail) ID() uint32

ID returns identifier of the Detail.

func (*Detail) SetID

func (x *Detail) SetID(id uint32)

SetID sets identifier of the Detail.

func (*Detail) SetValue

func (x *Detail) SetValue(val []byte)

SetValue sets value of the Detail.

func (*Detail) StableMarshal

func (x *Detail) StableMarshal(buf []byte) []byte

func (*Detail) StableSize

func (x *Detail) StableSize() (size int)

func (*Detail) ToGRPCMessage

func (x *Detail) ToGRPCMessage() grpc.Message

func (*Detail) Unmarshal

func (x *Detail) Unmarshal(data []byte) error

func (*Detail) Value

func (x *Detail) Value() []byte

Value returns value of the Detail.

type Status

type Status struct {
	// contains filtered or unexported fields
}

Status represents structure of NeoFS API V2-compatible status return message.

func (*Status) AppendDetails

func (x *Status) AppendDetails(ds ...Detail)

AppendDetails appends the list of details to the Status.

func (*Status) Code

func (x *Status) Code() Code

Code returns code of the Status.

func (*Status) FromGRPCMessage

func (x *Status) FromGRPCMessage(m grpc.Message) error

func (*Status) IterateDetails

func (x *Status) IterateDetails(f func(*Detail) bool)

IterateDetails iterates over details of the Status. Breaks iteration on f's true return.

Handler must not be nil.

func (*Status) Message

func (x *Status) Message() string

Message sets message of the Status.

func (*Status) NumberOfDetails

func (x *Status) NumberOfDetails() int

NumberOfParameters returns number of network parameters.

func (*Status) ResetDetails

func (x *Status) ResetDetails()

ResetDetails empties the detail list.

func (*Status) SetCode

func (x *Status) SetCode(code Code)

SetCode sets code of the Status.

func (*Status) SetMessage

func (x *Status) SetMessage(msg string)

SetMessage sets message of the Status.

func (*Status) StableMarshal

func (x *Status) StableMarshal(buf []byte) []byte

func (*Status) StableSize

func (x *Status) StableSize() (size int)

func (*Status) ToGRPCMessage

func (x *Status) ToGRPCMessage() grpc.Message

func (*Status) Unmarshal

func (x *Status) Unmarshal(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL