utils

package
v0.0.0-...-df8b58b Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EcodeSystemError SYSTEM_ERROR
	EcodeSystemError = "SYSTEM_ERROR"
	// EcodeInvalidParam INVALID_PARAM
	EcodeInvalidParam = "INVALID_PARAM"
	// EcodeMissingParam MISSING_PARAM
	EcodeMissingParam = "MISSING_PARAM"
	// EcodeInvalidName INVALID_NAME
	EcodeInvalidName = "INVALID_NAME"
	// EcodeInvalidService INVALID_SERVICE
	EcodeInvalidService = "INVALID_SERVICE"
	// EcodeInvalidZone INVALID_ZONE
	EcodeInvalidZone = "INVALID_ZONE"
	// EcodeInvalidExt INVALID_EXTENSION
	EcodeInvalidExt = "INVALID_EXTENSION"
	// EcodeInvalidValue INVALID_VALUE
	EcodeInvalidValue = "INVALID_VALUE"
	// EcodeInvalidVersion INVALID_VERSION
	EcodeInvalidVersion = "INVALID_VERSION"
	// EcodeInvalidAddress INVALID_ADDRESS
	EcodeInvalidAddress = "INVALID_ADDRESS"
	// EcodeInvalidEndpoint INVALID_ENDPOINT
	EcodeInvalidEndpoint = "INVALID_ENDPOINT"
	// EcodeDamagedEndpointValue DAMAGED_ENDPOINT_VALUE
	EcodeDamagedEndpointValue = "DAMAGED_ENDPOINT_VALUE"
	// EcodeTooManyAttempts TOO_MANY_ATTEMPTS
	EcodeTooManyAttempts = "TOO_MANY_ATTEMPTS"
	// EcodeNotFound NOT_FOUND
	EcodeNotFound = "NOT_FOUND"
	// EcodeDeadlineExceeded DEADLINE_EXCEEDED
	EcodeDeadlineExceeded = "DEADLINE_EXCEEDED"
	// EcodeCanceled CANCELED
	EcodeCanceled = "CANCELED"
	// EcodeDeleted DELETED
	EcodeDeleted = "DELETED"
	// EcodeChangedServiceDesc CHANGED_SERVICE_DESC
	EcodeChangedServiceDesc = "CHANGED_SERVICE_DESC"
	// EcodeNameDuplicated NAME_DUPLICATED
	EcodeNameDuplicated = "NAME_DUPLICATED"
	// EcodeNotPermitted NOT_PERMITTED
	EcodeNotPermitted = "NOT_PERMITTED"
	// EcodeEtcdWatchFailed ETCD_WATCH_FAILED
	EcodeEtcdWatchFailed = "ETCD_WATCH_FAILED"
)
View Source
const (
	// StatusDeleted status deleted
	StatusDeleted = -1
	// StatusOk status ok
	StatusOk = 0
	// StatusDisabled status disabled
	StatusDisabled = -1
)

Variables

This section is empty.

Functions

func CleanErr

func CleanErr(err error, sysErrRet, sysErrformat string, args ...interface{}) error

CleanErr clean err

func CleanErrWithCode

func CleanErrWithCode(err error, sysErrRet, sysErrformat string, args ...interface{}) (codes.Code, error)

CleanErrWithCode clean err with code

func EncodePrivateKeyToPem

func EncodePrivateKeyToPem(key crypto.Signer) (string, error)

EncodePrivateKeyToPem encode private key to pem

func EncodeToPem

func EncodeToPem(typ string, data []byte) string

EncodeToPem encode to pem

func GetErrCode

func GetErrCode(err error) codes.Code

GetErrCode get err code

func NewPrivateKey

func NewPrivateKey(ecdsaCurve string, rsaBits int) (crypto.Signer, error)

NewPrivateKey new private key

func NextRangeFromKey

func NextRangeFromKey(key string) string

NextRangeFromKey next range from key

func RangeEndKey

func RangeEndKey(key string) string

RangeEndKey range end key

func ReadPEM

func ReadPEM(path string) (*pem.Block, error)

ReadPEM read pem

func ReadPEMCertificate

func ReadPEMCertificate(path string) (*x509.Certificate, error)

ReadPEMCertificate read cert from pem

func WriteCert

func WriteCert(path string, perm os.FileMode, derBytes []byte) error

WriteCert write cert

func WriteFile

func WriteFile(path string, perm os.FileMode, data []byte) error

WriteFile write file

func WritePem

func WritePem(path string, perm os.FileMode, typ string, data []byte) error

WritePem write pem

func WritePrivateKey

func WritePrivateKey(path string, perm os.FileMode, key crypto.Signer) error

WritePrivateKey write private key

Types

type ETCDConfig

type ETCDConfig struct {
	Endpoints []string      `default:"[\"127.0.0.1:2379\"]"`
	Timeout   time.Duration `default:"5s"`
	CACert    string
}

ETCDConfig etcd config

func (*ETCDConfig) NewEtcdClient

func (etcd *ETCDConfig) NewEtcdClient() *clientv3.Client

NewEtcdClient new etcd client

type Error

type Error struct {
	Code    string   `json:"code"`
	Message string   `json:"message,omitempty"`
	Keys    []string `json:"keys,omitempty"`
}

Error error

func Errorf

func Errorf(code, format string, args ...interface{}) *Error

Errorf errorf

func NewError

func NewError(code string, message string) *Error

NewError new error

func NewNotPermittedError

func NewNotPermittedError(msg string, keys []string) *Error

NewNotPermittedError new not permitted error

func NewSystemError

func NewSystemError(msg string) *Error

NewSystemError new system error

func SystemErrorf

func SystemErrorf(format string, args ...interface{}) *Error

SystemErrorf system errorf

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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