delivery

package
v0.0.0-...-272cb90 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadTarget = fmt.Errorf("bad delivery target")
View Source
var ErrSrcFileNotExist = fmt.Errorf("source file does not exist")

Functions

func Deliver

func Deliver(ctx context.Context, path string, s Source, d Destination) (string, error)

target may end up being a type

func RegisterAllSourcesAndDestinations

func RegisterAllSourcesAndDestinations(ctx context.Context, appConfig appconfig.AppConfig) (err error)

Eventually, this can take a more generic list of deliverer configuration object

func RegisterDestination

func RegisterDestination(name string, d Destination)

func RegisterSource

func RegisterSource(name string, s Source)

Types

type AzureDestination

type AzureDestination struct {
	ToClient *container.Client
	Target   string
}

func NewAzureDestination

func NewAzureDestination(ctx context.Context, target string) (*AzureDestination, error)

func (*AzureDestination) Health

func (*AzureDestination) Upload

func (ad *AzureDestination) Upload(ctx context.Context, path string, r io.Reader, m map[string]string) (string, error)

type AzureSource

type AzureSource struct {
	FromContainerClient *container.Client
	Prefix              string
}

func (*AzureSource) GetMetadata

func (ad *AzureSource) GetMetadata(ctx context.Context, tuid string) (map[string]string, error)

func (*AzureSource) Reader

func (ad *AzureSource) Reader(ctx context.Context, path string) (io.Reader, error)

type Destination

type Destination interface {
	Upload(context.Context, string, io.Reader, map[string]string) (string, error)
}

func GetDestination

func GetDestination(name string) (Destination, bool)

type FileDestination

type FileDestination struct {
	appconfig.LocalStorageConfig
	Target string
}

func NewFileDestination

func NewFileDestination(_ context.Context, target string, appConfig *appconfig.AppConfig) (*FileDestination, error)

func (*FileDestination) Health

func (*FileDestination) Upload

func (fd *FileDestination) Upload(_ context.Context, id string, r io.Reader, m map[string]string) (string, error)

type FileSource

type FileSource struct {
	FS fs.FS
}

func (*FileSource) GetMetadata

func (fd *FileSource) GetMetadata(_ context.Context, tuid string) (map[string]string, error)

func (*FileSource) Reader

func (fd *FileSource) Reader(_ context.Context, path string) (io.Reader, error)

type PathInfo

type PathInfo struct {
	Year     string
	Month    string
	Day      string
	UploadId string
	Filename string
}

type S3Destination

type S3Destination struct {
	ToClient   *s3.Client
	BucketName string
	Target     string
}

func NewS3Destination

func NewS3Destination(ctx context.Context, target string, conn *appconfig.S3StorageConfig) (*S3Destination, error)

func (*S3Destination) Health

func (sd *S3Destination) Health(ctx context.Context) (rsp models.ServiceHealthResp)

func (*S3Destination) Upload

func (sd *S3Destination) Upload(ctx context.Context, path string, r io.Reader, m map[string]string) (string, error)

type S3Source

type S3Source struct {
	FromClient *s3.Client
	BucketName string
	Prefix     string
}

func (*S3Source) GetMetadata

func (ss *S3Source) GetMetadata(ctx context.Context, tuid string) (map[string]string, error)

func (*S3Source) Reader

func (ss *S3Source) Reader(ctx context.Context, path string) (io.Reader, error)

type Source

type Source interface {
	Reader(context.Context, string) (io.Reader, error)
	GetMetadata(context.Context, string) (map[string]string, error)
}

func GetSource

func GetSource(name string) (Source, bool)

Jump to

Keyboard shortcuts

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