Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultMaxRAMUsageFraction = 0.50
DefaultMaxRAMUsageFraction is the default fraction of system RAM above which we'll force spooling to disk. For example, 0.5 = 50%.
View Source
const MaxInMemorySize = 1024 * 1024
MaxInMemorySize is the max number of bytes (currently 1MB) to hold in memory before starting to write to disk
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReadSeekCloser ¶
type ReadSeekCloser interface {
io.Reader
io.Seeker
ReaderAt
io.Closer
FileName() string
Len() int
}
ReadSeekCloser is an io.Reader + ReaderAt + io.Seeker + io.Closer + Stat
type ReadWriteSeekCloser ¶
type ReadWriteSeekCloser interface {
ReadSeekCloser
io.Writer
}
ReadWriteSeekCloser is an io.Writer + io.Reader + io.Seeker + io.Closer.
func NewSpooledTempFile ¶
func NewSpooledTempFile( filePrefix string, tempDir string, threshold int, fullOnDisk bool, maxRAMUsageFraction float64, ) ReadWriteSeekCloser
NewSpooledTempFile returns an ReadWriteSeekCloser, with some important constraints:
- You can Write into it, but whenever you call Read or Seek on it, subsequent Write calls will panic.
- If threshold is -1, then the default MaxInMemorySize is used.
- If maxRAMUsageFraction <= 0, we default to DefaultMaxRAMUsageFraction. E.g. 0.5 = 50%.
If the system memory usage is above maxRAMUsageFraction, we skip writing to memory and spool directly on disk to avoid OOM scenarios in high concurrency.
Click to show internal directories.
Click to hide internal directories.