Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // spool is immutable, consumed tasks remains in spool. IsImmutable = withMutability(immutable) // spool is mutable, consumed tasks are removed IsMutable = withMutability(mutable) // spool fails on error WithStrict = withStrict(strict) // spool skips error, continue as warning WithSkipError = withStrict(skiperror) // spool files matching the pattern WithPattern = opts.ForName[Spool, string]("pattern") // output files with new extension WithFileExt = opts.ForName[Spool, string]("ext") )
Functions ¶
This section is empty.
Types ¶
type FileSystem ¶
type FileSystem interface {
fs.FS
Create(path string, attr *struct{}) (File, error)
Remove(path string) error
}
A FileSystem abstraction provides access to a hierarchical file system or sequence of files
Use https://github.com/fogfish/stream to implement FileSystem for local file system or AWS S3.
type Spool ¶
type Spool struct {
// contains filtered or unexported fields
}
func (*Spool) ForEach ¶
ForEach iterates over the files in the spool's reader using the provided walker. It applies the Spooler function f to each file that matches the spool's pattern (if set). Directories are skipped, and files not matching the pattern are ignored. The function returns an error if the regex compilation fails, walking encounters an error, or if applying the Spooler function fails for any file.
func (*Spool) Shard ¶ added in v1.3.5
func (spool *Spool) Shard( ctx context.Context, dir string, f func(context.Context, string, io.Reader) (string, error), ) error
Apply the shard function over each file in the reader filesystem. The shard function is given the file path and a reader for the input file, and returns the shard name for the output file. The output file is written to the writer filesystem with the same path, but prefixed with the shard name.
If the shard function returns an empty string, the file is skipped. After processing, if the spool is mutable, the original file is removed from the reader filesystem.
type Spooler ¶ added in v1.3.5
Spooler is a function applied to each file. It is given the file path, a reader for the input file and a writer for the output file.