writer

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileWriterChmod = 0600
	FileTypeTag     = "file"

	// Multi-threading the dump with one worker for each types
	// The number of workers is set to the number of differents entities (roles, pods, ...)
	// 1 thread per k8s object type to pull from the Kubernetes API
	// 0 means as many thread as k8s entity types (calculated by the dumper_pipeline)
	FileWriterWorkerNumber = 0
)
View Source
const (
	TarWriterChmod = 0600
	TarTypeTag     = "tar"

	// Multi-threading the dump with one worker for each types
	// The number of workers is set to the number of differents entities (roles, pods, ...)
	// 1 thread per k8s object type to pull from the Kubernetes API
	// 0 means as many thread as k8s entity types (calculated by the dumper_pipeline)
	TarWorkerNumber = 0
)
View Source
const (
	FSWriterChmod = 0600
)
View Source
const (
	WriterDirMod = 0700
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DumperWriter

type DumperWriter interface {
	Write(context.Context, []byte, string) error
	Flush(context.Context) error
	Close(context.Context) error

	// Multi-threading the dump with one worker for each types
	// The number of workers is set to 7 to have one thread per k8s object type to pull  fronm the Kubernetes API
	// Using single thread when zipping to avoid concurency issues
	WorkerNumber() int
	OutputPath() string
}

The DumperWriter handle multiple types of writer (file, tar, ...) It is used to centralized all writes and therefore handle all the files at once Some of the writers support multi-threading (WorkerNumber to retrieve the info)

func DumperWriterFactory

func DumperWriterFactory(ctx context.Context, compression bool, directoryPath string, resultName string) (DumperWriter, error)

type FSWriter

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

The FileWriter uses a map of buffers to write data to files Each file has its own buffer to optimize IO calls

func NewFSWriter

func NewFSWriter(ctx context.Context) (*FSWriter, error)

func (*FSWriter) Close

func (f *FSWriter) Close(ctx context.Context) error

func (*FSWriter) Flush

func (f *FSWriter) Flush(ctx context.Context) error

No flush needed for the file writer as we are flushing the buffer at every write

func (*FSWriter) WriteFile

func (f *FSWriter) WriteFile(ctx context.Context, pathObj string, k8sObj []byte) error

Write function writes the Kubernetes object to a buffer All buffer are stored in a map which is flushed at the end of every type processed

type FileWriter

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

The FileWriter uses a map of buffers to write data to files Each file has its own buffer to optimize IO calls

func NewFileWriter

func NewFileWriter(ctx context.Context, directoryOutput string) (*FileWriter, error)

func (*FileWriter) Close

func (f *FileWriter) Close(ctx context.Context) error

func (*FileWriter) Flush

func (f *FileWriter) Flush(ctx context.Context) error

No flush needed for the file writer as we are flushing the buffer at every write

func (*FileWriter) OutputPath

func (f *FileWriter) OutputPath() string

func (*FileWriter) WorkerNumber

func (f *FileWriter) WorkerNumber() int

func (*FileWriter) Write

func (f *FileWriter) Write(ctx context.Context, k8sObj []byte, pathObj string) error

Write function writes the Kubernetes object to a buffer All buffer are stored in a map which is flushed at the end of every type processed

type TarWriter

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

TarWriter keeps track of all handlers used to create the tar file The write occurs in memory and is flushed to the file at the end of the process

func NewTarWriter

func NewTarWriter(ctx context.Context, tarPath string) (*TarWriter, error)

func (*TarWriter) Close

func (t *TarWriter) Close(ctx context.Context) error

Close all the handler used to write the tar file Need to be closed only when all assets are dumped

func (*TarWriter) Flush

func (t *TarWriter) Flush(ctx context.Context) error

Flush function flushes all kubernetes object from the buffers to the tar file

func (*TarWriter) OutputPath

func (f *TarWriter) OutputPath() string

func (*TarWriter) WorkerNumber

func (f *TarWriter) WorkerNumber() int

func (*TarWriter) Write

func (t *TarWriter) Write(ctx context.Context, k8sObj []byte, filePath string) error

Write function writes the Kubernetes object to a buffer All buffer are stored in a map which is flushed at the end of every type processed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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