Documentation ¶
Index ¶
- Constants
- type File
- func (f *File) AppendData(ctx context.Context, buf []byte) error
- func (f *File) Close() error
- func (f *File) GetStartOffsetAndSize(ctx context.Context) (int64, int64, error)
- func (f *File) ReadAll(ctx context.Context) (int64, []byte, error)
- func (f *File) ReadAtWithMax(ctx context.Context, offset int64, maxSize int64) (int64, []byte, error)
- func (f *File) ReadMeta(ctx context.Context) error
- func (f *File) ReadNext(ctx context.Context, buf []byte, offset int64) (int64, int, error)
- func (f *File) WriteAt(ctx context.Context, buf []byte, writePos int64) error
- type Stat
Constants ¶
View Source
const CurrentVersion = 1
View Source
const FilePosEmpty = -1 // sentinel, if startpos is set to -1, file is empty
View Source
const FullHeaderFmt = "%-255s\n" // 256 bytes (255 + newline)
View Source
const HeaderFmt1 = "CBUF%02d %19d %19d %19d %19d\n" // 87 bytes
CBUF[version] [maxsize] [fileoffset] [startpos] [endpos]
View Source
const HeaderLen = 256 // set to 256 for future expandability
View Source
const InitialLockDelay = 10 * time.Millisecond
View Source
const InitialLockTries = 5
View Source
const LockDelay = 100 * time.Millisecond
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { OSFile *os.File Version byte MaxSize int64 FileOffset int64 StartPos int64 EndPos int64 FileDataSize int64 // size of data (does not include header size) FlockStatus int }
File objects are *not* multithread safe, operations must be externally synchronized
func CreateCirFile ¶
if the file already exists, it is an error. there is a race condition if two goroutines try to create the same file between Stat() and Create(), so
they both might get no error, but only one file will be valid. if this is a concern, this call should be externally synchronized.
func OpenCirFile ¶
does not read metadata because locking could block/fail. we want to be able to return a valid file struct without blocking.
func (*File) GetStartOffsetAndSize ¶
returns (fileOffset, datasize, error) datasize is the current amount of readable data held in the cirfile
func (*File) ReadAtWithMax ¶
Click to show internal directories.
Click to hide internal directories.