Documentation ¶
Index ¶
- Variables
- func WithAtomic(opt *logOption)
- func WithSync(opt *logOption)
- type Batch
- type Log
- func (l *Log) Close() error
- func (l *Log) Flush() error
- func (l *Log) Read(segment, index uint64) (data []byte, err error)
- func (l *Log) RunSync(duration time.Duration) error
- func (l *Log) Segments() int
- func (l *Log) Sync() error
- func (l *Log) Truncate(n int) error
- func (l *Log) Write(data []byte, opts ...LogOpition) (int, error)
- func (l *Log) WriteBatch(b *Batch, opts ...LogOpition) (int, error)
- type LogOpition
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCorrupt = errors.New("log corrupt") ErrClosed = errors.New("log closed") ErrInvaildCRC = errors.New("invaild crc") ErrNotFound = errors.New("not found") ErrEOF = errors.New("end of file reached") ErrFailedLock = errors.New("failed to get file lock") )
View Source
var DefaultOptions = &Options{ NoSync: false, SyncDuration: time.Second, SegmentSize: 20971520, DirPerms: 0750, FilePerms: 0640, }
Functions ¶
func WithAtomic ¶
func WithAtomic(opt *logOption)
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log represents a append only log
func (*Log) WriteBatch ¶
func (l *Log) WriteBatch(b *Batch, opts ...LogOpition) (int, error)
type LogOpition ¶
type LogOpition func(*logOption)
type Options ¶
type Options struct { // NoSync disables fsync after writes. This is less durable and puts the // log at risk of data loss when there's a server crash. NoSync bool LoadAll bool SyncDuration time.Duration SegmentSize int // SegmentSize of each segment. Default is 20 MB. DirPerms os.FileMode FilePerms os.FileMode }
Click to show internal directories.
Click to hide internal directories.