services

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats bytes into human-readable format

func FormatSize

func FormatSize(bytes int64) string

FormatSize formats a size in bytes to human-readable format

func NewAgeService

func NewAgeService() interfaces.AgeService

NewAgeService creates a new age service instance

func NewBucketService

func NewBucketService(client *awsclient.S3Client) interfaces.BucketService

NewBucketService creates a new BucketService instance

func NewDryRunService

func NewDryRunService(costCalculator interfaces.CostCalculator) interfaces.DryRunService

NewDryRunService creates a new DryRunService instance

func NewExportService

func NewExportService() interfaces.ExportService

NewExportService creates a new ExportService instance

func NewOutputFormatter

func NewOutputFormatter() interfaces.OutputFormatter

NewOutputFormatter creates a new OutputFormatter instance

func NewUploadService

func NewUploadService(client *awsclient.S3Client, bucketService interfaces.BucketService, dryRunService interfaces.DryRunService) interfaces.UploadService

NewUploadService creates a new UploadService instance

func NewUploadServiceWithConcurrency

func NewUploadServiceWithConcurrency(client *awsclient.S3Client, bucketService interfaces.BucketService, dryRunService interfaces.DryRunService, concurrency int) interfaces.UploadService

NewUploadServiceWithConcurrency creates a new UploadService instance with custom concurrency

func NewUploadServiceWithOptions

func NewUploadServiceWithOptions(client *awsclient.S3Client, bucketService interfaces.BucketService, dryRunService interfaces.DryRunService, concurrency int, progressReporter ProgressReporter, confirmationReader io.Reader, outputWriter io.Writer) interfaces.UploadService

NewUploadServiceWithOptions creates a new UploadService instance with all options

func ParseSize

func ParseSize(sizeStr string) (int64, error)

ParseSize parses a human-readable size string to bytes

Types

type BucketService

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

BucketService implements the interfaces.BucketService interface

func (*BucketService) ClearRegionCache

func (s *BucketService) ClearRegionCache()

ClearRegionCache clears the region cache (useful for testing)

func (*BucketService) GetBucketRegion

func (s *BucketService) GetBucketRegion(ctx context.Context, bucketName string) (string, error)

GetBucketRegion retrieves the region for a specific bucket with caching

func (*BucketService) GetCacheStats

func (s *BucketService) GetCacheStats() map[string]interface{}

GetCacheStats returns cache statistics (useful for monitoring)

func (*BucketService) ListBuckets

func (s *BucketService) ListBuckets(ctx context.Context, region string) ([]pkgtypes.Bucket, error)

ListBuckets retrieves all accessible S3 buckets

func (*BucketService) ListBucketsInRegion

func (s *BucketService) ListBucketsInRegion(ctx context.Context, region string) ([]pkgtypes.Bucket, error)

ListBucketsInRegion retrieves buckets in a specific region

type ConsoleProgressReporter

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

ConsoleProgressReporter implements ProgressReporter for console output

func NewConsoleProgressReporter

func NewConsoleProgressReporter(writer io.Writer, quiet bool) *ConsoleProgressReporter

NewConsoleProgressReporter creates a new console progress reporter

func (*ConsoleProgressReporter) ReportCompletion

func (r *ConsoleProgressReporter) ReportCompletion(result DeletionResult)

ReportCompletion reports deletion completion to console

func (*ConsoleProgressReporter) ReportProgress

func (r *ConsoleProgressReporter) ReportProgress(progress DeletionProgress)

ReportProgress reports deletion progress to console

type CostService

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

CostService implements the CostCalculator interface

func NewCostService

func NewCostService() *CostService

NewCostService creates a new CostService with AWS S3 pricing data

func (*CostService) CalculateStorageCost

func (c *CostService) CalculateStorageCost(ctx context.Context, uploads []types.MultipartUpload) (types.CostBreakdown, error)

CalculateStorageCost calculates storage costs for uploads

func (*CostService) EstimateSavings

func (c *CostService) EstimateSavings(ctx context.Context, uploads []types.MultipartUpload) (float64, error)

EstimateSavings calculates potential cost savings from deletion

func (*CostService) GetRegionalPricing

func (c *CostService) GetRegionalPricing(ctx context.Context, region, storageClass string) (float64, error)

GetRegionalPricing retrieves pricing for a region and storage class

type DeletionError

type DeletionError struct {
	Upload pkgtypes.MultipartUpload
	Error  error
	Time   time.Time
}

DeletionError represents an error that occurred during deletion

type DeletionProgress

type DeletionProgress struct {
	TotalUploads      int
	ProcessedUploads  int64
	SuccessfulDeletes int64
	FailedDeletes     int64
	CurrentBucket     string
	StartTime         time.Time
	Errors            []DeletionError
}

DeletionProgress represents progress information for deletion operations

type DeletionResult

type DeletionResult struct {
	TotalProcessed    int
	SuccessfulDeletes int
	FailedDeletes     int
	StorageFreed      int64
	Duration          time.Duration
	Errors            []DeletionError
}

DeletionResult represents the result of a deletion operation

type DryRunService

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

DryRunService implements the interfaces.DryRunService interface

func (*DryRunService) GenerateFilename

func (d *DryRunService) GenerateFilename(command string, format string) string

GenerateFilename generates a filename for dry-run results

func (*DryRunService) SaveDryRunResult

func (d *DryRunService) SaveDryRunResult(result types.DryRunResult, filename string) error

SaveDryRunResult saves dry-run results to a file

func (*DryRunService) SimulateDeletion

func (d *DryRunService) SimulateDeletion(ctx context.Context, uploads []types.MultipartUpload, opts types.DeleteOptions) (types.DryRunResult, error)

SimulateDeletion simulates deletion without executing it

type ExportService

type ExportService struct{}

ExportService implements the interfaces.ExportService interface

func (*ExportService) ExportToCSV

func (e *ExportService) ExportToCSV(ctx context.Context, uploads []types.MultipartUpload, filename string) error

ExportToCSV exports uploads to CSV format

func (*ExportService) ExportToJSON

func (e *ExportService) ExportToJSON(ctx context.Context, uploads []types.MultipartUpload, filename string) error

ExportToJSON exports uploads to JSON format

func (*ExportService) GenerateExportFilename

func (e *ExportService) GenerateExportFilename(command string, format string) string

GenerateExportFilename generates a filename for export results

func (*ExportService) StreamExportToCSV

func (e *ExportService) StreamExportToCSV(ctx context.Context, uploads <-chan types.MultipartUpload, filename string) error

StreamExportToCSV exports large datasets to CSV with streaming

func (*ExportService) StreamExportToJSON

func (e *ExportService) StreamExportToJSON(ctx context.Context, uploads <-chan types.MultipartUpload, filename string) error

StreamExportToJSON exports large datasets to JSON with streaming

type OutputFormatter

type OutputFormatter struct{}

OutputFormatter implements the interfaces.OutputFormatter interface

func (*OutputFormatter) FormatAgeDistribution

func (f *OutputFormatter) FormatAgeDistribution(distribution types.AgeDistribution) string

FormatAgeDistribution formats age distribution for console output

func (*OutputFormatter) FormatCostBreakdown

func (f *OutputFormatter) FormatCostBreakdown(breakdown types.CostBreakdown) string

FormatCostBreakdown formats cost breakdown for console output

func (*OutputFormatter) FormatJSON

func (f *OutputFormatter) FormatJSON(data interface{}) (string, error)

FormatJSON formats any data structure as JSON

func (*OutputFormatter) FormatSizeReport

func (f *OutputFormatter) FormatSizeReport(report types.SizeReport) string

FormatSizeReport formats size report for console output

func (*OutputFormatter) FormatTable

func (f *OutputFormatter) FormatTable(headers []string, rows [][]string) string

FormatTable formats data as a table with headers and rows

func (*OutputFormatter) FormatUploads

func (f *OutputFormatter) FormatUploads(uploads []types.MultipartUpload, showDetails bool) string

FormatUploads formats uploads for human-readable console output

type ProgressReporter

type ProgressReporter interface {
	ReportProgress(progress DeletionProgress)
	ReportCompletion(result DeletionResult)
}

ProgressReporter defines the interface for reporting deletion progress

type S3ClientInterface

type S3ClientInterface interface {
	ListBuckets(ctx context.Context) (*s3.ListBucketsOutput, error)
	GetBucketLocation(ctx context.Context, bucket string) (*s3.GetBucketLocationOutput, error)
}

S3ClientInterface defines the S3 operations needed by BucketService

type S3UploadClientInterface

type S3UploadClientInterface interface {
	ListMultipartUploads(ctx context.Context, input *s3.ListMultipartUploadsInput) (*s3.ListMultipartUploadsOutput, error)
	ListParts(ctx context.Context, input *s3.ListPartsInput) (*s3.ListPartsOutput, error)
	AbortMultipartUpload(ctx context.Context, input *s3.AbortMultipartUploadInput) (*s3.AbortMultipartUploadOutput, error)
}

S3UploadClientInterface defines the S3 operations needed by UploadService

type SizeService

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

SizeService handles size calculation and reporting operations

func NewSizeService

func NewSizeService(uploadService interfaces.UploadService) *SizeService

NewSizeService creates a new SizeService instance

func NewSizeServiceWithConcurrency

func NewSizeServiceWithConcurrency(uploadService interfaces.UploadService, concurrency int) *SizeService

NewSizeServiceWithConcurrency creates a new SizeService instance with custom concurrency

func (*SizeService) CalculateBucketSizes

func (s *SizeService) CalculateBucketSizes(ctx context.Context, opts types.ListOptions) (*types.SizeReport, error)

CalculateBucketSizes calculates sizes grouped by bucket

func (*SizeService) CalculateTotalSize

func (s *SizeService) CalculateTotalSize(ctx context.Context, opts types.ListOptions) (*types.SizeReport, error)

CalculateTotalSize calculates the total size of all incomplete multipart uploads

func (*SizeService) GetSortedBucketSizes

func (s *SizeService) GetSortedBucketSizes(report *types.SizeReport) []interfaces.BucketSize

GetSortedBucketSizes returns bucket sizes sorted by size in descending order

func (*SizeService) GetStorageClassBreakdown

func (s *SizeService) GetStorageClassBreakdown(report *types.SizeReport) []interfaces.StorageClassSize

GetStorageClassBreakdown returns a formatted breakdown by storage class

type UploadService

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

UploadService implements the interfaces.UploadService interface

func (*UploadService) DeleteUpload

func (s *UploadService) DeleteUpload(ctx context.Context, upload pkgtypes.MultipartUpload) error

DeleteUpload deletes a specific multipart upload

func (*UploadService) DeleteUploads

func (s *UploadService) DeleteUploads(ctx context.Context, uploads []pkgtypes.MultipartUpload, opts pkgtypes.DeleteOptions) error

DeleteUploads deletes multiple uploads with options and safety features

func (*UploadService) GetUploadSize

func (s *UploadService) GetUploadSize(ctx context.Context, upload pkgtypes.MultipartUpload) (int64, error)

GetUploadSize calculates the size of an incomplete upload

func (*UploadService) ListUploads

ListUploads retrieves all incomplete multipart uploads

Jump to

Keyboard shortcuts

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