Documentation ¶
Index ¶
- Variables
- func NewErrorCode(text string) error
- func NewServicer(ty string, ps ...types.Pair) (types.Servicer, error)
- func NewServicerFromString(conn string, ps ...types.Pair) (types.Servicer, error)
- func NewStorager(ty string, ps ...types.Pair) (types.Storager, error)
- func NewStoragerFromString(conn string, ps ...types.Pair) (types.Storager, error)
- func RegisterFactory(ty string, f Factory)
- func RegisterSchema(ty string, m map[string]string)
- func RegisterServicer(ty string, fn NewServicerFunc)
- func RegisterStorager(ty string, fn NewStoragerFunc)
- type Factory
- type InitError
- type InternalError
- type ListModeInvalidError
- type MetadataUnrecognizedError
- type NewServicerFunc
- type NewStoragerFunc
- type ObjectModeInvalidError
- type PairRequiredError
- type PairUnsupportedError
- type ServiceError
- type StorageError
Constants ¶
This section is empty.
Variables ¶
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") )
var ( // ErrConnectionStringInvalid means the connection string is invalid. ErrConnectionStringInvalid = NewErrorCode("connection string is invalid") )
Functions ¶
func NewErrorCode ¶
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 ¶
NewServicer will initiate a new servicer.
func NewServicerFromString ¶
NewServicerFromString will create a new service via connection string.
func NewStorager ¶
NewStorager will initiate a new storager.
func NewStoragerFromString ¶
NewStoragerFromString will create a new storager via connection string.
func RegisterFactory ¶
RegisterFactory is used to register a new service.
NOTE:
- This function is not for public use, it should only be called in service init() function.
- This function is not concurrent-safe.
func RegisterSchema ¶
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 Factory ¶
type Factory interface { // FromString fill factory with data parsed from connection string. // // The connection string will be parsed by the following format: // // s3://<credential>@<endpoint>/<name>/<work_dir>?force_path_style FromString(conn string) (err error) // FromMap fill factory with data parsed from map. // // The map will be parsed by the following format: // // { // "credential": <credential>, // "endpoint": <endpoint>, // "name": <name>, // "work_dir": <work_dir>, // "force_path_style": true // } FromMap(m map[string]interface{}) (err error) // WithPairs fill factory with data parsed from key-value pairs. WithPairs(ps ...types.Pair) (err error) // NewServicer will create a new service via already initialized factory. // // Service should implement `newService() (*Service, error)` // // It's possible that the factory only support init Storager, but not init Servicer. // For example, services like `fs` only have Storager but no Servicer support. // We will generate an error for it. NewServicer() (srv types.Servicer, err error) // NewStorager will create a new storage via already initialized factory. // // Service should implement `newStorage() (*Storage, error)` // // It's possible that the factory is OK to NewServicer but not OK to NewStorager. // For example, services like `s3` will fail to init a storager will user doesn't input a bucket name. // We will generate an error for it. NewStorager() (sto types.Storager, err error) }
Factory is used to initialize a new service or storage.
We will generate a Factory struct which implement this interface for each service.
func NewFactory ¶
NewFactory will create a new factory by service type.
func NewFactoryFromMap ¶
NewFactoryFromMap will create a new factory by service type and map.
TODO: we will provide NewServicerFromMap and NewStoragerFromMap in the future.
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 ¶
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 (e MetadataUnrecognizedError) Error() string
func (MetadataUnrecognizedError) IsInternalError ¶
func (e MetadataUnrecognizedError) IsInternalError()
IsInternalError implements InternalError
func (MetadataUnrecognizedError) Unwrap ¶
func (e MetadataUnrecognizedError) Unwrap() error
Unwrap implements xerrors.Wrapper
type NewServicerFunc ¶
NewServicerFunc is a function that can initiate a new servicer.
type NewStoragerFunc ¶
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 ¶
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 ¶
ServiceError represent errors related to service.
Only returned in Servicer related operations
func (ServiceError) Error ¶
func (e ServiceError) Error() string
type StorageError ¶
StorageError represent errors related to storage.
Only returned in Storager related operations
func (StorageError) Error ¶
func (e StorageError) Error() string