minio

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPort                = 9000
	DefaultAddress             = "localhost"
	DefaultRegion              = "us-east-1"
	DefaultBucket              = "icebox"
	DefaultAccessKey           = "minioadmin"
	DefaultSecretKey           = "minioadmin"
	DefaultMaxIdleConns        = 100
	DefaultMaxIdleConnsPerHost = 10
	DefaultConnectTimeout      = 30 * time.Second
	DefaultRequestTimeout      = 60 * time.Second
	DefaultReadTimeout         = 30 * time.Second
	DefaultWriteTimeout        = 60 * time.Second
	DefaultIdleTimeout         = 90 * time.Second
	DefaultTLSHandshakeTimeout = 10 * time.Second
	DefaultKeepAlive           = 30 * time.Second
	DefaultStartupTimeout      = 30 * time.Second
	DefaultShutdownTimeout     = 10 * time.Second
	DefaultHealthCheckInterval = 5 * time.Second
	DefaultRetryAttempts       = 3
	DefaultRetryDelay          = 100 * time.Millisecond
	DefaultBufferSize          = 64 * 1024        // 64KB
	MaxBufferSize              = 10 * 1024 * 1024 // 10MB
	MinSecretKeyLength         = 8
	MaxSecretKeyLength         = 40
	MaxObjectNameLength        = 1024
	MaxBucketNameLength        = 63
)

Constants for configuration and limits

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddedMinIO

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

EmbeddedMinIO represents an embedded MinIO server instance with enterprise features

func NewEmbeddedMinIO

func NewEmbeddedMinIO(config *EmbeddedMinIOConfig) (*EmbeddedMinIO, error)

NewEmbeddedMinIO creates a new embedded MinIO server instance with comprehensive configuration

func (*EmbeddedMinIO) GetActualURL added in v0.4.0

func (m *EmbeddedMinIO) GetActualURL() string

GetActualURL returns the actual server URL (for testing with fake server)

func (*EmbeddedMinIO) GetClient

func (m *EmbeddedMinIO) GetClient() *minio.Client

GetClient returns the MinIO client instance (thread-safe)

func (*EmbeddedMinIO) GetEndpoint

func (m *EmbeddedMinIO) GetEndpoint() string

GetEndpoint returns the MinIO server endpoint

func (*EmbeddedMinIO) GetFakeServer added in v0.4.0

func (m *EmbeddedMinIO) GetFakeServer() *httptest.Server

GetFakeServer returns the fake server for testing (internal use)

func (*EmbeddedMinIO) GetMetrics added in v0.4.0

func (m *EmbeddedMinIO) GetMetrics() *ServerMetrics

GetMetrics returns current server metrics

func (*EmbeddedMinIO) IsRunning

func (m *EmbeddedMinIO) IsRunning() bool

IsRunning returns whether the MinIO server is currently running (thread-safe)

func (*EmbeddedMinIO) Start

func (m *EmbeddedMinIO) Start(ctx context.Context) error

Start starts the embedded MinIO server with comprehensive error handling and monitoring

func (*EmbeddedMinIO) Stop

func (m *EmbeddedMinIO) Stop(ctx context.Context) error

Stop stops the embedded MinIO server gracefully with comprehensive cleanup

type EmbeddedMinIOConfig

type EmbeddedMinIOConfig struct {
	// Server configuration
	Port    int    `yaml:"port" json:"port"`         // Server port (default: 9000)
	Address string `yaml:"address" json:"address"`   // Bind address (default: localhost)
	DataDir string `yaml:"data_dir" json:"data_dir"` // Data directory for MinIO storage

	// Authentication
	AccessKey string `yaml:"access_key" json:"access_key"` // MinIO access key (default: minioadmin)
	SecretKey string `yaml:"secret_key" json:"secret_key"` // MinIO secret key (default: minioadmin)

	// Behavior
	AutoStart bool `yaml:"auto_start" json:"auto_start"` // Auto-start server with Icebox (default: true)
	Console   bool `yaml:"console" json:"console"`       // Enable MinIO console (default: false)
	Quiet     bool `yaml:"quiet" json:"quiet"`           // Suppress MinIO logs (default: true)

	// Security & Performance
	Secure bool `yaml:"secure" json:"secure"` // Use HTTPS (default: false for embedded)

	// TLS Configuration
	TLS *TLSConfig `yaml:"tls" json:"tls"` // TLS configuration

	// Advanced configuration
	Region        string            `yaml:"region" json:"region"`                 // Default region (default: us-east-1)
	DefaultBucket string            `yaml:"default_bucket" json:"default_bucket"` // Default bucket name (default: icebox)
	Properties    map[string]string `yaml:"properties" json:"properties"`         // Additional MinIO properties

	// Connection settings
	MaxIdleConns        int           `yaml:"max_idle_conns" json:"max_idle_conns"`                   // Max idle connections (default: 100)
	MaxIdleConnsPerHost int           `yaml:"max_idle_conns_per_host" json:"max_idle_conns_per_host"` // Max idle per host (default: 10)
	ConnectTimeout      time.Duration `yaml:"connect_timeout" json:"connect_timeout"`                 // Connection timeout (default: 30s)
	RequestTimeout      time.Duration `yaml:"request_timeout" json:"request_timeout"`                 // Request timeout (default: 60s)
	ReadTimeout         time.Duration `yaml:"read_timeout" json:"read_timeout"`                       // Read timeout (default: 30s)
	WriteTimeout        time.Duration `yaml:"write_timeout" json:"write_timeout"`                     // Write timeout (default: 60s)
	IdleTimeout         time.Duration `yaml:"idle_timeout" json:"idle_timeout"`                       // Idle timeout (default: 90s)
	TLSHandshakeTimeout time.Duration `yaml:"tls_handshake_timeout" json:"tls_handshake_timeout"`     // TLS handshake timeout (default: 10s)
	KeepAlive           time.Duration `yaml:"keep_alive" json:"keep_alive"`                           // Keep alive duration (default: 30s)

	// Operational settings
	StartupTimeout      time.Duration `yaml:"startup_timeout" json:"startup_timeout"`             // Server startup timeout (default: 30s)
	ShutdownTimeout     time.Duration `yaml:"shutdown_timeout" json:"shutdown_timeout"`           // Server shutdown timeout (default: 10s)
	HealthCheckInterval time.Duration `yaml:"health_check_interval" json:"health_check_interval"` // Health check interval (default: 5s)
	RetryAttempts       int           `yaml:"retry_attempts" json:"retry_attempts"`               // Retry attempts for operations (default: 3)
	RetryDelay          time.Duration `yaml:"retry_delay" json:"retry_delay"`                     // Base retry delay (default: 100ms)

	// Performance settings
	BufferSize    int  `yaml:"buffer_size" json:"buffer_size"`       // Buffer size for I/O operations (default: 64KB)
	EnableMetrics bool `yaml:"enable_metrics" json:"enable_metrics"` // Enable metrics collection (default: true)
	EnableTracing bool `yaml:"enable_tracing" json:"enable_tracing"` // Enable request tracing (default: false)

	// Security settings
	EnableCORS        bool     `yaml:"enable_cors" json:"enable_cors"`               // Enable CORS (default: false)
	AllowedOrigins    []string `yaml:"allowed_origins" json:"allowed_origins"`       // Allowed CORS origins
	EnableCompression bool     `yaml:"enable_compression" json:"enable_compression"` // Enable response compression (default: true)
}

EmbeddedMinIOConfig represents comprehensive configuration for embedded MinIO server

func DefaultMinIOConfig

func DefaultMinIOConfig() *EmbeddedMinIOConfig

DefaultMinIOConfig returns comprehensive default MinIO configuration

type FileSystemConfig added in v0.4.0

type FileSystemConfig struct {
	RetryAttempts     int           `yaml:"retry_attempts" json:"retry_attempts"`
	RetryDelay        time.Duration `yaml:"retry_delay" json:"retry_delay"`
	BufferSize        int           `yaml:"buffer_size" json:"buffer_size"`
	EnableMetrics     bool          `yaml:"enable_metrics" json:"enable_metrics"`
	EnableCompression bool          `yaml:"enable_compression" json:"enable_compression"`
	EnableChecksums   bool          `yaml:"enable_checksums" json:"enable_checksums"`
	MaxConcurrentOps  int           `yaml:"max_concurrent_ops" json:"max_concurrent_ops"`
	OperationTimeout  time.Duration `yaml:"operation_timeout" json:"operation_timeout"`
	EnableCaching     bool          `yaml:"enable_caching" json:"enable_caching"`
	CacheSize         int           `yaml:"cache_size" json:"cache_size"`
	CacheTTL          time.Duration `yaml:"cache_ttl" json:"cache_ttl"`
}

FileSystemConfig represents configuration for the MinIO filesystem

type FileSystemMetrics added in v0.4.0

type FileSystemMetrics struct {
	// Operation counts
	ReadOperations   int64 `json:"read_operations"`
	WriteOperations  int64 `json:"write_operations"`
	DeleteOperations int64 `json:"delete_operations"`
	ListOperations   int64 `json:"list_operations"`

	// Data transfer
	BytesRead    int64 `json:"bytes_read"`
	BytesWritten int64 `json:"bytes_written"`

	// Performance
	AvgReadLatency   int64 `json:"avg_read_latency_ms"`
	AvgWriteLatency  int64 `json:"avg_write_latency_ms"`
	AvgDeleteLatency int64 `json:"avg_delete_latency_ms"`

	// Errors
	ReadErrors    int64 `json:"read_errors"`
	WriteErrors   int64 `json:"write_errors"`
	DeleteErrors  int64 `json:"delete_errors"`
	NetworkErrors int64 `json:"network_errors"`
	TimeoutErrors int64 `json:"timeout_errors"`

	// Cache metrics (if enabled)
	CacheHits      int64 `json:"cache_hits"`
	CacheMisses    int64 `json:"cache_misses"`
	CacheEvictions int64 `json:"cache_evictions"`
	// contains filtered or unexported fields
}

FileSystemMetrics tracks filesystem operation metrics

type MinIOError added in v0.4.0

type MinIOError struct {
	Op      string
	Err     error
	Context map[string]interface{}
}

Error types for better error handling

func (*MinIOError) Error added in v0.4.0

func (e *MinIOError) Error() string

func (*MinIOError) Unwrap added in v0.4.0

func (e *MinIOError) Unwrap() error

type MinIOFileSystem

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

MinIOFileSystem implements iceberg FileIO interface with embedded MinIO backend

func NewMinIOFileSystem

func NewMinIOFileSystem(minioServer *EmbeddedMinIO, bucket, prefix string) (*MinIOFileSystem, error)

NewMinIOFileSystem creates a new MinIO-backed FileSystem with comprehensive configuration

func (*MinIOFileSystem) Create

func (fs *MinIOFileSystem) Create(location string) (icebergio.File, error)

Create creates a new file for writing to MinIO with enhanced buffering

func (*MinIOFileSystem) GetMetrics added in v0.4.0

func (fs *MinIOFileSystem) GetMetrics() *FileSystemMetrics

GetMetrics returns current filesystem metrics

func (*MinIOFileSystem) Open

func (fs *MinIOFileSystem) Open(location string) (icebergio.File, error)

Open opens a file for reading from MinIO with comprehensive error handling

func (*MinIOFileSystem) Remove

func (fs *MinIOFileSystem) Remove(location string) error

Remove removes a file from MinIO with retry logic

type ServerMetrics added in v0.4.0

type ServerMetrics struct {
	// Connection metrics
	ActiveConnections int64 `json:"active_connections"`
	TotalConnections  int64 `json:"total_connections"`
	FailedConnections int64 `json:"failed_connections"`
	ConnectionsPerSec int64 `json:"connections_per_sec"`

	// Request metrics
	TotalRequests      int64 `json:"total_requests"`
	SuccessfulRequests int64 `json:"successful_requests"`
	FailedRequests     int64 `json:"failed_requests"`
	RequestsPerSec     int64 `json:"requests_per_sec"`
	AvgResponseTime    int64 `json:"avg_response_time_ms"`

	// Data metrics
	BytesRead      int64 `json:"bytes_read"`
	BytesWritten   int64 `json:"bytes_written"`
	ObjectsCreated int64 `json:"objects_created"`
	ObjectsDeleted int64 `json:"objects_deleted"`
	ObjectsRead    int64 `json:"objects_read"`

	// Error metrics
	TimeoutErrors        int64 `json:"timeout_errors"`
	NetworkErrors        int64 `json:"network_errors"`
	AuthenticationErrors int64 `json:"authentication_errors"`
	AuthorizationErrors  int64 `json:"authorization_errors"`
	InternalErrors       int64 `json:"internal_errors"`

	// Performance metrics
	MemoryUsage int64   `json:"memory_usage_bytes"`
	DiskUsage   int64   `json:"disk_usage_bytes"`
	CPUUsage    float64 `json:"cpu_usage_percent"`

	// Health metrics
	Uptime            time.Duration `json:"uptime"`
	LastHealthCheck   time.Time     `json:"last_health_check"`
	HealthCheckStatus string        `json:"health_check_status"`
	// contains filtered or unexported fields
}

ServerMetrics tracks server operation metrics

type TLSConfig added in v0.4.0

type TLSConfig struct {
	CertFile           string `yaml:"cert_file" json:"cert_file"`                       // Path to certificate file
	KeyFile            string `yaml:"key_file" json:"key_file"`                         // Path to private key file
	CAFile             string `yaml:"ca_file" json:"ca_file"`                           // Path to CA certificate file
	InsecureSkipVerify bool   `yaml:"insecure_skip_verify" json:"insecure_skip_verify"` // Skip certificate verification
	MinVersion         string `yaml:"min_version" json:"min_version"`                   // Minimum TLS version (default: TLS 1.2)
	MaxVersion         string `yaml:"max_version" json:"max_version"`                   // Maximum TLS version
}

TLSConfig represents TLS configuration

type ValidationError added in v0.4.0

type ValidationError struct {
	Field   string
	Message string
	Value   interface{}
}

ValidationError represents configuration validation errors

func (*ValidationError) Error added in v0.4.0

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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