slurpfiles

package module
v0.0.0-...-558eab5 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 5 Imported by: 0

README

slurp-files

Process files from SFTP backend. See the test for a complete example. To run the test use just.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Digest

func Digest(ctx context.Context, backend BackendFunc, handler *Handler) error

Digest runs the backend and invokes handler.OnFile on each file received.

Of all callbacks, only OnFile is required.

Types

type BackendFunc

type BackendFunc func(ctx context.Context, sink chan<- File) error

BackendFunc fetches files from its backend and sends them on the sink.

Implementations must close the channel when they are done and return.

func SFTPBackend

func SFTPBackend(client *sftp.Client, directory string) BackendFunc

SFTPBackend fetches files via SFTP.

type File

type File interface {
	io.Reader
	Name() string
}

File is the thing being processed.

type Handler

type Handler struct {
	// OnFile is invoked on any file encountered.
	OnFile OnFileFunc
	// OnSuccess is invoked once and only if no error occured.
	OnSuccess Thunk
	// OnCompletion is invoked once after all operations are complete and before OnSuccess.
	OnCompletion Thunk
}

Handler stores callbacks for use in Digest.

type OnFileFunc

type OnFileFunc func(ctx context.Context, file File) error

OnFileFunc processes file.

type Thunk

type Thunk func(ctx context.Context) error

Thunk is a callback for various, though purely side-effect reasons.

Jump to

Keyboard shortcuts

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