upload

package
v1.41.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDataPartitionSize = 50000
	DefaultDataInterval      = time.Hour
	DefaultDataPrefix        = "data"
)

Variables

View Source
var (
	DefaultPathProvider = NewPathPartitionProvider()
	DefaultTimeNow      = time.Now
)

Functions

This section is empty.

Types

type Blob

type Blob struct {
	PhysicalAddress string
	RelativePath    bool
	Checksum        string
	Size            int64
	CreationDate    time.Time
}

func WriteBlob

func WriteBlob(ctx context.Context, adapter block.Adapter, bucketName, address string, body io.Reader, contentLength int64, opts block.PutOpts) (*Blob, error)

type PathPartitionProvider added in v0.84.0

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

PathPartitionProvider provides path by request to upload data. The provided path is built from '<prefix>/<partition>/<unique id>'. The partition is updated every interval or when the number of IDs generated passes the specified size.

func NewPathPartitionProvider added in v0.84.0

func NewPathPartitionProvider(opts ...PathProviderOption) *PathPartitionProvider

func (*PathPartitionProvider) NewPath added in v0.84.0

func (i *PathPartitionProvider) NewPath() string

NewPath returns a new upload path based on the current partition.

func (*PathPartitionProvider) ResolvePathTime added in v0.90.0

func (i *PathPartitionProvider) ResolvePathTime(address string) (time.Time, error)

type PathProvider added in v0.84.0

type PathProvider interface {
	NewPath() string
	// ResolvePathTime - get string parse it to xid and returns the timestamp part of it
	ResolvePathTime(address string) (time.Time, error)
}

PathProvider captures the requirements from PathPartitionProvider implementation to return a new path

type PathProviderConfig added in v0.84.0

type PathProviderConfig struct {
	Size     int
	Interval time.Duration
	Prefix   string
	TellTime TimeNow
}

type PathProviderOption added in v0.84.0

type PathProviderOption func(o *PathProviderConfig)

func WithPathProviderInterval added in v0.84.0

func WithPathProviderInterval(d time.Duration) PathProviderOption

func WithPathProviderPrefix added in v0.84.0

func WithPathProviderPrefix(p string) PathProviderOption

func WithPathProviderSize added in v0.84.0

func WithPathProviderSize(size int) PathProviderOption

func WithPathProviderTellTime added in v0.84.0

func WithPathProviderTellTime(t TimeNow) PathProviderOption

type TimeNow added in v0.84.0

type TimeNow func() time.Time

Jump to

Keyboard shortcuts

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