Documentation
¶
Index ¶
- Variables
- type BucketMetadata
- type BucketMetadataSys
- func (sys *BucketMetadataSys) CreateBucket(ctx context.Context, bucket, region, accessKey string) error
- func (sys *BucketMetadataSys) DeleteBucket(ctx context.Context, bucket string) error
- func (sys *BucketMetadataSys) DeleteBucketPolicy(ctx context.Context, bucket string) error
- func (sys *BucketMetadataSys) DeleteBucketTagging(ctx context.Context, bucket string) error
- func (sys *BucketMetadataSys) GetAllBucketsOfUser(ctx context.Context, username string) ([]BucketMetadata, error)
- func (sys *BucketMetadataSys) GetBucketMeta(ctx context.Context, bucket string) (meta BucketMetadata, err error)
- func (sys *BucketMetadataSys) GetPolicyConfig(ctx context.Context, bucket string) (*policy.Policy, error)
- func (sys *BucketMetadataSys) GetTaggingConfig(ctx context.Context, bucket string) (*Tags, error)
- func (sys *BucketMetadataSys) HasBucket(ctx context.Context, bucket string) bool
- func (sys *BucketMetadataSys) NewNSLock(bucket string) lock.RWLocker
- func (sys *BucketMetadataSys) SetEmptyBucket(emptyBucket func(ctx context.Context, bucket string) (bool, error))
- func (sys *BucketMetadataSys) UpdateBucketPolicy(ctx context.Context, bucket string, p *policy.Policy) error
- func (sys *BucketMetadataSys) UpdateBucketTagging(ctx context.Context, bucket string, tags *Tags) error
- type BucketNotFound
- type BucketPolicyNotFound
- type BucketTaggingNotFound
- type ListMultipartsInfo
- type ListObjectsInfo
- type ListObjectsV2Info
- type ListPartsInfo
- type MultipartInfo
- type ObjectInfo
- type StorageSys
- func (s *StorageSys) AbortMultipartUpload(ctx context.Context, bucket string, object string, uploadID string) error
- func (s *StorageSys) CleanObjectsInBucket(ctx context.Context, bucket string) error
- func (s *StorageSys) CompleteMultiPartUpload(ctx context.Context, bucket string, object string, uploadID string, ...) (oi ObjectInfo, err error)
- func (s *StorageSys) DeleteObject(ctx context.Context, bucket, object string) error
- func (s *StorageSys) EmptyBucket(ctx context.Context, bucket string) (bool, error)
- func (s *StorageSys) GetMultipartInfo(ctx context.Context, bucket string, object string, uploadID string) (MultipartInfo, error)
- func (s *StorageSys) GetObject(ctx context.Context, bucket, object string) (ObjectInfo, io.ReadCloser, error)
- func (s *StorageSys) GetObjectInfo(ctx context.Context, bucket, object string) (meta ObjectInfo, err error)
- func (s *StorageSys) ListMultipartUploads(ctx context.Context, ...) (result ListMultipartsInfo, err error)
- func (s *StorageSys) ListObjectParts(ctx context.Context, bucket, object, uploadID string, ...) (result ListPartsInfo, err error)
- func (s *StorageSys) ListObjects(ctx context.Context, bucket string, prefix string, marker string, ...) (loi ListObjectsInfo, err error)
- func (s *StorageSys) ListObjectsV2(ctx context.Context, bucket string, prefix string, continuationToken string, ...) (ListObjectsV2Info, error)
- func (s *StorageSys) NewMultipartUpload(ctx context.Context, bucket string, object string, meta map[string]string) (MultipartInfo, error)
- func (s *StorageSys) NewNSLock(bucket string, objects ...string) lock.RWLocker
- func (s *StorageSys) PutObjectPart(ctx context.Context, bucket string, object string, uploadID string, partID int, ...) (pi objectPartInfo, err error)
- func (s *StorageSys) SetHasBucket(hasBucket func(ctx context.Context, bucket string) bool)
- func (s *StorageSys) SetNewBucketNSLock(newBucketNSLock func(bucket string) lock.RWLocker)
- func (s *StorageSys) StoreObject(ctx context.Context, bucket, object string, reader io.ReadCloser, size int64, ...) (ObjectInfo, error)
- type TagSet
- type Tags
Constants ¶
This section is empty.
Variables ¶
var ErrBucketNotEmpty = errors.New("bucket not empty")
var ErrObjectNotFound = errors.New("object not found")
Functions ¶
This section is empty.
Types ¶
type BucketMetadata ¶
type BucketMetadata struct {
Name string
Region string
Owner string
Created time.Time
PolicyConfig *policy.Policy
TaggingConfig *Tags
}
BucketMetadata contains bucket metadata.
func NewBucketMetadata ¶
func NewBucketMetadata(name, region, accessKey string) *BucketMetadata
NewBucketMetadata creates BucketMetadata with the supplied name and Created to Now.
type BucketMetadataSys ¶
type BucketMetadataSys struct {
// contains filtered or unexported fields
}
BucketMetadataSys captures all bucket metadata for a given cluster.
func NewBucketMetadataSys ¶
func NewBucketMetadataSys(db *uleveldb.ULevelDB) *BucketMetadataSys
NewBucketMetadataSys - creates new policy system.
func (*BucketMetadataSys) CreateBucket ¶
func (sys *BucketMetadataSys) CreateBucket(ctx context.Context, bucket, region, accessKey string) error
CreateBucket - create a new Bucket
func (*BucketMetadataSys) DeleteBucket ¶
func (sys *BucketMetadataSys) DeleteBucket(ctx context.Context, bucket string) error
DeleteBucket bucket.
func (*BucketMetadataSys) DeleteBucketPolicy ¶
func (sys *BucketMetadataSys) DeleteBucketPolicy(ctx context.Context, bucket string) error
DeleteBucketPolicy Delete bucket metadata . The configData data should not be modified after being sent here.
func (*BucketMetadataSys) DeleteBucketTagging ¶
func (sys *BucketMetadataSys) DeleteBucketTagging(ctx context.Context, bucket string) error
func (*BucketMetadataSys) GetAllBucketsOfUser ¶
func (sys *BucketMetadataSys) GetAllBucketsOfUser(ctx context.Context, username string) ([]BucketMetadata, error)
GetAllBucketsOfUser metadata for all bucket.
func (*BucketMetadataSys) GetBucketMeta ¶
func (sys *BucketMetadataSys) GetBucketMeta(ctx context.Context, bucket string) (meta BucketMetadata, err error)
GetBucketMeta metadata for a bucket.
func (*BucketMetadataSys) GetPolicyConfig ¶
func (sys *BucketMetadataSys) GetPolicyConfig(ctx context.Context, bucket string) (*policy.Policy, error)
GetPolicyConfig returns configured bucket policy
func (*BucketMetadataSys) GetTaggingConfig ¶
func (*BucketMetadataSys) HasBucket ¶
func (sys *BucketMetadataSys) HasBucket(ctx context.Context, bucket string) bool
HasBucket metadata for a bucket.
func (*BucketMetadataSys) NewNSLock ¶
func (sys *BucketMetadataSys) NewNSLock(bucket string) lock.RWLocker
NewNSLock - initialize a new namespace RWLocker instance.
func (*BucketMetadataSys) SetEmptyBucket ¶
func (*BucketMetadataSys) UpdateBucketPolicy ¶
func (sys *BucketMetadataSys) UpdateBucketPolicy(ctx context.Context, bucket string, p *policy.Policy) error
UpdateBucketPolicy Update bucket metadata . The configData data should not be modified after being sent here.
func (*BucketMetadataSys) UpdateBucketTagging ¶
type BucketNotFound ¶
BucketNotFound - no bucket found.
func (BucketNotFound) Error ¶
func (e BucketNotFound) Error() string
type BucketPolicyNotFound ¶
BucketPolicyNotFound - no bucket policy found.
func (BucketPolicyNotFound) Error ¶
func (e BucketPolicyNotFound) Error() string
type BucketTaggingNotFound ¶
func (BucketTaggingNotFound) Error ¶
func (e BucketTaggingNotFound) Error() string
type ListMultipartsInfo ¶
type ListMultipartsInfo struct {
// Together with upload-id-marker, this parameter specifies the multipart upload
// after which listing should begin.
KeyMarker string
// Together with key-marker, specifies the multipart upload after which listing
// should begin. If key-marker is not specified, the upload-id-marker parameter
// is ignored.
UploadIDMarker string
// When a list is truncated, this element specifies the value that should be
// used for the key-marker request parameter in a subsequent request.
NextKeyMarker string
// When a list is truncated, this element specifies the value that should be
// used for the upload-id-marker request parameter in a subsequent request.
NextUploadIDMarker string
// Maximum number of multipart uploads that could have been included in the
// response.
MaxUploads int
// Indicates whether the returned list of multipart uploads is truncated. A
// value of true indicates that the list was truncated. The list can be truncated
// if the number of multipart uploads exceeds the limit allowed or specified
// by max uploads.
IsTruncated bool
// List of all pending uploads.
Uploads []MultipartInfo
// When a prefix is provided in the request, The result contains only keys
// starting with the specified prefix.
Prefix string
// A character used to truncate the object prefixes.
// NOTE: only supported delimiter is '/'.
Delimiter string
// CommonPrefixes contains all (if there are any) keys between Prefix and the
// next occurrence of the string specified by delimiter.
CommonPrefixes []string
EncodingType string // Not supported yet.
}
ListMultipartsInfo - represnets bucket resources for incomplete multipart uploads.
func (ListMultipartsInfo) Lookup ¶
func (lm ListMultipartsInfo) Lookup(uploadID string) bool
Lookup - returns if uploadID is valid
type ListObjectsInfo ¶
type ListObjectsInfo struct {
// Indicates whether the returned list objects response is truncated. A
// value of true indicates that the list was truncated. The list can be truncated
// if the number of objects exceeds the limit allowed or specified
// by max keys.
IsTruncated bool
// When response is truncated (the IsTruncated element value in the response is true),
// you can use the key name in this field as marker in the subsequent
// request to get next set of objects.
//
// NOTE: AWS S3 returns NextMarker only if you have delimiter request parameter specified,
NextMarker string
// List of objects info for this request.
Objects []ObjectInfo
// List of prefixes for this request.
Prefixes []string
}
ListObjectsInfo - container for list objects.
type ListObjectsV2Info ¶
type ListObjectsV2Info struct {
// Indicates whether the returned list objects response is truncated. A
// value of true indicates that the list was truncated. The list can be truncated
// if the number of objects exceeds the limit allowed or specified
// by max keys.
IsTruncated bool
// When response is truncated (the IsTruncated element value in the response
// is true), you can use the key name in this field as marker in the subsequent
// request to get next set of objects.
//
// NOTE: This element is returned only if you have delimiter request parameter
// specified.
ContinuationToken string
NextContinuationToken string
// List of objects info for this request.
Objects []ObjectInfo
// List of prefixes for this request.
Prefixes []string
}
ListObjectsV2Info - container for list objects version 2.
type ListPartsInfo ¶
type ListPartsInfo struct {
// Name of the bucket.
Bucket string
// Name of the object.
Object string
// Upload ID identifying the multipart upload whose parts are being listed.
UploadID string
// Part number after which listing begins.
PartNumberMarker int
// When a list is truncated, this element specifies the last part in the list,
// as well as the value to use for the part-number-marker request parameter
// in a subsequent request.
NextPartNumberMarker int
// Maximum number of parts that were allowed in the response.
MaxParts int
// Indicates whether the returned list of parts is truncated.
IsTruncated bool
// List of all parts.
Parts []objectPartInfo
// Any metadata set during InitMultipartUpload, including encryption headers.
Metadata map[string]string
// ChecksumAlgorithm if set
ChecksumAlgorithm string
}
ListPartsInfo - represents list of all parts.
type MultipartInfo ¶
type ObjectInfo ¶
type ObjectInfo struct {
// Name of the bucket.
Bucket string
// Name of the object.
Name string
// Date and time when the object was last modified.
ModTime time.Time
// Total object size.
Size int64
// IsDir indicates if the object is prefix.
IsDir bool
// Hex encoded unique entity tag of the object.
ETag string
// Version ID of this object.
VersionID string
// IsLatest indicates if this is the latest current version
// latest can be true for delete marker or a version.
IsLatest bool
// DeleteMarker indicates if the versionId corresponds
// to a delete marker on an object.
DeleteMarker bool
// A standard MIME type describing the format of the object.
ContentType string
// Specifies what content encodings have been applied to the object and thus
// what decoding mechanisms must be applied to obtain the object referenced
// by the Content-Type header field.
ContentEncoding string
// Date and time at which the object is no longer able to be cached
Expires time.Time
// Date and time when the object was last accessed.
AccTime time.Time
// The mod time of the successor object version if any
SuccessorModTime time.Time
}
ObjectInfo - represents object metadata.
{
Bucket = {string} "test"
Name = {string} "default.exe"
ModTime = {time.Time} 2022-03-18 10:54:43.308685163 +0800
Size = {int64} 11604147
IsDir = {bool} false
ETag = {string} "a6b0b7ddb4630832ed47821af59aa125"
VersionID = {string} ""
IsLatest = {bool} false
DeleteMarker = {bool} false
ContentType = {string} "application/x-msdownload"
ContentEncoding = {string} ""
Expires = {time.Time} 0001-01-01 00:00:00 +0000
Parts = {[]ObjectPartInfo} nil
AccTime = {time.Time} 0001-01-01 00:00:00 +0000
SuccessorModTime = {time.Time} 0001-01-01 00:00:00 +0000
}
type StorageSys ¶
type StorageSys struct {
Db *uleveldb.ULevelDB
DagPool ipld.DAGService
CidBuilder cid.Builder
// contains filtered or unexported fields
}
StorageSys store sys
func NewStorageSys ¶
func NewStorageSys(ctx context.Context, dagService ipld.DAGService, db *uleveldb.ULevelDB) *StorageSys
NewStorageSys new a storage sys
func (*StorageSys) AbortMultipartUpload ¶
func (*StorageSys) CleanObjectsInBucket ¶
func (s *StorageSys) CleanObjectsInBucket(ctx context.Context, bucket string) error
func (*StorageSys) CompleteMultiPartUpload ¶
func (s *StorageSys) CompleteMultiPartUpload(ctx context.Context, bucket string, object string, uploadID string, parts []datatypes.CompletePart) (oi ObjectInfo, err error)
func (*StorageSys) DeleteObject ¶
func (s *StorageSys) DeleteObject(ctx context.Context, bucket, object string) error
DeleteObject delete object
func (*StorageSys) EmptyBucket ¶
func (*StorageSys) GetMultipartInfo ¶
func (s *StorageSys) GetMultipartInfo(ctx context.Context, bucket string, object string, uploadID string) (MultipartInfo, error)
func (*StorageSys) GetObject ¶
func (s *StorageSys) GetObject(ctx context.Context, bucket, object string) (ObjectInfo, io.ReadCloser, error)
GetObject Get object
func (*StorageSys) GetObjectInfo ¶
func (s *StorageSys) GetObjectInfo(ctx context.Context, bucket, object string) (meta ObjectInfo, err error)
func (*StorageSys) ListMultipartUploads ¶
func (s *StorageSys) ListMultipartUploads(ctx context.Context, bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartsInfo, err error)
func (*StorageSys) ListObjectParts ¶
func (s *StorageSys) ListObjectParts(ctx context.Context, bucket, object, uploadID string, partNumberMarker, maxParts int) (result ListPartsInfo, err error)
func (*StorageSys) ListObjects ¶
func (s *StorageSys) ListObjects(ctx context.Context, bucket string, prefix string, marker string, delimiter string, maxKeys int) (loi ListObjectsInfo, err error)
ListObjects list user object TODO use more params
func (*StorageSys) ListObjectsV2 ¶
func (s *StorageSys) ListObjectsV2(ctx context.Context, bucket string, prefix string, continuationToken string, delimiter string, maxKeys int, owner bool, startAfter string) (ListObjectsV2Info, error)
ListObjectsV2 list objects
func (*StorageSys) NewMultipartUpload ¶
func (s *StorageSys) NewMultipartUpload(ctx context.Context, bucket string, object string, meta map[string]string) (MultipartInfo, error)
func (*StorageSys) NewNSLock ¶
func (s *StorageSys) NewNSLock(bucket string, objects ...string) lock.RWLocker
NewNSLock - initialize a new namespace RWLocker instance.
func (*StorageSys) PutObjectPart ¶
func (*StorageSys) SetHasBucket ¶
func (s *StorageSys) SetHasBucket(hasBucket func(ctx context.Context, bucket string) bool)
func (*StorageSys) SetNewBucketNSLock ¶
func (s *StorageSys) SetNewBucketNSLock(newBucketNSLock func(bucket string) lock.RWLocker)
func (*StorageSys) StoreObject ¶
func (s *StorageSys) StoreObject(ctx context.Context, bucket, object string, reader io.ReadCloser, size int64, meta map[string]string) (ObjectInfo, error)
StoreObject store object
type Tags ¶
type Tags tagging
Tags is list of tags of XML request/response as per https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketTagging.html#API_GetBucketTagging_RequestBody