Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateNewBufFName(now time.Time, oldFName string) (string, error)
- func OpenBufFile(filepath string) (fp *os.File, err error)
- func PrepareDir(path string) error
- type BufFileStat
- type Data
- type DataDecoder
- type DataEncoder
- type IdsDecoder
- type IdsEncoder
- type Int64Set
- type Journal
- func (j *Journal) Flush() (err error)
- func (j *Journal) IsLegacyRunning() bool
- func (j *Journal) LoadLegacyBuf(data *Data) (err error)
- func (j *Journal) LoadMaxId() (int64, error)
- func (j *Journal) LockLegacy() bool
- func (j *Journal) RefreshLegacyLoader()
- func (j *Journal) Rotate() (err error)
- func (j *Journal) UnLockLegacy() bool
- func (j *Journal) WriteData(data *Data) (err error)
- func (j *Journal) WriteId(id int64) error
- type JournalConfig
- type LegacyLoader
- func (l *LegacyLoader) AddID(id int64)
- func (l *LegacyLoader) Clean() error
- func (l *LegacyLoader) Load(data *Data) (err error)
- func (l *LegacyLoader) LoadAllids(ids *Int64Set) (allErr error)
- func (l *LegacyLoader) LoadMaxId() (maxId int64, err error)
- func (l *LegacyLoader) Reset(dataFNames, idsFNames []string)
Constants ¶
View Source
const ( FileMode = 0664 DirMode = 0774 BufSize = 1024 * 1024 * 4 // 4 MB )
Variables ¶
View Source
var ( // DataFileNameReg journal data file name pattern DataFileNameReg = regexp.MustCompile(`\d{8}_\d{8}\.buf`) // IDFileNameReg journal id file name pattern IDFileNameReg = regexp.MustCompile(`\d{8}_\d{8}\.ids`) )
View Source
var (
DuringRotateErr = fmt.Errorf("during rotating")
)
Functions ¶
func GenerateNewBufFName ¶
GenerateNewBufFName return new buf file name depends on current time file name looks like `yyyymmddnnnn.ids`, nnnn begin from 0001 for each day
func OpenBufFile ¶
OpenBufFile create and open file
Types ¶
type BufFileStat ¶
type BufFileStat struct {
NewDataFp, NewIdsDataFp *os.File
OldDataFnames, OldIdsDataFname []string
}
BufFileStat current journal files' stats
func PrepareNewBufFile ¶
func PrepareNewBufFile(dirPath string, oldFsStat *BufFileStat, isScan bool) (ret *BufFileStat, err error)
PrepareNewBufFile create new data & id files, and update BufFileStat
type Data ¶
func (*Data) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type DataDecoder ¶
type DataDecoder struct {
// contains filtered or unexported fields
}
func NewDataDecoder ¶
func NewDataDecoder(fp *os.File) *DataDecoder
func (*DataDecoder) Read ¶
func (dec *DataDecoder) Read(data *Data) (err error)
type DataEncoder ¶
type DataEncoder struct {
// contains filtered or unexported fields
}
func NewDataEncoder ¶
func NewDataEncoder(fp *os.File) *DataEncoder
func (*DataEncoder) Flush ¶
func (enc *DataEncoder) Flush() error
func (*DataEncoder) Write ¶
func (enc *DataEncoder) Write(msg *Data) (err error)
type IdsDecoder ¶
type IdsDecoder struct {
// contains filtered or unexported fields
}
func NewIdsDecoder ¶
func NewIdsDecoder(fp *os.File) *IdsDecoder
func (*IdsDecoder) LoadMaxId ¶
func (dec *IdsDecoder) LoadMaxId() (maxId int64, err error)
func (*IdsDecoder) ReadAllToBmap ¶
func (dec *IdsDecoder) ReadAllToBmap() (ids *roaring.Bitmap, err error)
func (*IdsDecoder) ReadAllToInt64Set ¶ added in v1.3.0
func (dec *IdsDecoder) ReadAllToInt64Set(ids *Int64Set) (err error)
type IdsEncoder ¶
type IdsEncoder struct {
// contains filtered or unexported fields
}
func NewIdsEncoder ¶
func NewIdsEncoder(fp *os.File) *IdsEncoder
func (*IdsEncoder) Flush ¶
func (enc *IdsEncoder) Flush() error
func (*IdsEncoder) Write ¶
func (enc *IdsEncoder) Write(id int64) (err error)
type Int64Set ¶ added in v1.3.0
type Int64Set struct {
// contains filtered or unexported fields
}
func NewInt64Set ¶ added in v1.3.0
func NewInt64Set() *Int64Set
func (*Int64Set) CheckAndRemove ¶ added in v1.3.0
type Journal ¶
type Journal struct { *JournalConfig // contains filtered or unexported fields }
func NewJournal ¶
func NewJournal(cfg *JournalConfig) *Journal
func (*Journal) IsLegacyRunning ¶
func (*Journal) LoadLegacyBuf ¶
LoadLegacyBuf load legacy data one by one ⚠️Warn: should call `j.LockLegacy()` before invoke this method
func (*Journal) LockLegacy ¶
func (*Journal) RefreshLegacyLoader ¶
func (j *Journal) RefreshLegacyLoader()
RefreshLegacyLoader create or reset legacy loader
func (*Journal) UnLockLegacy ¶
type JournalConfig ¶
type LegacyLoader ¶
type LegacyLoader struct {
// contains filtered or unexported fields
}
func NewLegacyLoader ¶
func NewLegacyLoader(dataFNames, idsFNames []string) *LegacyLoader
func (*LegacyLoader) AddID ¶ added in v1.3.0
func (l *LegacyLoader) AddID(id int64)
func (*LegacyLoader) Clean ¶
func (l *LegacyLoader) Clean() error
func (*LegacyLoader) Load ¶
func (l *LegacyLoader) Load(data *Data) (err error)
func (*LegacyLoader) LoadAllids ¶
func (l *LegacyLoader) LoadAllids(ids *Int64Set) (allErr error)
func (*LegacyLoader) LoadMaxId ¶
func (l *LegacyLoader) LoadMaxId() (maxId int64, err error)
func (*LegacyLoader) Reset ¶
func (l *LegacyLoader) Reset(dataFNames, idsFNames []string)
Click to show internal directories.
Click to hide internal directories.