Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.
func CopyFile ¶
CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.
Types ¶
type TimeoutReader ¶
type TimeoutReader struct {
// contains filtered or unexported fields
}
TimeoutReader is a reader with read timeout
It is designed for those want to read some data from a stream, and the size of the data is unknown, but still want to pipe data to some destination.
func NewTimeoutReader ¶
func NewTimeoutReader(r io.Reader, chunkSize int) *TimeoutReader
NewTimeoutReader creates a new idle timeout reader
func (*TimeoutReader) Error ¶
func (t *TimeoutReader) Error() error
Error returns the error happened during reading in background
func (*TimeoutReader) ReadUntilTimeout ¶
func (t *TimeoutReader) ReadUntilTimeout(stop <-chan time.Time) (data []byte, isTimeout bool)
ReadUntilTimeout perform a read operation on buffered data, return a chunk of data if
the size of the buffered data has reached or maxed out the chunkSize, then the size of returned data chunk will be chunkSize
or
the stop signaled, but buffer is not full, will return all buffered data
func (*TimeoutReader) StartBackgroundReading ¶
func (t *TimeoutReader) StartBackgroundReading()
StartBackgroundReading until EOF or error returned, should be called in a goroutine other than the one you are reading
func (*TimeoutReader) WaitUntilHasData ¶
func (t *TimeoutReader) WaitUntilHasData(stopSig <-chan struct{}) bool
WaitUntilHasData is a helper function used to check if there is data available, to reduce actual call of ReadUntilTimeout when the timeout is a short duration