Documentation
¶
Index ¶
- Variables
- type Store
- func (s *Store) AbortMultipartUpload(accessKeyID, bucket, name string, uploadID s3.UploadID) (size int64, _ error)
- func (s *Store) AddMultipartPart(accessKeyID, bucket, name string, uploadID s3.UploadID, filename string, ...) (prev string, size int64, _ error)
- func (s *Store) AllFilenames() (filenames []string, err error)
- func (s *Store) AppKey() (types.PrivateKey, string, error)
- func (s *Store) Close() error
- func (s *Store) CompleteMultipartUpload(accessKeyID, bucket, name string, uploadID s3.UploadID, contentMD5 [16]byte, ...) (orphanFile string, orphanSize int64, _ error)
- func (s *Store) CopyObject(accessKeyID, srcBucket, srcName, dstBucket, dstName string, ...) (result *objects.Object, orphanFile string, orphanSize int64, err error)
- func (s *Store) CreateAccessKey(userName, accessKeyID, secretKey string) error
- func (s *Store) CreateBucket(accessKeyID, bucket string) error
- func (s *Store) CreateMultipartUpload(accessKeyID, bucket, name string, uploadID s3.UploadID, meta map[string]string) error
- func (s *Store) CreateUser(name string) error
- func (s *Store) DeleteAccessKey(accessKeyID string) error
- func (s *Store) DeleteBucket(accessKeyID, bucket string) error
- func (s *Store) DeleteObject(accessKeyID, bucket string, objectID s3.ObjectID) (orphanFile string, orphanSize int64, _ error)
- func (s *Store) DeleteUser(name string) error
- func (s *Store) DiskUsage() (usage uint64, err error)
- func (s *Store) GetObject(accessKeyID, bucket, name string, partNumber *int32) (*objects.Object, error)
- func (s *Store) HasMultipartUpload(accessKeyID, bucket, name string, uploadID s3.UploadID) (hasParts bool, err error)
- func (s *Store) HeadBucket(accessKeyID, bucket string) error
- func (s *Store) ListAccessKeys(userName *string) ([]sia.AccessKeyInfo, error)
- func (s *Store) ListBuckets(accessKeyID string) ([]s3.BucketInfo, error)
- func (s *Store) ListMultipartUploads(accessKeyID, bucket string, prefix s3.Prefix, page s3.ListMultipartUploadsPage) (_ *s3.ListMultipartUploadsResult, err error)
- func (s *Store) ListObjects(accessKeyID, bucket string, prefix s3.Prefix, page s3.ListObjectsPage) (result *s3.ObjectsListResult, err error)
- func (s *Store) ListParts(accessKeyID, bucket, name string, uploadID s3.UploadID, partNumberMarker int, ...) (*s3.ListPartsResult, error)
- func (s *Store) ListUsers() ([]string, error)
- func (s *Store) LoadSecret(accessKeyID string) (string, error)
- func (s *Store) MarkObjectUploaded(bucket, name string, contentMD5 [16]byte, sealed sdk.SealedObject) error
- func (s *Store) MultipartParts(accessKeyID, bucket, name string, uploadID s3.UploadID) ([]objects.Part, error)
- func (s *Store) ObjectPartsByName(bucket, name string) ([]objects.Part, error)
- func (s *Store) ObjectsCursor() (cursor slabs.Cursor, err error)
- func (s *Store) ObjectsForUpload() ([]objects.ObjectForUpload, error)
- func (s *Store) OrphanedObjects(limit int) (ids []types.Hash256, err error)
- func (s *Store) PutObject(accessKeyID, bucket, name string, contentMD5 [16]byte, meta map[string]string, ...) (orphanFile string, orphanSize int64, _ error)
- func (s *Store) RemoveOrphanedObject(objectID types.Hash256) error
- func (s *Store) SetAppKey(key types.PrivateKey, indexerURL string) error
- func (s *Store) SetObjectsCursor(cursor slabs.Cursor) error
- func (s *Store) UpdateSiaObjects(siaObjects []objects.SiaObject) (updated int64, err error)
- func (s *Store) UploadStats() (stats s3.UploadStats, err error)
- func (s *Store) UserNameForAccessKey(accessKeyID string) (name string, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoAppKey = errors.New("no app key set")
ErrNoAppKey is returned when no application key is set.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
A Store is a persistent store that uses a SQL database as its backend.
func OpenDatabase ¶
OpenDatabase creates a new SQLite store and initializes the database. If the database does not exist, it is created.
func (*Store) AbortMultipartUpload ¶
func (s *Store) AbortMultipartUpload(accessKeyID, bucket, name string, uploadID s3.UploadID) (size int64, _ error)
AbortMultipartUpload removes a multipart upload from the store and returns the total size of all parts that were removed.
func (*Store) AddMultipartPart ¶
func (s *Store) AddMultipartPart(accessKeyID, bucket, name string, uploadID s3.UploadID, filename string, partNumber int, contentMD5 [16]byte, contentLength int64) (prev string, size int64, _ error)
AddMultipartPart adds metadata for a multipart part to the store. It returns the previous part's filename and content length if a part with the same number already existed.
func (*Store) AllFilenames ¶
AllFilenames returns all filenames from the objects table and in-progress multipart uploads.
func (*Store) AppKey ¶
func (s *Store) AppKey() (types.PrivateKey, string, error)
AppKey retrieves the application private key and the indexer URL it was registered with.
func (*Store) CompleteMultipartUpload ¶
func (s *Store) CompleteMultipartUpload(accessKeyID, bucket, name string, uploadID s3.UploadID, contentMD5 [16]byte, contentLength int64) (orphanFile string, orphanSize int64, _ error)
CompleteMultipartUpload finalizes a multipart upload by creating the object and transferring parts from the upload to the object. If the overwritten object's ID has no remaining references, it is inserted into the orphaned_objects table. If the overwrite leaves a previously pending file unreferenced, its filename is returned so the caller can remove it from disk.
func (*Store) CopyObject ¶
func (s *Store) CopyObject(accessKeyID, srcBucket, srcName, dstBucket, dstName string, meta map[string]string, replace bool) (result *objects.Object, orphanFile string, orphanSize int64, err error)
CopyObject atomically reads the source object and writes it to the destination within a single transaction, applying metadata according to the replace flag. Returns the copied object metadata, and if the copy overwrote a previously pending object whose file is no longer referenced, its filename so the caller can remove it from disk.
func (*Store) CreateAccessKey ¶
CreateAccessKey creates a new access key for the given user.
func (*Store) CreateBucket ¶
CreateBucket creates a new bucket owned by the user associated with the given access key.
func (*Store) CreateMultipartUpload ¶
func (s *Store) CreateMultipartUpload(accessKeyID, bucket, name string, uploadID s3.UploadID, meta map[string]string) error
CreateMultipartUpload persists metadata for a new multipart upload.
func (*Store) CreateUser ¶
CreateUser creates a new user with the given name.
func (*Store) DeleteAccessKey ¶
DeleteAccessKey deletes the access key with the given ID.
func (*Store) DeleteBucket ¶
DeleteBucket deletes a bucket if it is empty and owned by the requesting user.
func (*Store) DeleteObject ¶
func (s *Store) DeleteObject(accessKeyID, bucket string, objectID s3.ObjectID) (orphanFile string, orphanSize int64, _ error)
DeleteObject deletes the object with the given bucket and name if it exists and all provided preconditions match. If the deleted object's ID has no remaining references, it is inserted into the orphaned_objects table. If the object hasn't been uploaded yet, its filename is returned for cleanup.
func (*Store) DeleteUser ¶
DeleteUser deletes the user with the given name. Access keys belonging to the user are deleted via cascade. Returns an error if the user owns any buckets.
func (*Store) DiskUsage ¶
DiskUsage returns the total bytes pending upload to Sia, across pending objects and in-progress multipart parts. Pending objects sharing a filename (e.g. via CopyObject) are counted once.
func (*Store) GetObject ¶
func (s *Store) GetObject(accessKeyID, bucket, name string, partNumber *int32) (*objects.Object, error)
GetObject retrieves the object with the given bucket and name.
func (*Store) HasMultipartUpload ¶
func (s *Store) HasMultipartUpload(accessKeyID, bucket, name string, uploadID s3.UploadID) (hasParts bool, err error)
HasMultipartUpload checks if a multipart upload exists and reports whether any parts have been uploaded for it.
func (*Store) HeadBucket ¶
HeadBucket verifies that the bucket exists and is owned by the user associated with the given access key.
func (*Store) ListAccessKeys ¶
func (s *Store) ListAccessKeys(userName *string) ([]sia.AccessKeyInfo, error)
ListAccessKeys returns all access keys for the given user. If userName is nil, all access keys are returned.
func (*Store) ListBuckets ¶
func (s *Store) ListBuckets(accessKeyID string) ([]s3.BucketInfo, error)
ListBuckets lists all buckets owned by the user associated with the given access key.
func (*Store) ListMultipartUploads ¶
func (s *Store) ListMultipartUploads(accessKeyID, bucket string, prefix s3.Prefix, page s3.ListMultipartUploadsPage) (_ *s3.ListMultipartUploadsResult, err error)
ListMultipartUploads lists all multipart uploads for the given bucket and filters.
func (*Store) ListObjects ¶
func (s *Store) ListObjects(accessKeyID, bucket string, prefix s3.Prefix, page s3.ListObjectsPage) (result *s3.ObjectsListResult, err error)
ListObjects lists objects in the specified bucket, filtered by prefix and pagination settings.
func (*Store) ListParts ¶
func (s *Store) ListParts(accessKeyID, bucket, name string, uploadID s3.UploadID, partNumberMarker int, maxParts int64) (*s3.ListPartsResult, error)
ListParts lists uploaded parts for a multipart upload.
func (*Store) LoadSecret ¶
LoadSecret returns the secret key for the given access key ID.
func (*Store) MarkObjectUploaded ¶
func (s *Store) MarkObjectUploaded(bucket, name string, contentMD5 [16]byte, sealed sdk.SealedObject) error
MarkObjectUploaded transitions a pending upload to a Sia-backed object by setting the object_id, sia_object and cached_at fields while clearing filename. The update targets any pending object matching the bucket and name, returning ErrObjectNotFound if no pending object exists or ErrObjectModified if the stored content MD5 does not match the provided contentMD5.
func (*Store) MultipartParts ¶
func (s *Store) MultipartParts(accessKeyID, bucket, name string, uploadID s3.UploadID) ([]objects.Part, error)
MultipartParts returns the parts belonging to the specified multipart upload.
func (*Store) ObjectPartsByName ¶
ObjectPartsByName returns the parts for a completed multipart object. It is intended for internal callers (the upload loop and downstream of an ownership-scoped GetObject) and does not perform an access check.
func (*Store) ObjectsCursor ¶
ObjectsCursor returns the cursor for resuming object event syncing.
func (*Store) ObjectsForUpload ¶
func (s *Store) ObjectsForUpload() ([]objects.ObjectForUpload, error)
ObjectsForUpload returns all objects stored on disk, ordered by size descending for greedy best-fit slab filling.
func (*Store) OrphanedObjects ¶
OrphanedObjects returns up to limit object IDs from the orphaned_objects table.
func (*Store) PutObject ¶
func (s *Store) PutObject(accessKeyID, bucket, name string, contentMD5 [16]byte, meta map[string]string, length int64, fileName *string) (orphanFile string, orphanSize int64, _ error)
PutObject stores the given object in the given bucket with the given name or overwrites it if it already exists. If the overwritten object's ID has no remaining references, it is inserted into the orphaned_objects table. If the overwrite leaves a previously pending file unreferenced, its filename is returned so the caller can remove it from disk and release its disk usage.
func (*Store) RemoveOrphanedObject ¶
RemoveOrphanedObject removes an object ID from the orphaned_objects table.
func (*Store) SetAppKey ¶
func (s *Store) SetAppKey(key types.PrivateKey, indexerURL string) error
SetAppKey sets the application private key and the indexer URL it was registered with.
func (*Store) SetObjectsCursor ¶
SetObjectsCursor updates the cursor for resuming object event syncing.
func (*Store) UpdateSiaObjects ¶
UpdateSiaObjects batch updates object metadata in the database within a single transaction. It returns the number of rows that were updated.
func (*Store) UploadStats ¶
func (s *Store) UploadStats() (stats s3.UploadStats, err error)
UploadStats returns statistics about the background upload pipeline.