processor

package
v0.0.0-...-0bc2699 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CTimeGetter

type CTimeGetter interface {
	GetCTime(fi fs.File) (time.Time, error)
}

CTimeGetter defines the interface required to get the change time from a FileInfo object.

type Checksum

type Checksum uint32

Checksum defines a CRC32 checksum as an unsigned 32-bit integer.

type File

type File struct {
	Key       string
	LocalPath string
	Checksum  Checksum
	CTime     time.Time
	Bucket    string
	ETag      string
	Version   string
}

File encapsulates all information associated with a file.

type KeyGenerator

type KeyGenerator interface {
	GenerateKey() string
}

KeyGenerator defines the interface required to generate a random key.

type Option

type Option func(*Processor)

Option is the type used to implement the functional options pattern for the Processor type.

func WithCTimeGetter

func WithCTimeGetter(ctg CTimeGetter) Option

WithCTimeGetter returns an option for setting the way in which a Processor gets the ctime from a FileInfo object.

func WithKeyGenerator

func WithKeyGenerator(kg KeyGenerator) Option

WithKeyGenerator returns an option for setting the way in which a Processor generates a key for a new file.

type Processor

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

Processor encapsulates the logic required to create a file and store it in the file store.

func New

func New(fs fs.FS, uploader Uploader, registry Registry, opts ...Option) *Processor

New instantiates a new Processor instance with provided file store and registry.

func (*Processor) Process

func (p *Processor) Process(ctx context.Context, path string) (*File, error)

Process creates a file from the provided path and uploads it to the store.

type Registry

type Registry interface {
	Create(ctx context.Context, file *File) (*File, error)
	FetchLatest(ctx context.Context, path string) (*File, error)
}

Registry specifies the interface required to register and update the registry of uploaded files.

type Uploader

type Uploader interface {
	Upload(ctx context.Context, file *File) (*File, error)
}

Uploader specifies the interface required to upload files.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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