services

package
v0.0.0-...-0dabf1d Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

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

func NewServicerFromString(conn 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

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

NewStoragerFromString will create a new storager via connection string.

func RegisterFactory

func RegisterFactory(ty string, f Factory)

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

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 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

func NewFactory(ty string, ps ...types.Pair) (Factory, error)

NewFactory will create a new factory by service type.

func NewFactoryFromMap

func NewFactoryFromMap(ty string, m map[string]interface{}, ps ...types.Pair) (Factory, error)

NewFactoryFromMap will create a new factory by service type and map.

TODO: we will provide NewServicerFromMap and NewStoragerFromMap in the future.

func NewFactoryFromString

func NewFactoryFromString(conn string, ps ...types.Pair) (Factory, error)

NewFactoryFromString will create a new factory by service type and connection string.

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

Directories

Path Synopsis
Package azblob provided support for Azure Storage containers and blobs objects (https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction)
Package azblob provided support for Azure Storage containers and blobs objects (https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction)
Package azfile provided support for Azure Files(https://azure.microsoft.com/en-us/services/storage/files/).
Package azfile provided support for Azure Files(https://azure.microsoft.com/en-us/services/storage/files/).
bos
Package bos provided support for bos by go-storage.
Package bos provided support for bos by go-storage.
Package cephfs provided support for ceph file system(https://ceph.io).
Package cephfs provided support for ceph file system(https://ceph.io).
cos
Package cos provided support for Tencent Cloud's Cloud Object Storage (https://intl.cloud.tencent.com/product/cos)
Package cos provided support for Tencent Cloud's Cloud Object Storage (https://intl.cloud.tencent.com/product/cos)
Package dropbox provides support for Dropbox (https://www.dropbox.com/).
Package dropbox provides support for Dropbox (https://www.dropbox.com/).
Package example provided support for local file system.
Package example provided support for local file system.
Package fs provided support for local file system.
Package fs provided support for local file system.
Package ftp provided support for ftp by go-storage.
Package ftp provided support for ftp by go-storage.
gcs
Package gcs provided support for Google Cloud Storage (https://cloud.google.com/storage/)
Package gcs provided support for Google Cloud Storage (https://cloud.google.com/storage/)
Package gdrive provided support for local file system.
Package gdrive provided support for local file system.
Package hdfs provided support for Hadoop Distributed File System (HDFS).
Package hdfs provided support for Hadoop Distributed File System (HDFS).
Package kodo provided support for qiniu kodo object storage (https://www.qiniu.com/en/products/kodo)
Package kodo provided support for qiniu kodo object storage (https://www.qiniu.com/en/products/kodo)
Package memory provided support for memory file system.
Package memory provided support for memory file system.
Package minio provided support for minio by go-storage.
Package minio provided support for minio by go-storage.
obs
Package obs provided support for the Huawei Object Storage Service(https://www.huaweicloud.com/intl/en-us/product/obs.html).
Package obs provided support for the Huawei Object Storage Service(https://www.huaweicloud.com/intl/en-us/product/obs.html).
Package ocios provided support for Oracle Object Storage(https://www.oracle.com/cloud/storage/object-storage/).
Package ocios provided support for Oracle Object Storage(https://www.oracle.com/cloud/storage/object-storage/).
Package onedrive provided support for Microsoft onedrive(https://www.microsoft.com/zh-cn/microsoft-365/onedrive/online-cloud-storage).
Package onedrive provided support for Microsoft onedrive(https://www.microsoft.com/zh-cn/microsoft-365/onedrive/online-cloud-storage).
oss
Package oss provided support for Aliyun Object Storage Service (https://cn.aliyun.com/product/oss)
Package oss provided support for Aliyun Object Storage Service (https://cn.aliyun.com/product/oss)
Package qingstor provided support for qingstor object storage (https://www.qingcloud.com/products/qingstor/)
Package qingstor provided support for qingstor object storage (https://www.qingcloud.com/products/qingstor/)
s3
Package s3 provided support for AWS s3 (https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html)
Package s3 provided support for AWS s3 (https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html)
Package storj provided support for Storj Decentralized Cloud Storage(https://www.storj.io).
Package storj provided support for Storj Decentralized Cloud Storage(https://www.storj.io).
tar
Package tar provided support for tar archive files.
Package tar provided support for tar archive files.
us3
Package us3 provided support for Ucloud(https://docs.ucloud.cn).
Package us3 provided support for Ucloud(https://docs.ucloud.cn).
uss
Package uss provided support for UPYUN Storage Service (https://www.upyun.com/products/file-storage)
Package uss provided support for UPYUN Storage Service (https://www.upyun.com/products/file-storage)
Package webdav provided support for webdav archive files.
Package webdav provided support for webdav archive files.
zip
Package zip provided support for zip archive files.
Package zip provided support for zip archive files.

Jump to

Keyboard shortcuts

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