Documentation
¶
Index ¶
- func IsNotFound(err error) bool
- func WithEndpoint(ctx context.Context, endpoint string) context.Context
- type AzureClient
- func (c *AzureClient) CopyObject(ctx context.Context, bucket, srcKey, destKey string) error
- func (c *AzureClient) DeleteObjects(ctx context.Context, bucket string, keys []string) error
- func (c *AzureClient) DownloadDirectory(ctx context.Context, bucket, prefix, destDir string) error
- func (c *AzureClient) DownloadObjectToFile(ctx context.Context, bucket, key, localPath string) error
- func (c *AzureClient) GetObject(ctx context.Context, bucket, key string) ([]byte, error)
- func (c *AzureClient) HeadObjectExists(ctx context.Context, bucket, key string) (bool, error)
- func (c *AzureClient) ListKeys(ctx context.Context, bucket, prefix string) ([]string, error)
- func (c *AzureClient) ListObjectsWithMeta(ctx context.Context, bucket, prefix string) ([]ObjectMeta, error)
- func (c *AzureClient) PutObject(ctx context.Context, bucket, key string, data []byte) error
- func (c *AzureClient) TouchObject(ctx context.Context, bucket, key string) error
- func (c *AzureClient) UploadFile(ctx context.Context, localPath, bucket, key string, sc StorageClass) error
- type Backend
- type Client
- func (c *Client) ClientForBucket(ctx context.Context, bucket string) (*s3.Client, error)
- func (c *Client) CopyObject(ctx context.Context, bucket, srcKey, destKey string) error
- func (c *Client) DeleteObjects(ctx context.Context, bucket string, keys []string) error
- func (c *Client) DownloadDirectory(ctx context.Context, bucket, prefix, destDir string) error
- func (c *Client) DownloadObjectToFile(ctx context.Context, bucket, key, localPath string) error
- func (c *Client) GetObject(ctx context.Context, bucket, key string) ([]byte, error)
- func (c *Client) HeadObjectExists(ctx context.Context, bucket, key string) (bool, error)
- func (c *Client) ListKeys(ctx context.Context, bucket, prefix string) ([]string, error)
- func (c *Client) ListObjectsWithMeta(ctx context.Context, bucket, prefix string) ([]ObjectMeta, error)
- func (c *Client) PresignGetObject(ctx context.Context, bucket, key string, ttl time.Duration) (string, error)
- func (c *Client) PutObject(ctx context.Context, bucket, key string, data []byte) error
- func (c *Client) TouchObject(ctx context.Context, bucket, key string) error
- func (c *Client) UploadDirectory(ctx context.Context, localDir, bucket, prefix string) error
- func (c *Client) UploadFile(ctx context.Context, localPath, bucket, key string, sc StorageClass) error
- type GCSClient
- func (c *GCSClient) CopyObject(ctx context.Context, bucket, srcKey, destKey string) error
- func (c *GCSClient) DeleteObjects(ctx context.Context, bucket string, keys []string) error
- func (c *GCSClient) DownloadDirectory(ctx context.Context, bucket, prefix, destDir string) error
- func (c *GCSClient) DownloadObjectToFile(ctx context.Context, bucket, key, localPath string) error
- func (c *GCSClient) GetObject(ctx context.Context, bucket, key string) ([]byte, error)
- func (c *GCSClient) HeadObjectExists(ctx context.Context, bucket, key string) (bool, error)
- func (c *GCSClient) ListKeys(ctx context.Context, bucket, prefix string) ([]string, error)
- func (c *GCSClient) ListObjectsWithMeta(ctx context.Context, bucket, prefix string) ([]ObjectMeta, error)
- func (c *GCSClient) PutObject(ctx context.Context, bucket, key string, data []byte) error
- func (c *GCSClient) TouchObject(ctx context.Context, bucket, key string) error
- func (c *GCSClient) UploadFile(ctx context.Context, localPath, bucket, key string, sc StorageClass) error
- type LocalClient
- func (c *LocalClient) CopyObject(_ context.Context, bucket, srcKey, destKey string) error
- func (c *LocalClient) DeleteObjects(ctx context.Context, bucket string, keys []string) error
- func (c *LocalClient) DownloadDirectory(_ context.Context, bucket, prefix, destDir string) error
- func (c *LocalClient) DownloadObjectToFile(_ context.Context, bucket, key, localPath string) error
- func (c *LocalClient) GetObject(ctx context.Context, bucket, key string) ([]byte, error)
- func (c *LocalClient) HeadObjectExists(ctx context.Context, bucket, key string) (bool, error)
- func (c *LocalClient) ListKeys(ctx context.Context, bucket, prefix string) ([]string, error)
- func (c *LocalClient) ListObjectsWithMeta(ctx context.Context, bucket, prefix string) ([]ObjectMeta, error)
- func (c *LocalClient) PutObject(ctx context.Context, bucket, key string, data []byte) error
- func (c *LocalClient) TouchObject(_ context.Context, bucket, key string) error
- func (c *LocalClient) UploadFile(_ context.Context, localPath, bucket, key string, _ StorageClass) error
- type ObjectMeta
- type StorageClass
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound returns true if err represents a "not found / 404" error from any backend.
Types ¶
type AzureClient ¶
type AzureClient struct {
// contains filtered or unexported fields
}
AzureClient implements Backend using Azure Blob Storage.
func (*AzureClient) CopyObject ¶
func (c *AzureClient) CopyObject(ctx context.Context, bucket, srcKey, destKey string) error
func (*AzureClient) DeleteObjects ¶
func (*AzureClient) DownloadDirectory ¶
func (c *AzureClient) DownloadDirectory(ctx context.Context, bucket, prefix, destDir string) error
func (*AzureClient) DownloadObjectToFile ¶
func (c *AzureClient) DownloadObjectToFile(ctx context.Context, bucket, key, localPath string) error
func (*AzureClient) HeadObjectExists ¶
func (*AzureClient) ListObjectsWithMeta ¶
func (c *AzureClient) ListObjectsWithMeta(ctx context.Context, bucket, prefix string) ([]ObjectMeta, error)
func (*AzureClient) TouchObject ¶
func (c *AzureClient) TouchObject(ctx context.Context, bucket, key string) error
TouchObject refreshes the blob's Last-Modified time via a metadata set.
func (*AzureClient) UploadFile ¶
func (c *AzureClient) UploadFile(ctx context.Context, localPath, bucket, key string, sc StorageClass) error
type Backend ¶
type Backend interface {
GetObject(ctx context.Context, bucket, key string) ([]byte, error)
PutObject(ctx context.Context, bucket, key string, data []byte) error
HeadObjectExists(ctx context.Context, bucket, key string) (bool, error)
ListKeys(ctx context.Context, bucket, prefix string) ([]string, error)
ListObjectsWithMeta(ctx context.Context, bucket, prefix string) ([]ObjectMeta, error)
DeleteObjects(ctx context.Context, bucket string, keys []string) error
UploadFile(ctx context.Context, localPath, bucket, key string, sc StorageClass) error
DownloadObjectToFile(ctx context.Context, bucket, key, localPath string) error
DownloadDirectory(ctx context.Context, bucket, prefix, destDir string) error
CopyObject(ctx context.Context, bucket, srcKey, destKey string) error
// TouchObject refreshes an object's last-modified time (used by push to keep
// dedup-skipped blobs inside the GC grace window).
TouchObject(ctx context.Context, bucket, key string) error
}
Backend is the storage interface for all s3lo operations. *Client (S3/S3-compatible), *LocalClient, *GCSClient, *AzureClient all implement it.
func NewBackendFromRef ¶
NewBackendFromRef creates the appropriate backend based on the URL scheme.
- local:// → LocalClient (filesystem)
- gs:// → GCSClient (Google Cloud Storage)
- az:// → AzureClient (Azure Blob Storage)
- s3:// (default) → S3 Client; uses custom endpoint from context for S3-compatible backends
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewS3Client ¶
NewS3Client creates an S3 client using the default AWS credentials chain.
func (*Client) ClientForBucket ¶
ClientForBucket returns an S3 client configured for the bucket's region (public). Clients are cached per-region to avoid re-loading AWS config on every call. For S3-compatible backends (endpoint set), region detection is skipped and the pre-configured endpoint client is returned directly.
func (*Client) CopyObject ¶
CopyObject copies an S3 object within the same bucket.
func (*Client) DeleteObjects ¶
DeleteObjects deletes multiple S3 objects in batches of up to 1000.
func (*Client) DownloadDirectory ¶
DownloadDirectory downloads all objects under prefix into destDir.
func (*Client) DownloadObjectToFile ¶
DownloadObjectToFile downloads a single S3 object to a local file path.
func (*Client) HeadObjectExists ¶
HeadObjectExists returns true if an S3 object exists, false if it doesn't (404). Returns an error for non-404 failures (permissions, throttling, network).
func (*Client) ListObjectsWithMeta ¶
func (c *Client) ListObjectsWithMeta(ctx context.Context, bucket, prefix string) ([]ObjectMeta, error)
ListObjectsWithMeta returns all S3 objects under prefix with size and last-modified metadata.
func (*Client) PresignGetObject ¶
func (c *Client) PresignGetObject(ctx context.Context, bucket, key string, ttl time.Duration) (string, error)
PresignGetObject returns a presigned GET URL for the given object valid for ttl. This satisfies serve.Presigner without importing pkg/serve.
func (*Client) TouchObject ¶
TouchObject refreshes an object's LastModified timestamp by copying it onto itself with metadata replacement. Push calls this when it dedups against an already-present blob so the blob re-enters the GC grace window; otherwise an old blob newly referenced by an in-flight push could be reaped by a concurrent GC before the push writes its manifest.
func (*Client) UploadDirectory ¶
UploadDirectory uploads all files in localDir to bucket at prefix/ with Standard storage class.
func (*Client) UploadFile ¶
func (c *Client) UploadFile(ctx context.Context, localPath, bucket, key string, sc StorageClass) error
UploadFile uploads a single local file to a specific S3 key.
type GCSClient ¶
type GCSClient struct {
// contains filtered or unexported fields
}
GCSClient implements Backend using Google Cloud Storage.
func (*GCSClient) CopyObject ¶
func (*GCSClient) DeleteObjects ¶
func (*GCSClient) DownloadDirectory ¶
func (*GCSClient) DownloadObjectToFile ¶
func (*GCSClient) HeadObjectExists ¶
func (*GCSClient) ListObjectsWithMeta ¶
func (*GCSClient) TouchObject ¶
TouchObject refreshes the object's update time by rewriting it onto itself.
func (*GCSClient) UploadFile ¶
type LocalClient ¶
type LocalClient struct{}
LocalClient implements Backend using the local filesystem. The "bucket" parameter in every method is the storage root directory.
func NewLocalClient ¶
func NewLocalClient() *LocalClient
NewLocalClient returns a LocalClient. No configuration needed — the bucket path serves as the storage root on every method call.
func (*LocalClient) CopyObject ¶
func (c *LocalClient) CopyObject(_ context.Context, bucket, srcKey, destKey string) error
func (*LocalClient) DeleteObjects ¶
func (*LocalClient) DownloadDirectory ¶
func (c *LocalClient) DownloadDirectory(_ context.Context, bucket, prefix, destDir string) error
func (*LocalClient) DownloadObjectToFile ¶
func (c *LocalClient) DownloadObjectToFile(_ context.Context, bucket, key, localPath string) error
func (*LocalClient) HeadObjectExists ¶
func (*LocalClient) ListObjectsWithMeta ¶
func (c *LocalClient) ListObjectsWithMeta(ctx context.Context, bucket, prefix string) ([]ObjectMeta, error)
func (*LocalClient) TouchObject ¶
func (c *LocalClient) TouchObject(_ context.Context, bucket, key string) error
TouchObject updates the blob file's modification time to now.
func (*LocalClient) UploadFile ¶
func (c *LocalClient) UploadFile(_ context.Context, localPath, bucket, key string, _ StorageClass) error
type ObjectMeta ¶
ObjectMeta holds key and metadata for an S3 object.
type StorageClass ¶
type StorageClass string
StorageClass controls blob upload tiering. Backends map this to their own concepts.
const ( StorageClassStandard StorageClass = "STANDARD" StorageClassIntelligentTiering StorageClass = "INTELLIGENT_TIERING" )