filesystem

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package filesystem utilities for read and write files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilenameFunc

type FilenameFunc func() string

FilenameFunc provide a wrapper to implement a Filenamer with just a func()string

func (FilenameFunc) Filename

func (f FilenameFunc) Filename([]byte) string

Filename return a filename to be opened by worker

type Filenamer

type Filenamer interface {
	Filename(msg []byte) string
}

Filenamer is used to provide an easy way to generate dynamic files name to reader/writer msg is readed from input chanel in Process

type Reader

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

Reader for every message received it call Filenamer.Filename(msg) to get a filename to open a given file, then read it until eof or context is cancelled

func NewReader

func NewReader(opts ReaderOptions) *Reader

NewReader create a new reader with goven options

func (*Reader) Process

func (r *Reader) Process(ctx context.Context, args selina.ProcessArgs) (err error)

Process see selina.Worker

type ReaderOptions

type ReaderOptions struct {
	Fs        afero.Fs
	SplitFunc bufio.SplitFunc
	Filename  Filenamer
	Handler   selina.ErrorHandler
}

ReaderOptions configuration for Reader worker

type Writer

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

func NewWriter

func NewWriter(opts WriterOptions) *Writer

NewWriter create a new writer with given options

func (Writer) Process

func (w Writer) Process(ctx context.Context, args selina.ProcessArgs) (err error)

Process implents selina.Worker interface

type WriterOptions

type WriterOptions struct {
	Filename   Filenamer
	Fs         afero.Fs
	AddNewLine bool
	BufferSize int
	Mode       os.FileMode
	Handler    selina.ErrorHandler
}

WriterOptions configuration for a Writer worker

Jump to

Keyboard shortcuts

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