Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type TransactionWriter ¶
type TransactionWriter struct { io.WriteCloser // contains filtered or unexported fields }
TransactionWriter implements a tranasactional, file-backed io.WriteCloser. Calls to Write() are captured in a temporary file, which will replace the target file path only upon Commit().
func NewTransactionWriter ¶
func NewTransactionWriter(fs afero.Fs, path string) (*TransactionWriter, error)
NewTransactionWriter returns a TransactionWriter implementing io.WritCloser. The caller is responsible for calling either Abort() or Commit(). If Commit() is not called, the target file is not created/replaced.
func (*TransactionWriter) Abort ¶
func (tw *TransactionWriter) Abort() error
Abort aborts an in-progress transaction and cleans up any temporary files. This method is safe to call multiple times. Not currently thread-safe.
func (*TransactionWriter) Commit ¶
func (tw *TransactionWriter) Commit() error
Commit commits an in-progress transaction and cleans up any temporary files. This method is safe to call multiple times. Not currently thread-safe.