codes

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCodeTypeFunc = defaultCodeTypeFunc

DefaultCodeTypeFunc default code mapping。

Functions

func SetMapper

func SetMapper(m CodeMapper)

SetMapper set user-defined mapper

Types

type Code

type Code struct {
	// Code in string
	Code string `yaml:"code"`
	// Type of code
	Type string `yaml:"type"`
	// Description code description
	Description string `yaml:"description"`
	// Service empty means full match
	Service string `yaml:"service"`
	// Method empty means full match
	Method string `yaml:"method"`
}

Code structure.

func CodeMapping

func CodeMapping(code, service, method string) *Code

CodeMapping redefine code

func NewCode

func NewCode(code string, codeType CodeType, description string) *Code

NewCode create a new code

func (*Code) String

func (c *Code) String() string

String ...

type CodeConverter

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

CodeConverter implements CodeMapper interface

func New

func New(opts ...SetupOption) *CodeConverter

New trpc codes

func (*CodeConverter) Mapping

func (cm *CodeConverter) Mapping(code, service, method string) *Code

Mapping redefine the return code

type CodeMapper

type CodeMapper interface {
	Mapping(code, service, method string) *Code
}

CodeMapper mapping interface

type CodeType

type CodeType string

CodeType ...

const (
	CodeTypeSuccess   CodeType = "success"
	CodeTypeException CodeType = "exception"
	CodeTypeTimeout   CodeType = "timeout"
)

func (CodeType) String

func (c CodeType) String() string

String ...

type CodeTypeFunc

type CodeTypeFunc func(code, service, method string) *Code

CodeTypeFunc ...

type CodeTypeMappingDescription

type CodeTypeMappingDescription struct {
	// CodeType ...
	CodeType string
	// Description ...
	Description string
}

CodeTypeMappingDescription describe code_type_mapping information Deprecated

func NewCodeTypeMappingDescription

func NewCodeTypeMappingDescription(codeType CodeType, desc string) *CodeTypeMappingDescription

NewCodeTypeMappingDescription ... Deprecated

func (*CodeTypeMappingDescription) String

func (d *CodeTypeMappingDescription) String() string

String ... Deprecated

func (*CodeTypeMappingDescription) UnmarshalText

func (d *CodeTypeMappingDescription) UnmarshalText(text []byte) error

UnmarshalText unmarshal yaml string to *CodeTypeMappingDescription。 Deprecated

type SetupOption

type SetupOption func(setupOption *setupOption)

SetupOption Configuration method of codes, specify codes, configurator, etc.

func WithCodes

func WithCodes(codes []*Code) SetupOption

WithCodes ...

func WithConfigurator

func WithConfigurator(configurator remote.Configurator) SetupOption

WithConfigurator set configurator

func WithDefaultFunc

func WithDefaultFunc(f CodeTypeFunc) SetupOption

WithDefaultFunc set the default return code redefinition method

Jump to

Keyboard shortcuts

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