Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { Upload(ctx context.Context, local, remote string, ctypeFunc ContentTypeInferenceFunction) error UploadPartOfFile(ctx context.Context, local io.ReadSeeker, start, length int64, remote, contentType string) error }
Backend is a common interface for a service that can upload log files somewhere
func NewCopyBackend ¶
NewCopyBackend creates a new instance of a copy uploader
func NewNoopBackend ¶
func NewNoopBackend() Backend
NewNoopBackend creates a new instance of a NoopBackend
type Config ¶
type Config struct { DisableUpload bool S3WriterRole string S3BucketName string S3PathPrefix string }
Config specifies the config for the uploader
type ContentTypeInferenceFunction ¶
ContentTypeInferenceFunction is the callback that can be used to set the mime type of a file at upload time
type CopyBackend ¶
type CopyBackend struct {
Dir string `json:"directory"`
}
CopyBackend is an uploader that just copies files to another location on the same host
func (*CopyBackend) Upload ¶
func (u *CopyBackend) Upload(ctx context.Context, local, remote string, ctypeFunc ContentTypeInferenceFunction) error
Upload copies a single file only!
func (*CopyBackend) UploadPartOfFile ¶
func (u *CopyBackend) UploadPartOfFile(ctx context.Context, local io.ReadSeeker, start, length int64, remote, contentType string) error
UploadPartOfFile copies a single file only. It doesn't preserve the cursor location in the file.
type NoopBackend ¶
type NoopBackend struct{}
NoopBackend is an uploader to be used when testing
func (*NoopBackend) Upload ¶
func (u *NoopBackend) Upload(ctx context.Context, local, remote string, ctypeFunc ContentTypeInferenceFunction) error
Upload does nothing (i.e., noop)
func (*NoopBackend) UploadPartOfFile ¶
func (u *NoopBackend) UploadPartOfFile(ctx context.Context, local io.ReadSeeker, start, length int64, remote, contentType string) error
UploadPartOfFile does nothing (i.e., noop)
type S3Backend ¶
type S3Backend struct {
// contains filtered or unexported fields
}
S3Backend uploads logs to S3
func (*S3Backend) UploadPartOfFile ¶
func (u *S3Backend) UploadPartOfFile(ctx context.Context, local io.ReadSeeker, start, length int64, remote, contentType string) error
UploadPartOfFile copies a single file only. It doesn't preserve the cursor location in the file.
type Uploader ¶
type Uploader struct {
// contains filtered or unexported fields
}
Wraps the backends used to do log uploading.
func NewUploader ¶
func NewUploader(config *config.Config, uploaderConfig *Config, iamRole string, taskID string, m metrics.Reporter) (*Uploader, error)
The upload always prefers s3, then copy, and will use a black hole sink if nothing else is configured. The first s3 location or copy destination specified is used. Rest are ignored.
func NewUploaderWithBackend ¶
func (*Uploader) Upload ¶
func (e *Uploader) Upload(ctx context.Context, local, remote string, ctypeFunc ContentTypeInferenceFunction) error
Upload uploads the file, or all the files in a directory to the remote location.
func (*Uploader) UploadPartOfFile ¶
func (e *Uploader) UploadPartOfFile(ctx context.Context, local io.ReadSeeker, start, length int64, remote, contentType string) error
UploadPartOfFile logs the call and forwards to the backend. It can upload a subset of a file. Offsets are not preserved.