Documentation ¶
Overview ¶
Package copier provides a mockable interface for network-transparent(ish) file copying, and implementations thereof.
Index ¶
- func CopyMapping(ctx context.Context, dst, src Copier, mapping map[string]string, o ...Observer) error
- func OnCopy(m Message, cos ...Observer)
- func OnCopyEnd(cos ...Observer)
- func OnCopyStart(nfiles int, cos ...Observer)
- func OnCopyStep(i int, dst, src string, cos ...Observer)
- func RecvMapping(ctx context.Context, src Copier, mapping map[string]string, o ...Observer) error
- func SendMapping(ctx context.Context, dst Copier, mapping map[string]string, o ...Observer) error
- type Copier
- type Local
- type Message
- type Observer
- type SFTP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyMapping ¶
func CopyMapping(ctx context.Context, dst, src Copier, mapping map[string]string, o ...Observer) error
CopyMapping copies the files in the (dest-to-src) map mapping from dst to src. It checks ctx for cancellation between operations.
func OnCopyEnd ¶
func OnCopyEnd(cos ...Observer)
OnCopyEnd sends an OnCopyEnd observation to multiple observers.
func OnCopyStart ¶
OnCopyStart sends an OnCopyStart observation to multiple observers.
func OnCopyStep ¶
OnCopyStep sends an OnCopyStep observation to multiple observers.
func RecvMapping ¶
RecvMapping is shorthand for CopyMapping where the source is a Local.
Types ¶
type Copier ¶
type Copier interface { // Create tries to create a file at path, and, if successful, opens a write-closer pointing to it. Create(path string) (io.WriteCloser, error) // Open tries to open a file at path, and, if successful, opens a read-closer pointing to it. Open(path string) (io.ReadCloser, error) // MkdirAll recursively makes the directories mentioned in dir. MkdirAll(dir string) error }
Copier provides a mockable interface for remote copying.
type Local ¶
type Local struct{}
Local implements Copier through os.
func (Local) Create ¶
func (l Local) Create(path string) (io.WriteCloser, error)
Create calls os.Create on path.
type Message ¶
type Message struct { observing.Batch // Dst is the name of the destination file, if we're on a step. Dst string `json:"dst,omitempty"` // Src is the name of the source file, if we're on a step. Src string `json:"src,omitempty"` }
Message is the type of copy observation messages.
type Observer ¶
type Observer interface { // OnCopy sends a copy observation message. OnCopy(Message) }
Observer is an interface for types that observe an SFTP file copy.
type SFTP ¶
SFTP wraps an sftp.Client to adapt it to the Copier interface.
func (*SFTP) Create ¶
func (s *SFTP) Create(path string) (io.WriteCloser, error)
Create wraps sftp.Client's Create in such a way as to implement Copier.