minio

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package minio provides functionality for interacting with MinIO/S3-compatible object storage.

The minio package offers a simplified interface for working with object storage systems that are compatible with the S3 API, including MinIO, Amazon S3, and others. It provides functionality for object operations, bucket management, and presigned URL generation with a focus on ease of use and reliability.

Core Features:

  • Bucket operations (create, check existence)
  • Object operations (upload, download, delete)
  • Presigned URL generation for temporary access
  • Multipart upload and download support for large files
  • Notification configuration
  • Integration with the Logger package for structured logging

Basic Usage:

	import (
		"github.com/Aleph-Alpha/std/v1/minio"
		"github.com/Aleph-Alpha/std/v1/logger"
	)

	// Create a logger (optional)
	log, _ := logger.NewLoggerClient(logger.Config{Level: "info"})
	loggerAdapter := minio.NewLoggerAdapter(log)

	// Create a new MinIO client with logger
	client, err := minio.NewClient(minio.Config{
		Connection: minio.ConnectionConfig{
			Endpoint:        "play.min.io",
			AccessKeyID:     "minioadmin",
			SecretAccessKey: "minioadmin",
			UseSSL:          true,
			BucketName:      "mybucket",
         AccessBucketCreation: true,
		},
		PresignedConfig: minio.PresignedConfig{
			ExpiryDuration: 1 * time.Hour,
		},
	}, loggerAdapter)
	if err != nil {
		log.Fatal("Failed to create MinIO client", err, nil)
	}

	// Alternative: Create MinIO client without logger (uses fallback)
	client, err := minio.NewClient(config, nil)
	if err != nil {
		return fmt.Errorf("failed to initialize MinIO client: %w", err)
	}

	// Create a bucket if it doesn't exist
	err = client.CreateBucket(context.Background(), "mybucket")
	if err != nil {
		log.Error("Failed to create bucket", err, nil)
	}

	// Upload a file
	file, _ := os.Open("/local/path/file.txt")
	defer file.Close()
	fileInfo, _ := file.Stat()
	_, err = client.Put(context.Background(), "path/to/object.txt", file, fileInfo.Size())
	if err != nil {
		log.Error("Failed to upload file", err, nil)
	}

	// Generate a presigned URL for downloading
	url, err := client.PreSignedGet(context.Background(), "path/to/object.txt")
	if err != nil {
		log.Error("Failed to generate presigned URL", err, nil)
	}

Multipart Operations:

For large files, the package provides multipart upload and download capabilities:

Multipart Upload Example:

// Generate multipart upload URLs for a 1GB file
upload, err := client.GenerateMultipartUploadURLs(
	ctx,
	"large-file.zip",
	1024*1024*1024, // 1GB
	"application/zip",
	2*time.Hour, // URLs valid for 2 hours
)
if err != nil {
	log.Error("Failed to generate upload URLs", err, nil)
}

// Use the returned URLs to upload each part
urls := upload.GetPresignedURLs()
partNumbers := upload.GetPartNumbers()

// After uploading parts, complete the multipart upload
err = client.CompleteMultipartUpload(
	ctx,
	upload.GetObjectKey(),
	upload.GetUploadID(),
	partNumbers,
	etags, // ETags returned from each part upload
)

Multipart Download Example:

// Generate multipart download URLs for a large file
download, err := client.GenerateMultipartPresignedGetURLs(
	ctx,
	"large-file.zip",
	10*1024*1024, // 10MB parts
	1*time.Hour,  // URLs valid for 1 hour
)
if err != nil {
	log.Error("Failed to generate download URLs", err, nil)
}

// Use the returned URLs to download each part
urls := download.GetPresignedURLs()
ranges := download.GetPartRanges()

// Each URL can be used with an HTTP client to download a specific part
// by setting the Range header to the corresponding value from ranges

FX Module Integration:

This package provides an fx module for easy integration with optional logger injection:

// With logger module (recommended)
app := fx.New(
	logger.FXModule,  // Provides structured logger
	fx.Provide(func(log *logger.Logger) minio.MinioLogger {
		return minio.NewLoggerAdapter(log)
	}),
	minio.FXModule,   // Will automatically use the provided logger
	// ... other modules
)
app.Run()

// Without logger module (uses fallback logger)
app := fx.New(
	minio.FXModule,   // Will use fallback logger
	// ... other modules
)
app.Run()

Security Considerations:

When using this package, follow these security best practices:

  • Use environment variables or a secure secrets manager for credentials
  • Always enable TLS (UseSSL=true) in production environments
  • Use presigned URLs with the shortest viable expiration time
  • Set appropriate bucket policies and access controls
  • Consider using server-side encryption for sensitive data

Error Handling:

All operations return clear error messages that can be logged:

data, err := client.Get(ctx, "object.txt")
if err != nil {
	if strings.Contains(err.Error(), "The specified key does not exist") {
		// Handle not found case
	} else {
		// Handle other errors
		log.Error("Download failed", err, nil)
	}
}

Thread Safety:

All methods on the Minio type are safe for concurrent use by multiple goroutines.

Package minio is a generated GoMock package.

Index

Constants

View Source
const (

	// MultipartThreshold is the default size threshold (50 MiB) above which uploads
	// will automatically use multipart uploading for better performance and reliability.
	MultipartThreshold int64 = 50 * 1024 * 1024

	// MaxObjectSize is the maximum size (5 TiB) for a single object in MinIO/S3.
	// This is a limit imposed by the S3 specification.
	MaxObjectSize int64 = 5 * 1024 * 1024 * 1024 * 1024

	// UploadDefaultContentType is the default MIME type to use for uploaded objects.
	UploadDefaultContentType string = "application/octet-stream"

	MultipartDownloadDefaultPartSize int64 = 5 * 1024 * 1024
)

Constants for MinIO client configuration and behavior.

Variables

View Source
var (
	// ErrObjectNotFound is returned when an object doesn't exist in the bucket
	ErrObjectNotFound = errors.New("object not found")

	// ErrBucketNotFound is returned when a bucket doesn't exist
	ErrBucketNotFound = errors.New("bucket not found")

	// ErrBucketAlreadyExists is returned when trying to create a bucket that already exists
	ErrBucketAlreadyExists = errors.New("bucket already exists")

	// ErrInvalidBucketName is returned when bucket name is invalid
	ErrInvalidBucketName = errors.New("invalid bucket name")

	// ErrInvalidObjectName is returned when object name is invalid
	ErrInvalidObjectName = errors.New("invalid object name")

	// ErrAccessDenied is returned when access is denied to bucket or object
	ErrAccessDenied = errors.New("access denied")

	// ErrInsufficientPermissions is returned when user lacks necessary permissions
	ErrInsufficientPermissions = errors.New("insufficient permissions")

	// ErrInvalidCredentials is returned when credentials are invalid
	ErrInvalidCredentials = errors.New("invalid credentials")

	// ErrCredentialsExpired is returned when credentials have expired
	ErrCredentialsExpired = errors.New("credentials expired")

	// ErrConnectionFailed is returned when connection to MinIO server fails
	ErrConnectionFailed = errors.New("connection failed")

	// ErrConnectionLost is returned when connection to MinIO server is lost
	ErrConnectionLost = errors.New("connection lost")

	// ErrTimeout is returned when operation times out
	ErrTimeout = errors.New("operation timeout")

	// ErrInvalidRange is returned when byte range is invalid
	ErrInvalidRange = errors.New("invalid range")

	// ErrObjectTooLarge is returned when object exceeds size limits
	ErrObjectTooLarge = errors.New("object too large")

	// ErrInvalidChecksum is returned when object checksum doesn't match
	ErrInvalidChecksum = errors.New("invalid checksum")

	// ErrInvalidMetadata is returned when object metadata is invalid
	ErrInvalidMetadata = errors.New("invalid metadata")

	// ErrInvalidContentType is returned when content type is invalid
	ErrInvalidContentType = errors.New("invalid content type")

	// ErrInvalidEncryption is returned when encryption parameters are invalid
	ErrInvalidEncryption = errors.New("invalid encryption")

	// ErrServerError is returned for internal MinIO server errors
	ErrServerError = errors.New("server error")

	// ErrServiceUnavailable is returned when MinIO service is unavailable
	ErrServiceUnavailable = errors.New("service unavailable")

	// ErrTooManyRequests is returned when rate limit is exceeded
	ErrTooManyRequests = errors.New("too many requests")

	// ErrInvalidResponse is returned when server response is invalid
	ErrInvalidResponse = errors.New("invalid response")

	// ErrNetworkError is returned for network-related errors
	ErrNetworkError = errors.New("network error")

	// ErrInvalidURL is returned when URL is malformed
	ErrInvalidURL = errors.New("invalid URL")

	// ErrQuotaExceeded is returned when storage quota is exceeded
	ErrQuotaExceeded = errors.New("quota exceeded")

	// ErrBucketNotEmpty is returned when trying to delete non-empty bucket
	ErrBucketNotEmpty = errors.New("bucket not empty")

	// ErrPreconditionFailed is returned when precondition check fails
	ErrPreconditionFailed = errors.New("precondition failed")

	// ErrInvalidPart is returned when multipart upload part is invalid
	ErrInvalidPart = errors.New("invalid part")

	// ErrInvalidUploadID is returned when multipart upload ID is invalid
	ErrInvalidUploadID = errors.New("invalid upload ID")

	// ErrPartTooSmall is returned when multipart upload part is too small
	ErrPartTooSmall = errors.New("part too small")

	// ErrNotImplemented is returned for unsupported operations
	ErrNotImplemented = errors.New("operation not implemented")

	// ErrInvalidArgument is returned when function arguments are invalid
	ErrInvalidArgument = errors.New("invalid argument")

	// ErrCancelled is returned when operation is cancelled
	ErrCancelled = errors.New("operation cancelled")

	// ErrConfigurationError is returned for configuration-related errors
	ErrConfigurationError = errors.New("configuration error")

	// ErrVersioningNotEnabled is returned when versioning is required but not enabled
	ErrVersioningNotEnabled = errors.New("versioning not enabled")

	// ErrInvalidVersion is returned when object version is invalid
	ErrInvalidVersion = errors.New("invalid version")

	// ErrLockConfigurationError is returned for object lock configuration errors
	ErrLockConfigurationError = errors.New("lock configuration error")

	// ErrObjectLocked is returned when object is locked and cannot be deleted
	ErrObjectLocked = errors.New("object locked")

	// ErrRetentionPolicyError is returned for retention policy errors
	ErrRetentionPolicyError = errors.New("retention policy error")

	// ErrMalformedXML is returned when XML is malformed
	ErrMalformedXML = errors.New("malformed XML")

	// ErrInvalidStorageClass is returned when storage class is invalid
	ErrInvalidStorageClass = errors.New("invalid storage class")

	// ErrReplicationError is returned for replication-related errors
	ErrReplicationError = errors.New("replication error")

	// ErrLifecycleError is returned for lifecycle configuration errors
	ErrLifecycleError = errors.New("lifecycle error")

	// ErrNotificationError is returned for notification configuration errors
	ErrNotificationError = errors.New("notification error")

	// ErrTaggingError is returned for object tagging errors
	ErrTaggingError = errors.New("tagging error")

	// ErrPolicyError is returned for bucket policy errors
	ErrPolicyError = errors.New("policy error")

	// ErrWebsiteError is returned for website configuration errors
	ErrWebsiteError = errors.New("website configuration error")

	// ErrCORSError is returned for CORS configuration errors
	ErrCORSError = errors.New("CORS configuration error")

	// ErrLoggingError is returned for logging configuration errors
	ErrLoggingError = errors.New("logging configuration error")

	// ErrEncryptionError is returned for encryption configuration errors
	ErrEncryptionError = errors.New("encryption configuration error")

	// ErrUnknownError is returned for unknown/unhandled errors
	ErrUnknownError = errors.New("unknown error")
)

Common object storage error types that can be used by consumers of this package. These provide a standardized set of errors that abstract away the underlying MinIO-specific error details.

FXModule is an fx.Module that provides and configures the MinIO client. This module registers the MinIO client with the Fx dependency injection framework, making it available to other components in the application.

The module: 1. Provides the MinIO client factory function 2. Invokes the lifecycle registration to manage the client's lifecycle

Usage:

app := fx.New(
    minio.FXModule,
    // other modules...
)

Functions

func RegisterLifecycle

func RegisterLifecycle(params MinioLifeCycleParams)

RegisterLifecycle registers the MinIO client with the fx lifecycle system. This function sets up proper initialization and graceful shutdown of the MinIO client, including starting and stopping the connection monitoring goroutines.

Parameters:

  • lc: The fx lifecycle controller
  • mi: The MinIO client instance
  • logger: Logger for recording lifecycle events

The function registers two background goroutines: 1. A connection monitor that checks for connection health 2. A retry mechanism that handles reconnection when needed

On application shutdown, it ensures these goroutines are properly terminated and waits for their completion before allowing the application to exit.

Types

type AMQPNotification

type AMQPNotification struct {
	// Embed the common notification properties
	BaseNotification

	// URL is the AMQP server connection URL
	URL string

	// Exchange is the name of the AMQP exchange
	Exchange string

	// RoutingKey defines how messages are routed to queues
	RoutingKey string

	// ExchangeType defines the AMQP exchange type (e.g., "fanout", "direct")
	ExchangeType string

	// Mandatory flag requires messages to be routable
	Mandatory bool

	// Immediate flag requires immediate delivery
	Immediate bool

	// Durable flag makes the exchange survive broker restarts
	Durable bool

	// Internal flag makes the exchange only accessible to other exchanges
	Internal bool

	// NoWait flag makes declare operations non-blocking
	NoWait bool

	// AutoDeleted flag automatically deletes the exchange when no longer used
	AutoDeleted bool
}

AMQPNotification defines an AMQP notification target. AMQP notifications can be used with systems like RabbitMQ.

type BaseNotification

type BaseNotification struct {
	// Events is a list of event types to subscribe to
	// Examples: "s3:ObjectCreated:*", "s3:ObjectRemoved:*"
	Events []string

	// Prefix filters notifications to only objects with this key prefix
	// Example: "uploads/" to only get events for objects in the uploads directory
	Prefix string

	// Suffix filters notifications to only objects with this key suffix
	// Example: ".jpg" to only get events for JPEG images
	Suffix string

	// Name is a unique identifier for this notification configuration
	Name string
}

BaseNotification contains common properties for all notification types. This is embedded in specific notification target types.

type BufferPool

type BufferPool struct {
	// contains filtered or unexported fields
}

BufferPool implements an advanced pool of bytes.Buffers with size limits and monitoring. It prevents memory leaks by limiting buffer sizes and pool capacity.

func NewBufferPool

func NewBufferPool() *BufferPool

NewBufferPool creates a new BufferPool instance with default configuration. The pool will create new bytes.Buffer instances as needed when none are available, with built-in size limits to prevent memory leaks.

Returns a configured BufferPool ready for use.

func NewBufferPoolWithConfig

func NewBufferPoolWithConfig(config BufferPoolConfig) *BufferPool

NewBufferPoolWithConfig creates a new BufferPool with custom configuration. This allows fine-tuning of buffer sizes and pool limits for specific use cases.

Parameters:

  • config: Configuration for buffer pool behavior

Returns a configured BufferPool ready for use.

func (*BufferPool) Cleanup

func (bp *BufferPool) Cleanup()

Cleanup forces cleanup of the buffer pool, releasing all buffers. This is useful during shutdown or when memory pressure is high.

func (*BufferPool) Get

func (bp *BufferPool) Get() *bytes.Buffer

Get returns a buffer from the pool. The returned buffer may be newly allocated or reused from a previous Put call. The buffer is automatically reset and ready for use.

Returns a *bytes.Buffer that should be returned to the pool when no longer needed.

func (*BufferPool) GetStats

func (bp *BufferPool) GetStats() BufferPoolStats

GetStats returns current buffer pool statistics for monitoring. This is useful for understanding memory usage patterns and pool effectiveness.

func (*BufferPool) Put

func (bp *BufferPool) Put(b *bytes.Buffer)

Put returns a buffer to the pool for future reuse. The buffer will be discarded if it exceeds the maximum size limit or if the pool is full. This prevents memory leaks from oversized buffers accumulating in the pool.

Parameters:

  • b: The buffer to return to the pool

type BufferPoolConfig

type BufferPoolConfig struct {
	// MaxBufferSize is the maximum size a buffer can grow to before being discarded
	MaxBufferSize int
	// MaxPoolSize is the maximum number of buffers to keep in the pool
	MaxPoolSize int
	// InitialBufferSize is the initial size for new buffers
	InitialBufferSize int
}

BufferPoolConfig contains configuration for the buffer pool

func DefaultBufferPoolConfig

func DefaultBufferPoolConfig() BufferPoolConfig

DefaultBufferPoolConfig returns the default buffer pool configuration

type BufferPoolStats

type BufferPoolStats struct {
	// CurrentPoolSize is the current number of buffers in the pool
	CurrentPoolSize int64 `json:"currentPoolSize"`
	// TotalBuffersCreated is the total number of buffers created since start
	TotalBuffersCreated int64 `json:"totalBuffersCreated"`
	// TotalBuffersReused is the total number of buffer reuses
	TotalBuffersReused int64 `json:"totalBuffersReused"`
	// TotalBuffersDiscarded is the total number of buffers discarded due to limits
	TotalBuffersDiscarded int64 `json:"totalBuffersDiscarded"`
	// MaxBufferSize is the maximum allowed buffer size
	MaxBufferSize int `json:"maxBufferSize"`
	// MaxPoolSize is the maximum allowed pool size
	MaxPoolSize int `json:"maxPoolSize"`
	// ReuseRatio is the ratio of reused buffers to created buffers
	ReuseRatio float64 `json:"reuseRatio"`
}

Stats returns statistics about buffer pool usage for monitoring and debugging.

type Config

type Config struct {
	// Connection contains basic connection parameters for the MinIO server
	Connection ConnectionConfig

	// UploadConfig defines parameters related to uploading objects
	UploadConfig UploadConfig

	// DownloadConfig defines parameters related to downloading objects
	DownloadConfig DownloadConfig

	// PresignedConfig contains settings for generating presigned URLs
	PresignedConfig PresignedConfig

	// Notification defines event notification configuration
	Notification NotificationConfig
}

Config defines the top-level configuration for MinIO. This structure contains all configuration options for the MinIO client, organized into logical sections for different aspects of functionality.

type ConnectionConfig

type ConnectionConfig struct {
	// Endpoint is the MinIO server address (e.g., "minio.example.com:9000")
	Endpoint string

	// AccessKeyID is the MinIO access key (similar to a username)
	AccessKeyID string

	// SecretAccessKey is the MinIO secret key (similar to a password)
	SecretAccessKey string

	// UseSSL determines whether to use HTTPS (true) or HTTP (false)
	UseSSL bool

	// BucketName is the default bucket to use for operations
	BucketName string

	// Region specifies the S3 region (e.g., "us-east-1")
	Region string

	// AccessBucketCreation determines whether to allow bucket creation if it doesn't exist
	AccessBucketCreation bool
}

ConnectionConfig contains MinIO server connection details. These parameters are required to establish a connection to a MinIO server.

type ConnectionPoolConfig

type ConnectionPoolConfig struct {
	// MaxIdleConnections is the maximum number of idle connections to maintain
	MaxIdleConnections int
	// MaxConnectionsPerHost is the maximum connections per host
	MaxConnectionsPerHost int
	// IdleConnectionTimeout is how long to keep idle connections
	IdleConnectionTimeout time.Duration
	// ConnectionTimeout is the timeout for establishing connections
	ConnectionTimeout time.Duration
}

ConnectionPoolConfig contains configuration for connection management

func DefaultConnectionPoolConfig

func DefaultConnectionPoolConfig() ConnectionPoolConfig

DefaultConnectionPoolConfig returns default connection pool configuration

type DownloadConfig

type DownloadConfig struct {
	// SmallFileThreshold is the size in bytes below which a file is considered "small"
	// Small files use a simpler, direct download approach
	SmallFileThreshold int64

	// InitialBufferSize is the starting buffer size in bytes for downloading large files
	// This affects memory usage when downloading large objects
	InitialBufferSize int

	// DefaultMultipartDownload is the default size of parts to download at each part
	DefaultMultipartDownload int
}

DownloadConfig defines parameters that control download behavior. These settings optimize memory usage when downloading objects of different sizes.

type ErrorCategory

type ErrorCategory int

ErrorCategory represents different categories of MinIO errors

const (
	CategoryUnknown ErrorCategory = iota
	CategoryConnection
	CategoryAuthentication
	CategoryPermission
	CategoryNotFound
	CategoryConflict
	CategoryValidation
	CategoryServer
	CategoryNetwork
	CategoryTimeout
	CategoryQuota
	CategoryConfiguration
	CategoryVersioning
	CategoryLocking
	CategoryOperation
)

type KafkaNotification

type KafkaNotification struct {
	// Embed the common notification properties
	BaseNotification

	// Brokers is a list of Kafka broker addresses
	Brokers []string

	// Topic is the Kafka topic where events will be published
	Topic string

	// SASL contains optional SASL authentication details for Kafka
	SASL *KafkaSASLAuth
}

KafkaNotification defines a Kafka notification target. Kafka notifications publish events to a Kafka topic.

type KafkaSASLAuth

type KafkaSASLAuth struct {
	// Enable turns on SASL authentication
	Enable bool

	// Username for SASL authentication
	Username string

	// Password for SASL authentication
	Password string
}

KafkaSASLAuth contains Kafka SASL authentication details. SASL is used for authenticating with Kafka brokers.

type LoggerAdapter

type LoggerAdapter struct {
	// contains filtered or unexported fields
}

LoggerAdapter adapts the logger package's Logger to implement MinioLogger interface. This allows seamless integration with the structured logger from the logger package.

func (*LoggerAdapter) Debug

func (la *LoggerAdapter) Debug(msg string, err error, fields ...map[string]any)

Debug implements MinioLogger interface by delegating to the wrapped logger

func (*LoggerAdapter) Error

func (la *LoggerAdapter) Error(msg string, err error, fields ...map[string]any)

Error implements MinioLogger interface by delegating to the wrapped logger

func (*LoggerAdapter) Fatal

func (la *LoggerAdapter) Fatal(msg string, err error, fields ...map[string]any)

Fatal implements MinioLogger interface by delegating to the wrapped logger

func (*LoggerAdapter) Info

func (la *LoggerAdapter) Info(msg string, err error, fields ...map[string]any)

Info implements MinioLogger interface by delegating to the wrapped logger

func (*LoggerAdapter) Warn

func (la *LoggerAdapter) Warn(msg string, err error, fields ...map[string]any)

Warn implements MinioLogger interface by delegating to the wrapped logger

type MQTTNotification

type MQTTNotification struct {
	// Embed the common notification properties
	BaseNotification

	// Broker is the MQTT broker address (host:port)
	Broker string

	// Topic is the MQTT topic where events will be published
	Topic string

	// QoS (Quality of Service) level for message delivery:
	// 0: At most once (fire and forget)
	// 1: At least once (acknowledged delivery)
	// 2: Exactly once (assured delivery)
	QoS byte

	// Username for MQTT broker authentication
	Username string

	// Password for MQTT broker authentication
	Password string

	// Reconnect flag enables automatic reconnection on connection loss
	Reconnect bool
}

MQTTNotification defines an MQTT notification target. MQTT notifications publish events to an MQTT broker.

type Minio

type Minio struct {
	// Client is the standard MinIO client for high-level operations
	Client *minio.Client

	// CoreClient provides access to low-level operations not available in the standard client
	CoreClient *minio.Core
	// contains filtered or unexported fields
}

Minio represents a MinIO client with additional functionality. It wraps the standard MinIO client with features for connection management, reconnection handling, and thread-safety.

func NewClient

func NewClient(config Config, logger MinioLogger) (*Minio, error)

NewClient creates and validates a new MinIO client. It establishes connections to both the standard and core MinIO APIs, validates the connection, and ensures the configured bucket exists.

Parameters:

  • config: Configuration for the MinIO client
  • logger: Optional logger for recording operations and errors. If nil, a fallback logger will be used.

Returns a configured and validated MinIO client or an error if initialization fails.

Example:

// With custom logger
client, err := minio.NewClient(config, myLogger)
if err != nil {
    return fmt.Errorf("failed to initialize MinIO client: %w", err)
}

// Without logger (uses fallback)
client, err := minio.NewClient(config, nil)
if err != nil {
    return fmt.Errorf("failed to initialize MinIO client: %w", err)
}

func NewMinioClientWithDI

func NewMinioClientWithDI(params MinioParams) (*Minio, error)

func (*Minio) AbortMultipartUpload

func (m *Minio) AbortMultipartUpload(ctx context.Context, objectKey, uploadID string) error

AbortMultipartUpload aborts a multipart upload. This method cancels an in-progress multipart upload and removes any parts that have already been uploaded.

Parameters:

  • ctx: Context for the operation
  • objectKey: Path and name of the object in the bucket
  • uploadID: The upload ID to abort

Returns an error if the abort operation fails.

Example:

err := minioClient.AbortMultipartUpload(ctx, "uploads/myfile.zip", uploadID)

func (*Minio) CleanupIncompleteUploads

func (m *Minio) CleanupIncompleteUploads(ctx context.Context, prefix string, olderThan time.Duration) error

CleanupIncompleteUploads aborts any incomplete uploads older than the given duration. This method helps maintain storage hygiene by removing abandoned upload sessions.

Parameters:

  • ctx: Context for the operation
  • prefix: Optional prefix to filter objects by key
  • olderThan: Only abort uploads older than this duration

Return an error if the cleanup operation fails.

Example:

// Abort all incomplete uploads in the "uploads/" prefix that are older than 24 hours
err := minioClient.CleanupIncompleteUploads(ctx, "uploads/", 24*time.Hour)

func (*Minio) CleanupResources

func (m *Minio) CleanupResources()

CleanupResources performs cleanup of buffer pools and forces garbage collection. This method is useful during shutdown or when memory pressure is high.

Example:

// Clean up resources during shutdown
defer minioClient.CleanupResources()

func (*Minio) CompleteMultipartUpload

func (m *Minio) CompleteMultipartUpload(ctx context.Context, objectKey, uploadID string, partNumbers []int, etags []string) error

CompleteMultipartUpload finalizes a multipart upload by combining all parts. This method tells MinIO/S3 to assemble all the uploaded parts into the final object.

Parameters:

  • ctx: Context for the operation
  • objectKey: Path and name of the object in the bucket
  • uploadID: The upload ID of the multipart upload
  • partNumbers: Slice of part numbers in the order they were uploaded
  • etags: Slice of ETags for each part, must correspond to partNumbers

Returns an error if the completion fails.

Example:

err := minioClient.CompleteMultipartUpload(
    ctx,
    "uploads/myfile.zip",
    uploadID,
    []int{1, 2, 3},
    []string{"etag1", "etag2", "etag3"},
)

func (*Minio) Delete

func (m *Minio) Delete(ctx context.Context, objectKey string) error

Delete removes an object from the specified bucket. This method permanently deletes the object from MinIO storage.

Parameters:

  • ctx: Context for controlling the delete operation
  • objectKey: Path and name of the object to delete

Returns an error if the deletion fails.

Example:

err := minioClient.Delete(ctx, "documents/old-report.pdf")
if err == nil {
    fmt.Println("Object successfully deleted")
}

func (*Minio) GenerateMultipartPresignedGetURLs

func (m *Minio) GenerateMultipartPresignedGetURLs(
	ctx context.Context,
	objectKey string,
	partSize int64,
	expiry ...time.Duration,
) (MultipartPresignedGet, error)

GenerateMultipartPresignedGetURLs generates URLs for downloading an object in parts This method is useful for large objects that may benefit from parallel downloads or resumable downloads by clients.

Parameters:

  • ctx: Context for the operation
  • objectKey: Path and name of the object in the bucket
  • partSize: Size of each part in bytes (must be at least 5 MiB)
  • expiry: Optional custom expiration duration for the presigned URLs

Returns:

  • MultipartPresignedGet: Interface providing access to download details
  • error: Any error that occurred during setup

Example:

download, err := minioClient.GenerateMultipartPresignedGetURLs(
    ctx,
    "documents/large-file.zip",
    10*1024*1024, // 10 MiB parts
    2*time.Hour,
)

func (*Minio) GenerateMultipartUploadURLs

func (m *Minio) GenerateMultipartUploadURLs(
	ctx context.Context,
	objectKey string,
	fileSize int64,
	contentType string,
	expiry ...time.Duration,
) (MultipartUpload, error)

GenerateMultipartUploadURLs initiates a multipart upload and generates all necessary URLs. This method prepares everything needed for a client to directly upload multiple parts to MinIO/S3 without further server interaction until the upload is complete.

Parameters:

  • ctx: Context for the operation
  • objectKey: Path and name of the object in the bucket
  • fileSize: Total size of the file in bytes
  • contentType: MIME type of the file (defaults to "application/octet-stream" if empty)
  • expiry: Optional custom expiration duration for the presigned URLs

Returns:

  • MultipartUpload: Interface providing access to upload details
  • error: Any error that occurred during setup

Example:

upload, err := minioClient.GenerateMultipartUploadURLs(
    ctx,
    "uploads/myfile.zip",
    fileSize,
    "application/zip",
    2*time.Hour,
)

func (*Minio) Get

func (m *Minio) Get(ctx context.Context, objectKey string) ([]byte, error)

Get retrieves an object from the bucket and returns its contents as a byte slice. This method is optimized for both small and large files with safety considerations for buffer use. For small files, it uses direct allocation, while for larger files it leverages a buffer pool to reduce memory pressure.

Parameters:

  • ctx: Context for controlling the download operation
  • objectKey: Path and name of the object in the bucket

Returns:

  • []byte: The object's contents as a byte slice
  • error: Any error that occurred during the download

Note: For very large files, consider using a streaming approach rather than loading the entire file into memory with this method.

Example:

data, err := minioClient.Get(ctx, "documents/report.pdf")
if err == nil {
    fmt.Printf("Downloaded %d bytes\n", len(data))
    ioutil.WriteFile("report.pdf", data, 0644)
}

func (*Minio) GetBufferPoolStats

func (m *Minio) GetBufferPoolStats() BufferPoolStats

GetBufferPoolStats returns buffer pool statistics for monitoring buffer efficiency. This is useful for understanding memory usage patterns and optimizing buffer sizes.

Returns:

  • BufferPoolStats: Statistics about buffer pool usage and efficiency

Example:

stats := minioClient.GetBufferPoolStats()
fmt.Printf("Buffer reuse ratio: %.2f%%\n", stats.ReuseRatio*100)
fmt.Printf("Buffers in pool: %d\n", stats.CurrentPoolSize)

func (*Minio) GetErrorCategory

func (m *Minio) GetErrorCategory(err error) ErrorCategory

GetErrorCategory returns the category of the given error

func (*Minio) GetResourceStats

func (m *Minio) GetResourceStats() ResourceStats

GetResourceStats returns comprehensive resource usage statistics for monitoring. This method provides insights into connection health, request performance, memory usage, and buffer pool efficiency.

Returns:

  • ResourceStats: Comprehensive statistics about resource usage

Example:

stats := minioClient.GetResourceStats()
fmt.Printf("Active connections: %d\n", stats.ActiveConnections)
fmt.Printf("Request success rate: %.2f%%\n", stats.RequestSuccessRate*100)
fmt.Printf("Average request duration: %v\n", stats.AverageRequestDuration)

func (*Minio) GracefulShutdown

func (m *Minio) GracefulShutdown()

GracefulShutdown safely terminates all MinIO client operations and closes associated resources. This method ensures a clean shutdown process by using sync.Once to guarantee each channel is closed exactly once, preventing "close of closed channel" panics that could occur when multiple shutdown paths execute concurrently.

The shutdown process: 1. Safely closes the shutdownSignal channel to notify all monitoring goroutines to stop 2. Safely closes the reconnectSignal channel to terminate any reconnection attempts

This method is designed to be called from multiple potential places (such as application shutdown hooks, context cancellation handlers, or defer statements) without causing resource management issues. The use of sync.Once ensures that even if called multiple times, each cleanup operation happens exactly once.

Example usage:

// In application shutdown code
func shutdownApp() {
    minioClient.GracefulShutdown()
    // other cleanup...
}

// Or with defer
func processFiles() {
    defer minioClient.GracefulShutdown()
    // processing logic...
}

func (*Minio) IsPermanentError

func (m *Minio) IsPermanentError(err error) bool

IsPermanentError returns true if the error is permanent and should not be retried

func (*Minio) IsRetryableError

func (m *Minio) IsRetryableError(err error) bool

IsRetryableError returns true if the error is retryable

func (*Minio) IsTemporaryError

func (m *Minio) IsTemporaryError(err error) bool

IsTemporaryError returns true if the error is temporary

func (*Minio) ListIncompleteUploads

func (m *Minio) ListIncompleteUploads(ctx context.Context, prefix string) ([]minio.ObjectMultipartInfo, error)

ListIncompleteUploads lists all incomplete multipart uploads for cleanup. This method retrieves information about multipart uploads that were started but never completed or aborted.

Parameters:

  • ctx: Context for the operation
  • prefix: Optional prefix to filter objects by key

Returns:

  • []minio.ObjectMultipartInfo: Information about incomplete uploads
  • error: Any error that occurred during the listing

Example:

uploads, err := minioClient.ListIncompleteUploads(ctx, "uploads/")
if err == nil {
    for _, upload := range uploads {
        fmt.Printf("Incomplete upload: %s, started: %v\n", upload.Key, upload.Initiated)
    }
}

func (*Minio) PreSignedGet

func (m *Minio) PreSignedGet(ctx context.Context, objectKey string) (string, error)

PreSignedGet generates a pre-signed URL for GetObject operations. This method creates a temporary URL that allows downloading an object without additional authentication.

Parameters:

  • ctx: Context for the operation
  • objectKey: Path and name of the object in the bucket

Returns:

  • string: The presigned URL for downloading the object
  • error: Any error that occurred during URL generation

Example:

url, err := minioClient.PreSignedGet(ctx, "documents/report.pdf")
if err == nil {
    fmt.Printf("Download link: %s\n", url)
}

func (*Minio) PreSignedHeadObject

func (m *Minio) PreSignedHeadObject(ctx context.Context, objectKey string) (string, error)

PreSignedHeadObject generates a pre-signed URL for HeadObject operations. This method creates a temporary URL that allows checking object metadata without downloading the object itself.

Parameters:

  • ctx: Context for the operation
  • objectKey: Path and name of the object in the bucket

Returns:

  • string: The presigned URL for the HEAD operation
  • error: Any error that occurred during URL generation

Example:

url, err := minioClient.PreSignedHeadObject(ctx, "documents/report.pdf")
if err == nil {
    fmt.Printf("Use this URL to check if the object exists: %s\n", url)
}

func (*Minio) PreSignedPut

func (m *Minio) PreSignedPut(ctx context.Context, objectKey string) (string, error)

PreSignedPut generates a pre-signed URL for PutObject operations. This method creates a temporary URL that allows uploading an object without additional authentication.

Parameters:

  • ctx: Context for the operation
  • objectKey: Path and name of the object in the bucket

Returns:

  • string: The presigned URL for uploading the object
  • error: Any error that occurred during URL generation

Example:

url, err := minioClient.PreSignedPut(ctx, "documents/report.pdf")
if err == nil {
    fmt.Printf("Upload link: %s\n", url)
}

func (*Minio) Put

func (m *Minio) Put(ctx context.Context, objectKey string, reader io.Reader, size ...int64) (int64, error)

Put uploads an object to the specified bucket. This method handles the direct upload of data to MinIO, managing both the transfer and proper error handling.

Parameters:

  • ctx: Context for controlling the upload operation
  • objectKey: Path and name of the object in the bucket
  • reader: Source of the data to upload
  • size: Optional parameter specifying the size of the data in bytes. If not provided or set to 0, an unknown size is assumed, which may affect upload performance as chunking decisions can't be optimized

Returns:

  • int64: The number of bytes uploaded
  • error: Any error that occurred during the upload

Example:

file, _ := os.Open("document.pdf")
defer file.Close()

fileInfo, _ := file.Stat()
size, err := minioClient.Put(ctx, "documents/document.pdf", file, fileInfo.Size())
if err == nil {
    fmt.Printf("Uploaded %d bytes\n", size)
}

func (*Minio) ResetResourceStats

func (m *Minio) ResetResourceStats()

ResetResourceStats resets all resource monitoring statistics. This is useful for getting fresh metrics for a specific time period.

Example:

// Reset stats at the beginning of a monitoring period
minioClient.ResetResourceStats()
// ... perform operations ...
stats := minioClient.GetResourceStats()

func (*Minio) StreamGet

func (m *Minio) StreamGet(ctx context.Context, objectKey string, chunkSize int) (<-chan []byte, <-chan error)

StreamGet downloads a file from MinIO and sends chunks through a channel

func (*Minio) TranslateError

func (m *Minio) TranslateError(err error) error

TranslateError converts MinIO-specific errors into standardized application errors. This function provides abstraction from the underlying MinIO implementation details, allowing application code to handle errors in a MinIO-agnostic way.

It maps common MinIO errors to the standardized error types defined above. If an error doesn't match any known type, it's returned unchanged.

type MinioLifeCycleParams

type MinioLifeCycleParams struct {
	fx.In

	Lifecycle fx.Lifecycle
	Minio     *Minio
}

type MinioLogger

type MinioLogger interface {
	// Debug logs debug-level messages
	Debug(msg string, err error, fields ...map[string]any)
	// Info logs informational messages
	Info(msg string, err error, fields ...map[string]any)
	// Warn logs warning messages
	Warn(msg string, err error, fields ...map[string]any)
	// Error logs error messages
	Error(msg string, err error, fields ...map[string]any)
	// Fatal logs fatal messages and should terminate the application
	Fatal(msg string, err error, fields ...map[string]any)
}

MinioLogger defines the logging interface used by MinIO client. This interface allows for flexible logger injection while maintaining compatibility with both structured loggers (like the logger package) and simple loggers.

func NewLoggerAdapter

func NewLoggerAdapter(logger interface {
	Debug(msg string, err error, fields ...map[string]interface{})
	Info(msg string, err error, fields ...map[string]interface{})
	Warn(msg string, err error, fields ...map[string]interface{})
	Error(msg string, err error, fields ...map[string]interface{})
	Fatal(msg string, err error, fields ...map[string]interface{})
}) MinioLogger

NewLoggerAdapter creates a new LoggerAdapter that wraps the logger package's Logger. This function provides a bridge between the logger package and MinIO's logging interface.

type MinioParams

type MinioParams struct {
	fx.In

	Config
	// Logger is optional - if not provided, fallback logger will be used
	Logger MinioLogger `optional:"true"`
}

type MockLogger

type MockLogger struct {
	// contains filtered or unexported fields
}

MockLogger is a mock of Logger interface.

func NewMockLogger

func NewMockLogger(ctrl *gomock.Controller) *MockLogger

NewMockLogger creates a new mock instance.

func (*MockLogger) Debug

func (m *MockLogger) Debug(msg string, err error, fields ...map[string]any)

Debug mocks base method.

func (*MockLogger) EXPECT

func (m *MockLogger) EXPECT() *MockLoggerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLogger) Error

func (m *MockLogger) Error(msg string, err error, fields ...map[string]any)

Error mocks base method.

func (*MockLogger) Fatal

func (m *MockLogger) Fatal(msg string, err error, fields ...map[string]any)

Fatal mocks base method.

func (*MockLogger) Info

func (m *MockLogger) Info(msg string, err error, fields ...map[string]any)

Info mocks base method.

func (*MockLogger) Warn

func (m *MockLogger) Warn(msg string, err error, fields ...map[string]any)

Warn mocks base method.

type MockLoggerMockRecorder

type MockLoggerMockRecorder struct {
	// contains filtered or unexported fields
}

MockLoggerMockRecorder is the mock recorder for MockLogger.

func (*MockLoggerMockRecorder) Debug

func (mr *MockLoggerMockRecorder) Debug(msg, err any, fields ...any) *gomock.Call

Debug indicates an expected call of Debug.

func (*MockLoggerMockRecorder) Error

func (mr *MockLoggerMockRecorder) Error(msg, err any, fields ...any) *gomock.Call

Error indicates an expected call of Error.

func (*MockLoggerMockRecorder) Fatal

func (mr *MockLoggerMockRecorder) Fatal(msg, err any, fields ...any) *gomock.Call

Fatal indicates an expected call of Fatal.

func (*MockLoggerMockRecorder) Info

func (mr *MockLoggerMockRecorder) Info(msg, err any, fields ...any) *gomock.Call

Info indicates an expected call of Info.

func (*MockLoggerMockRecorder) Warn

func (mr *MockLoggerMockRecorder) Warn(msg, err any, fields ...any) *gomock.Call

Warn indicates an expected call of Warn.

type MultipartPresignedGet

type MultipartPresignedGet interface {
	// GetObjectKey returns the object key for this download
	GetObjectKey() string

	// GetPresignedURLs returns all presigned URLs for this download
	GetPresignedURLs() []string

	// GetPartRanges returns all byte ranges corresponding to the URLs
	GetPartRanges() []string

	// GetExpiryTimestamp returns the Unix timestamp when these URLs expire
	GetExpiryTimestamp() int64

	// GetTotalSize returns the total size of the object in bytes
	GetTotalSize() int64

	// GetContentType returns the content type of the object
	GetContentType() string

	// GetETag returns the ETag of the object
	GetETag() string

	// IsExpired checks if the download URLs have expired
	IsExpired() bool
}

MultipartPresignedGet is an interface for accessing multipart download info

type MultipartPresignedGetInfo

type MultipartPresignedGetInfo struct {
	// ObjectKey is the path and name of the object in the bucket
	ObjectKey string `json:"objectKey"`

	// PresignedUrls is a slice of temporary URLs for downloading each part
	PresignedUrls []string `json:"presignedUrls"`

	// PartRanges contains the byte ranges for each part
	PartRanges []string `json:"partRanges"`

	// ExpiresAt is the Unix timestamp when the presigned URLs will expire
	ExpiresAt int64 `json:"expiresAt"`

	// TotalSize is the total size of the object in bytes
	TotalSize int64 `json:"totalSize"`

	// ContentType is the MIME type of the object
	ContentType string `json:"contentType"`

	// ETag is the entity tag of the object
	ETag string `json:"etag"`
}

MultipartPresignedGetInfo contains information for downloading an object in parts

type MultipartUpload

type MultipartUpload interface {
	// GetUploadID returns the unique identifier for this multipart upload
	GetUploadID() string

	// GetObjectKey returns the object key for this upload
	GetObjectKey() string

	// GetPresignedURLs returns all presigned URLs for this upload
	GetPresignedURLs() []string

	// GetPartNumbers returns all part numbers corresponding to the URLs
	GetPartNumbers() []int

	// GetExpiryTimestamp returns the Unix timestamp when this upload expires
	GetExpiryTimestamp() int64

	// GetRecommendedPartSize returns the recommended size for each part in bytes
	GetRecommendedPartSize() int64

	// GetMaxParts returns the maximum number of parts allowed
	GetMaxParts() int

	// GetContentType returns the content type of the object
	GetContentType() string

	// GetTotalSize returns the total size of the object in bytes
	GetTotalSize() int64

	// IsExpired checks if the upload has expired
	IsExpired() bool
}

MultipartUpload represents a multipart upload session. This interface provides methods to access information about a multipart upload while hiding the internal implementation details.

type MultipartUploadInfo

type MultipartUploadInfo struct {
	// UploadID is the unique identifier for the multipart upload provided by MinIO/S3
	UploadID string `json:"uploadId"`

	// ObjectKey is the path and name of the object in the bucket
	ObjectKey string `json:"objectKey"`

	// PresignedUrls is a slice of temporary URLs for uploading each part
	PresignedUrls []string `json:"presignedUrls"`

	// PartNumbers contains the part numbers corresponding to each URL in PresignedUrls
	PartNumbers []int `json:"partNumbers"`

	// ExpiresAt is the Unix timestamp when the presigned URLs will expire
	ExpiresAt int64 `json:"expiresAt"`

	// RecommendedPartSize is the suggested size in bytes for each part for optimal performance
	RecommendedPartSize int64 `json:"recommendedPartSize"`

	// MaxParts is the maximum number of parts allowed for this upload (S3 limit)
	MaxParts int `json:"maxParts"`

	// ContentType is the MIME type of the object being uploaded
	ContentType string `json:"contentType"`

	// TotalSize is the total size of the object in bytes
	TotalSize int64 `json:"totalSize"`
}

MultipartUploadInfo contains all information needed for a multipart upload. This structure holds all the details required for managing and completing a multipart upload, including upload identifiers, presigned URLs for each part, and sizing information.

type NotificationConfig

type NotificationConfig struct {
	// Enabled determines whether event notifications are active
	Enabled bool

	// Webhook contains configuration for webhook notification targets
	Webhook []WebhookNotification

	// AMQP contains configuration for AMQP (RabbitMQ, etc.) notification targets
	AMQP []AMQPNotification

	// Redis contains configuration for Redis notification targets
	Redis []RedisNotification

	// Kafka contains configuration for Kafka notification targets
	Kafka []KafkaNotification

	// MQTT contains configuration for MQTT notification targets
	MQTT []MQTTNotification
}

NotificationConfig defines the configuration for event notifications. MinIO can send notifications when events occur on buckets (e.g., object created).

type PresignedConfig

type PresignedConfig struct {
	// Enabled determines whether presigned URL functionality is available
	Enabled bool

	// ExpiryDuration sets how long presigned URLs remain valid
	// Example: 15 * time.Minute for 15-minute expiration
	ExpiryDuration time.Duration

	// BaseURL allows overriding the host/domain in generated presigned URLs
	// Useful when using a CDN or custom domain in front of MinIO
	// Example: "https://cdn.example.com"
	BaseURL string
}

PresignedConfig contains configuration options for presigned URLs. Presigned URLs allow temporary access to objects without requiring AWS credentials.

type RedisNotification

type RedisNotification struct {
	// Embed the common notification properties
	BaseNotification

	// Addr is the Redis server address (host:port)
	Addr string

	// Password is the Redis server password, if required
	Password string

	// Key is the Redis key where events will be published
	Key string
}

RedisNotification defines a Redis notification target. Redis notifications publish events to a Redis pub/sub channel or list.

type ResourceMonitor

type ResourceMonitor struct {
	// contains filtered or unexported fields
}

ResourceMonitor tracks resource usage, performance metrics, and connection health

func NewResourceMonitor

func NewResourceMonitor(bufferPool *BufferPool) *ResourceMonitor

NewResourceMonitor creates a new resource monitor instance

func (*ResourceMonitor) GetStats

func (rm *ResourceMonitor) GetStats() ResourceStats

GetStats returns comprehensive resource usage statistics

func (*ResourceMonitor) RecordConnectionAttempt

func (rm *ResourceMonitor) RecordConnectionAttempt()

RecordConnectionAttempt records a connection attempt

func (*ResourceMonitor) RecordConnectionClosure

func (rm *ResourceMonitor) RecordConnectionClosure()

RecordConnectionClosure records a connection closure

func (*ResourceMonitor) RecordConnectionFailure

func (rm *ResourceMonitor) RecordConnectionFailure()

RecordConnectionFailure records a failed connection

func (*ResourceMonitor) RecordConnectionSuccess

func (rm *ResourceMonitor) RecordConnectionSuccess()

RecordConnectionSuccess records a successful connection

func (*ResourceMonitor) RecordMemoryUsage

func (rm *ResourceMonitor) RecordMemoryUsage(bytes int64)

RecordMemoryUsage records current memory usage

func (*ResourceMonitor) RecordRequest

func (rm *ResourceMonitor) RecordRequest() func(success bool)

RecordRequest records the start of a request and returns a function to record completion

func (*ResourceMonitor) ResetStats

func (rm *ResourceMonitor) ResetStats()

ResetStats resets all statistics counters

type ResourceStats

type ResourceStats struct {
	// Connection statistics
	TotalConnections      int64   `json:"totalConnections"`
	ActiveConnections     int64   `json:"activeConnections"`
	FailedConnections     int64   `json:"failedConnections"`
	ConnectionAttempts    int64   `json:"connectionAttempts"`
	ConnectionSuccessRate float64 `json:"connectionSuccessRate"`

	// Request statistics
	TotalRequests      int64   `json:"totalRequests"`
	SuccessfulRequests int64   `json:"successfulRequests"`
	FailedRequests     int64   `json:"failedRequests"`
	RequestSuccessRate float64 `json:"requestSuccessRate"`

	// Performance statistics
	AverageRequestDuration time.Duration `json:"averageRequestDuration"`
	MaxRequestDuration     time.Duration `json:"maxRequestDuration"`
	MinRequestDuration     time.Duration `json:"minRequestDuration"`
	RequestsPerSecond      float64       `json:"requestsPerSecond"`

	// Memory statistics
	TotalMemoryAllocated int64 `json:"totalMemoryAllocated"`
	CurrentMemoryUsage   int64 `json:"currentMemoryUsage"`
	MaxMemoryUsage       int64 `json:"maxMemoryUsage"`

	// Buffer pool statistics
	BufferPoolStats BufferPoolStats `json:"bufferPoolStats"`

	// Runtime information
	Uptime        time.Duration `json:"uptime"`
	LastResetTime time.Time     `json:"lastResetTime"`

	// System memory info
	SystemMemoryStats runtime.MemStats `json:"systemMemoryStats"`
}

ResourceStats contains comprehensive resource usage statistics

type UploadConfig

type UploadConfig struct {
	// MaxObjectSize is the maximum size in bytes allowed for a single object
	// Default: 5 TiB (S3 specification limit)
	MaxObjectSize int64

	// MinPartSize is the minimum size in bytes for each part in a multipart upload
	// Default: 5 MiB (S3 specification minimum)
	MinPartSize uint64

	// MultipartThreshold is the size in bytes above which an upload automatically
	// switches to multipart mode for better performance
	// Default: 50 MiB
	MultipartThreshold int64

	// DefaultContentType is the default MIME type to use for uploaded objects
	DefaultContentType string
}

UploadConfig defines the configuration for upload constraints. These parameters control how objects are uploaded, particularly for large objects.

type WebhookNotification

type WebhookNotification struct {
	// Embed the common notification properties
	BaseNotification

	// Endpoint is the URL where webhook notifications will be sent
	Endpoint string

	// AuthToken is an optional token for authenticating with the webhook endpoint
	AuthToken string
}

WebhookNotification defines a webhook notification target. Webhook notifications send HTTP POST requests to a specified endpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL