Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
io.Closer
// Name returns the name of the backend
Name() string
// URL returns the backend destination URL. The scheme, host (bucket/name),
// and path (prefix/directory) identify the storage location. Query
// parameters carry useful non-credential details: region, endpoint, anonymous.
URL() *url.URL
// Create object in the backend
CreateObject(context.Context, schema.CreateObjectRequest) (*schema.Object, error)
// Get object metadata from the backend
GetObject(context.Context, schema.GetObjectRequest) (*schema.Object, error)
// Read object content from the backend. Caller must close the returned reader.
ReadObject(context.Context, schema.ReadObjectRequest) (io.ReadCloser, *schema.Object, error)
// List objects in the backend
ListObjects(context.Context, schema.ListObjectsRequest) (*schema.ListObjectsResponse, error)
// Delete objects in the backend (single object or prefix)
DeleteObjects(context.Context, schema.DeleteObjectsRequest) (*schema.DeleteObjectsResponse, error)
// Delete a single object from the backend
DeleteObject(context.Context, schema.DeleteObjectRequest) (*schema.Object, error)
}
Backend is the interface for a storage backend.
func NewBlobBackend ¶
NewBlobBackend creates a new blob backend using Go CDK. Supported URL schemes: s3://, file://, mem:// Examples:
- "s3://my-bucket?region=us-east-1"
- "file:///path/to/directory"
- "mem://"
For S3 URLs, you can optionally provide an aws.Config via WithAWSConfig() for full control over AWS SDK configuration.
func NewFileBackend ¶
NewFileBackend creates a file-based backend with a logical name. name must be a valid identifier (see types.IsIdentifier): starts with a letter, contains only letters, digits, underscores, or hyphens, max 64 chars. dir must be an absolute path; if it doesn't start with "/" an error is returned.
type Opt ¶
type Opt func(*opt) error
func WithAWSConfig ¶
WithAWSConfig provides an AWS SDK v2 Config directly. When provided for s3:// URLs, this config is used instead of the URL-based configuration. This allows full control over AWS configuration including custom credentials providers, HTTP clients, retry settings, etc.
func WithAnonymous ¶
func WithAnonymous() Opt
WithAnonymous forces use of anonymous credentials. Use this for S3-compatible services that don't require authentication.
func WithCreateDir ¶
func WithCreateDir() Opt
WithCreateDir sets create_dir=true for file:// URLs to create the directory if it doesn't exist
func WithEndpoint ¶
WithEndpoint sets the S3 endpoint for S3-compatible services. For http:// endpoints, HTTPS is automatically disabled.
func WithTracer ¶ added in v0.0.14
WithTracer sets the OpenTelemetry tracer for the backend. When set on an s3:// backend, AWS SDK middleware is injected so each S3 API call (PutObject, GetObject, etc.) produces a child span. When not set no SDK middleware is added, avoiding unnecessary overhead in non-tracing deployments.