services

package
v4.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0 Imports: 8 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnexpected means this is an unexpected error which go-storage can't handle
	ErrUnexpected = NewErrorCode("unexpected")

	// ErrCapabilityInsufficient means this service doesn't have this capability
	ErrCapabilityInsufficient = NewErrorCode("capability insufficient")
	// ErrRestrictionDissatisfied means this operation doesn't meat service's restriction.
	ErrRestrictionDissatisfied = NewErrorCode("restriction dissatisfied")

	// ErrObjectNotExist means the object to be operated is not exist.
	ErrObjectNotExist = NewErrorCode("object not exist")
	// ErrObjectModeInvalid means the provided object mode is invalid.
	ErrObjectModeInvalid = NewErrorCode("object mode invalid")
	// ErrPermissionDenied means this operation doesn't have enough permission.
	ErrPermissionDenied = NewErrorCode("permission denied")
	// ErrListModeInvalid means the provided list mode is invalid.
	ErrListModeInvalid = NewErrorCode("list mode invalid")
	// ErrServiceNotRegistered means this service is not registered.
	ErrServiceNotRegistered = NewErrorCode("service not registered")
	// ErrServiceInternal means this service has an internal error.
	ErrServiceInternal = NewErrorCode("service internal")
	// ErrRequestThrottled means there are too many requests.
	ErrRequestThrottled = NewErrorCode("request throttled")
)
View Source
var (
	// ErrConnectionStringInvalid means the connection string is invalid.
	ErrConnectionStringInvalid = NewErrorCode("connection string is invalid")
)

Functions

func NewErrorCode

func NewErrorCode(text string) error

NewErrorCode creates a new error code.

Developers SHOULD use this function to define error codes (sentinel errors), instead of `NewErrorCode`

Users SHOULD NOT call this function. Use defined error codes instead.

func NewServicer

func NewServicer(ty string, ps ...types.Pair) (types.Servicer, error)

NewServicer will initiate a new servicer.

func NewServicerFromString added in v4.2.0

func NewServicerFromString(connStr string, ps ...types.Pair) (types.Servicer, error)

NewServicerFromString will create a new service via connection string.

func NewStorager

func NewStorager(ty string, ps ...types.Pair) (types.Storager, error)

NewStorager will initiate a new storager.

func NewStoragerFromString added in v4.2.0

func NewStoragerFromString(connStr string, ps ...types.Pair) (types.Storager, error)

NewStoragerFromString will create a new storager via connection string.

func RegisterSchema added in v4.2.0

func RegisterSchema(ty string, m map[string]string)

RegisterSchema will register a service's pair map.

Users SHOULD NOT call this function.

func RegisterServicer

func RegisterServicer(ty string, fn NewServicerFunc)

RegisterServicer will register a servicer.

func RegisterStorager

func RegisterStorager(ty string, fn NewStoragerFunc)

RegisterStorager will register a storager.

Types

type InitError

type InitError struct {
	Op   string
	Type string
	Err  error

	Pairs []types.Pair
}

InitError means this service init failed.

Only returned in New

func (InitError) Error

func (e InitError) Error() string

func (InitError) Unwrap

func (e InitError) Unwrap() error

Unwrap implements xerrors.Wrapper

type InternalError

type InternalError interface {
	// IsInternalError SHOULD and SHOULD ONLY be implemented by error definitions in go-storage & go-service-*.
	// We depends on the InternalError interface to distinguish our errors.
	// There's no need for user code to implement or use this function and interface.
	IsInternalError()
}

type ListModeInvalidError

type ListModeInvalidError struct {
	Actual types.ListMode
}

ListModeInvalidError means the provided list mode is invalid.

func (ListModeInvalidError) Error

func (e ListModeInvalidError) Error() string

func (ListModeInvalidError) IsInternalError

func (e ListModeInvalidError) IsInternalError()

IsInternalError implements InternalError

func (ListModeInvalidError) Unwrap

func (e ListModeInvalidError) Unwrap() error

type MetadataUnrecognizedError

type MetadataUnrecognizedError struct {
	Key   string
	Value interface{}
}

MetadataUnrecognizedError means this operation meets unrecognized metadata.

func (MetadataUnrecognizedError) Error

func (MetadataUnrecognizedError) IsInternalError

func (e MetadataUnrecognizedError) IsInternalError()

IsInternalError implements InternalError

func (MetadataUnrecognizedError) Unwrap

func (e MetadataUnrecognizedError) Unwrap() error

Unwrap implements xerrors.Wrapper

type NewServicerFunc

type NewServicerFunc func(ps ...types.Pair) (types.Servicer, error)

NewServicerFunc is a function that can initiate a new servicer.

type NewStoragerFunc

type NewStoragerFunc func(ps ...types.Pair) (types.Storager, error)

NewStoragerFunc is a function that can initiate a new storager.

type ObjectModeInvalidError

type ObjectModeInvalidError struct {
	Expected types.ObjectMode
	Actual   types.ObjectMode
}

ObjectModeInvalidError means the provided object mode is invalid.

func (ObjectModeInvalidError) Error

func (e ObjectModeInvalidError) Error() string

func (ObjectModeInvalidError) IsInternalError

func (e ObjectModeInvalidError) IsInternalError()

IsInternalError implements InternalError

func (ObjectModeInvalidError) Unwrap

func (e ObjectModeInvalidError) Unwrap() error

type PairRequiredError

type PairRequiredError struct {
	Keys []string
}

PairRequiredError means this operation has required pair but missing.

func (PairRequiredError) Error

func (e PairRequiredError) Error() string

func (PairRequiredError) IsInternalError

func (e PairRequiredError) IsInternalError()

IsInternalError implements InternalError

func (PairRequiredError) Unwrap

func (e PairRequiredError) Unwrap() error

Unwrap implements xerrors.Wrapper

type PairUnsupportedError

type PairUnsupportedError struct {
	Pair types.Pair
}

PairUnsupportedError means this operation has unsupported pair.

func (PairUnsupportedError) Error

func (e PairUnsupportedError) Error() string

func (PairUnsupportedError) IsInternalError

func (e PairUnsupportedError) IsInternalError()

IsInternalError implements InternalError

func (PairUnsupportedError) Unwrap

func (e PairUnsupportedError) Unwrap() error

Unwrap implements xerrors.Wrapper

type ServiceError

type ServiceError struct {
	Op  string
	Err error

	types.Servicer
	Name string
}

ServiceError represent errors related to service.

Only returned in Servicer related operations

func (ServiceError) Error

func (e ServiceError) Error() string

func (ServiceError) Unwrap

func (e ServiceError) Unwrap() error

Unwrap implements xerrors.Wrapper

type StorageError

type StorageError struct {
	Op  string
	Err error

	types.Storager
	Path []string
}

StorageError represent errors related to storage.

Only returned in Storager related operations

func (StorageError) Error

func (e StorageError) Error() string

func (StorageError) Unwrap

func (e StorageError) Unwrap() error

Unwrap implements xerrors.Wrapper

Jump to

Keyboard shortcuts

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