publish-vod/pkg/uploader/interface.go
Knut Ahlers 7ff74d6e1a
Do some refactoring, add limiting of uploaders
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-04-01 13:03:26 +02:00

40 lines
1.1 KiB
Go

// Package uploader defines the interface to implement when building
// uploaders
package uploader
import (
"context"
"io"
"github.com/Luzifer/go_helpers/v2/fieldcollection"
"github.com/cheggaaa/pb/v3"
)
type (
// Uploader defines the interface to implement on new uploaders
Uploader interface {
// Prepare is used to check authorizations, re-authorize uploaders
// and do preflight-checks in before the real upload is started
Prepare(ctx context.Context, opts Opts) error
// UploadFile is executed after Prepare and ValidateConfig and
// can concentrate on uploading the file to the respective target
UploadFile(ctx context.Context, opts Opts) error
// ValidateConfig is called before Prepare and UploadFile and
// must make sure the settings given are complete and valid
ValidateConfig(config *fieldcollection.FieldCollection) error
}
// Opts contains the require arguments for an Uploader
// to do its job
Opts struct {
Name string
Config *fieldcollection.FieldCollection
Filename string
Content io.Reader
Size int64
ProgressBar *pb.ProgressBar
FinalMessage func(format string, opts ...any)
}
)