Documentation
¶
Index ¶
- Variables
- func ValidateKey(key string) bool
- type AfterCopyObjectHook
- type AfterDeleteObjectHook
- type AfterPutObjectHook
- type BlobChangeCallback
- type BlobEventType
- type BlobIndex
- func (bi *BlobIndex) Close() error
- func (bi *BlobIndex) Count() int
- func (bi *BlobIndex) FilterAfterTime(after time.Time) ([]*BlobInfo, error)
- func (bi *BlobIndex) FilterBeforeTime(before time.Time) ([]*BlobInfo, error)
- func (bi *BlobIndex) FilterByKeyGlob(pattern string) ([]*BlobInfo, error)
- func (bi *BlobIndex) FilterByPrefix(prefix string) ([]*BlobInfo, error)
- func (bi *BlobIndex) FilterBySuffix(suffix string) ([]*BlobInfo, error)
- func (bi *BlobIndex) FilterByTime(filter TimeFilter) ([]*BlobInfo, error)
- func (bi *BlobIndex) Get(key string) (*BlobInfo, bool)
- func (bi *BlobIndex) Iter() iter.Seq[*BlobInfo]
- func (bi *BlobIndex) List() ([]*BlobInfo, error)
- func (bi *BlobIndex) Remove(key string) error
- func (bi *BlobIndex) Set(blob *BlobInfo) error
- func (bi *BlobIndex) SetMany(blobs []*BlobInfo) error
- type BlobInfo
- type BlobService
- type CompleteMultipartUploadParams
- type CompletedPart
- type CopyObjectParams
- type CopyObjectResponse
- type GetObjectResponse
- type IBlobBackend
- type IBlobIndex
- type PutObjectMultipartParams
- type PutObjectMultipartResponse
- type PutObjectParams
- type PutObjectPresignedResponse
- type PutObjectResponse
- type S3Backend
- func (s *S3Backend) CompleteMultipartUpload(ctx context.Context, params *CompleteMultipartUploadParams) (*PutObjectResponse, error)
- func (s *S3Backend) CopyObject(ctx context.Context, params *CopyObjectParams) (*CopyObjectResponse, error)
- func (s *S3Backend) Delegate() any
- func (s *S3Backend) DeleteObject(ctx context.Context, key string) (bool, error)
- func (s *S3Backend) GetObject(ctx context.Context, key string) (*GetObjectResponse, error)
- func (s *S3Backend) GetObjectPresigned(ctx context.Context, key string) (string, error)
- func (s *S3Backend) ListObjects(ctx context.Context) ([]*BlobInfo, error)
- func (s *S3Backend) PutObject(ctx context.Context, params *PutObjectParams) (*PutObjectResponse, error)
- func (s *S3Backend) PutObjectMultipart(ctx context.Context, params *PutObjectMultipartParams) (*PutObjectMultipartResponse, error)
- func (s *S3Backend) PutObjectPresigned(ctx context.Context, key string) (string, error)
- type S3Config
- type Service
- type TimeFilter
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidKey = errors.New("invalid key")
)
Functions ¶
func ValidateKey ¶
Validate a key for S3 and local file system compatibility
Types ¶
type AfterCopyObjectHook ¶ added in v0.6.1
type AfterCopyObjectHook func(req *CopyObjectParams, resp *CopyObjectResponse)
type AfterDeleteObjectHook ¶ added in v0.6.1
type AfterPutObjectHook ¶ added in v0.6.1
type AfterPutObjectHook func(req *PutObjectParams, resp *PutObjectResponse)
Hook function signatures
type BlobChangeCallback ¶ added in v0.6.1
type BlobChangeCallback func(key string, eventType BlobEventType)
BlobChangeCallback is the function signature for blob change callbacks
type BlobEventType ¶ added in v0.6.1
type BlobEventType uint8
BlobEventType represents the type of blob operation that occurred
const ( BlobEventPut BlobEventType = 1 << iota BlobEventDelete BlobEventCopy )
BlobEvent constants define the different types of blob operations that can trigger events.
type BlobIndex ¶
type BlobIndex struct {
// contains filtered or unexported fields
}
BlobIndex provides access to the blob metadata stored in SQLite
func (*BlobIndex) FilterAfterTime ¶
FilterAfterTime returns blobs modified after the given time (maintains backward compatibility)
func (*BlobIndex) FilterBeforeTime ¶
FilterBeforeTime returns blobs modified before the given time
func (*BlobIndex) FilterByKeyGlob ¶
FilterByKeyGlob returns blobs with keys matching the given SQL LIKE pattern
func (*BlobIndex) FilterByPrefix ¶
func (*BlobIndex) FilterBySuffix ¶
func (*BlobIndex) FilterByTime ¶
func (bi *BlobIndex) FilterByTime(filter TimeFilter) ([]*BlobInfo, error)
FilterByTime returns blobs modified after the given time
type BlobService ¶
type BlobService struct {
// contains filtered or unexported fields
}
func NewBlobService ¶
func NewBlobService(cfg *S3Config, db *sqlx.DB) (*BlobService, error)
func (*BlobService) Backend ¶
func (b *BlobService) Backend() IBlobBackend
Backend returns the underlying blob backend instance
func (*BlobService) OnBlobChange ¶ added in v0.6.1
func (b *BlobService) OnBlobChange(callback BlobChangeCallback)
SetOnBlobChangeCallback sets the callback function for blob changes
type CompleteMultipartUploadParams ¶
type CompleteMultipartUploadParams struct { Key string `json:"key"` UploadID string `json:"uploadId"` Parts []*CompletedPart `json:"parts"` }
type CompletedPart ¶
type CopyObjectParams ¶
type CopyObjectResponse ¶
type GetObjectResponse ¶
type IBlobBackend ¶ added in v0.6.1
type IBlobBackend interface { // GetObject retrieves an object from storage by its key GetObject(ctx context.Context, key string) (*GetObjectResponse, error) // GetObjectPresigned generates a presigned URL for downloading an object GetObjectPresigned(ctx context.Context, key string) (string, error) // PutObject uploads a single object to storage PutObject(ctx context.Context, params *PutObjectParams) (*PutObjectResponse, error) // PutObjectPresigned generates a presigned URL for uploading an object PutObjectPresigned(ctx context.Context, key string) (string, error) // PutObjectMultipart initiates a multipart upload and returns upload URLs PutObjectMultipart(ctx context.Context, params *PutObjectMultipartParams) (*PutObjectMultipartResponse, error) // CompleteMultipartUpload finalizes a multipart upload CompleteMultipartUpload(ctx context.Context, params *CompleteMultipartUploadParams) (*PutObjectResponse, error) // CopyObject copies an object from one location to another CopyObject(ctx context.Context, params *CopyObjectParams) (*CopyObjectResponse, error) // DeleteObject removes an object from storage, returns true if successful DeleteObject(ctx context.Context, key string) (bool, error) // ListObjects returns a list of all objects in storage ListObjects(ctx context.Context) ([]*BlobInfo, error) // Delegate returns the underlying backend implementation Delegate() any // contains filtered or unexported methods }
IBlobBackend defines the interface for blob storage backend operations. It provides methods for basic CRUD operations on blob objects including single-part uploads, multipart uploads, presigned URLs, and object management. The interface is designed to be implemented by different storage backends such as S3, local filesystem, or other cloud storage providers.
type IBlobIndex ¶
type IBlobIndex interface { // Get retrieves a blob by its key, returning the blob info and whether it exists Get(key string) (*BlobInfo, bool) // Set stores a blob in the index, creating or updating the entry Set(blob *BlobInfo) error // SetMany stores multiple blobs in the index in a single operation SetMany(blobs []*BlobInfo) error // Remove deletes a blob from the index by its key Remove(key string) error // List returns all blobs in the index as a slice List() ([]*BlobInfo, error) // Iter returns an iterator for traversing all blobs in the index Iter() iter.Seq[*BlobInfo] // Count returns the total number of blobs in the index Count() int // FilterByKeyGlob filters blobs by key using glob pattern matching FilterByKeyGlob(pattern string) ([]*BlobInfo, error) // FilterByPrefix filters blobs by key prefix FilterByPrefix(prefix string) ([]*BlobInfo, error) // FilterBySuffix filters blobs by key suffix FilterBySuffix(suffix string) ([]*BlobInfo, error) // FilterByTime filters blobs based on a time range filter FilterByTime(filter TimeFilter) ([]*BlobInfo, error) // FilterAfterTime filters blobs modified after the specified time FilterAfterTime(after time.Time) ([]*BlobInfo, error) // FilterBeforeTime filters blobs modified before the specified time FilterBeforeTime(before time.Time) ([]*BlobInfo, error) }
IBlobIndex defines the interface for blob index operations. It provides methods for managing and querying blob metadata in an index, including CRUD operations, filtering, and iteration capabilities. The interface is designed to be implemented by different index backends such as in-memory maps, databases, or other storage systems.
type PutObjectParams ¶
type PutObjectResponse ¶
type S3Backend ¶
type S3Backend struct {
// contains filtered or unexported fields
}
func NewS3BackendWithConfig ¶
func (*S3Backend) CompleteMultipartUpload ¶
func (s *S3Backend) CompleteMultipartUpload(ctx context.Context, params *CompleteMultipartUploadParams) (*PutObjectResponse, error)
func (*S3Backend) CopyObject ¶
func (s *S3Backend) CopyObject(ctx context.Context, params *CopyObjectParams) (*CopyObjectResponse, error)
func (*S3Backend) DeleteObject ¶
func (*S3Backend) GetObjectPresigned ¶
func (*S3Backend) ListObjects ¶
func (*S3Backend) PutObject ¶
func (s *S3Backend) PutObject(ctx context.Context, params *PutObjectParams) (*PutObjectResponse, error)
Add an object to a bucket
func (*S3Backend) PutObjectMultipart ¶
func (s *S3Backend) PutObjectMultipart(ctx context.Context, params *PutObjectMultipartParams) (*PutObjectMultipartResponse, error)
type S3Config ¶
type Service ¶ added in v0.6.1
type Service interface { // Backend returns the underlying blob storage backend Backend() IBlobBackend // Index returns the blob index for metadata management Index() IBlobIndex // OnBlobChange registers a callback for blob change events OnBlobChange(callback BlobChangeCallback) }
Service defines the minimal interface for blob operations. It provides access to the underlying backend storage, index management, and allows registering callbacks for blob change events.