dataexporter

package
v1.59.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package dataexporter provides interfaces and implementations for exporting blockchain node data to cloud storage providers.

Index

Constants

View Source
const (
	GCS                   Provider = "gcs"
	CompositionBatchLimit int      = 32
)
View Source
const (
	DefaultSizeLimit      = "5TB"
	DefaultPartSize       = "500GB"
	DefaultChunkSize      = "250MB"
	DefaultBufferSize     = "32MB"
	DefaultReportPeriod   = time.Second
	DefaultConcurrentJobs = 10
)

Variables

This section is empty.

Functions

func GetDirSize

func GetDirSize(path string) (datasize.ByteSize, error)

GetDirSize calculates the total size of a directory and its contents.

Types

type DeleteOption

type DeleteOption func(*DeleteOptions)

DeleteOption is a functional option for configuring deletions.

func WithConcurrentDeleteJobs

func WithConcurrentDeleteJobs(concurrentJobs int) DeleteOption

WithConcurrentDeleteJobs sets the number of concurrent delete workers.

type DeleteOptions

type DeleteOptions struct {
	ConcurrentJobs int
}

DeleteOptions configures the behavior of data deletion from cloud storage.

type Exporter

type Exporter interface {
	// Provider returns the cloud storage provider type.
	Provider() Provider

	// Upload uploads a directory as a compressed tarball to the specified bucket.
	// The name parameter specifies the object name in the bucket.
	// Options can be provided to customize the upload behavior.
	Upload(dir, bucket, name string, opts ...UploadOption) error

	// Delete removes an object from the specified bucket.
	// Options can be provided to customize the delete behavior.
	Delete(bucket, name string, opts ...DeleteOption) error
}

Exporter provides methods to upload and delete data snapshots from cloud storage.

func FromProvider

func FromProvider(p Provider) (Exporter, error)

FromProvider creates an Exporter for the specified provider. Returns an error if the provider is not supported.

type GcsExporter

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

GcsExporter implements Exporter for Google Cloud Storage.

func NewGcsExporter

func NewGcsExporter() (*GcsExporter, error)

NewGcsExporter creates a new GCS exporter using application default credentials.

func (*GcsExporter) Delete

func (gcs *GcsExporter) Delete(bucket, name string, opts ...DeleteOption) error

func (*GcsExporter) Provider

func (gcs *GcsExporter) Provider() Provider

func (*GcsExporter) Upload

func (gcs *GcsExporter) Upload(dir, bucket, name string, opts ...UploadOption) error

type Provider

type Provider string

Provider identifies a cloud storage provider.

type UploadOption

type UploadOption func(*UploadOptions)

UploadOption is a functional option for configuring uploads.

func WithBufferSize

func WithBufferSize(size string) UploadOption

WithBufferSize sets the buffer size for upload operations.

func WithChunkSize

func WithChunkSize(size string) UploadOption

WithChunkSize sets the chunk size for uploads.

func WithConcurrentUploadJobs

func WithConcurrentUploadJobs(concurrentJobs int) UploadOption

WithConcurrentUploadJobs sets the number of concurrent upload workers.

func WithPartSize

func WithPartSize(size string) UploadOption

WithPartSize sets the part size for multi-part uploads.

func WithReportPeriod

func WithReportPeriod(period time.Duration) UploadOption

WithReportPeriod sets how often progress is reported.

func WithSizeLimit

func WithSizeLimit(size string) UploadOption

WithSizeLimit sets the maximum size before splitting into parts.

type UploadOptions

type UploadOptions struct {
	PartSize       datasize.ByteSize
	ChunkSize      datasize.ByteSize
	SizeLimit      datasize.ByteSize
	ReportPeriod   time.Duration
	ConcurrentJobs int
	BufferSize     datasize.ByteSize
}

UploadOptions configures the behavior of data uploads to cloud storage.

Jump to

Keyboard shortcuts

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