Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Path is the path to the chunk file.
// If the file does not exist, it will be created.
// If the file exists, it will be reloaded.
Path string
// ReadonlyAtFirst indicates whether the file should be readonly at first.
// If file of path does not exist, it cannot be true.
ReadonlyAtFirst bool
}
Config for a chunk file.
type Dependencies ¶
type Dependencies struct{}
type Factory ¶
type Factory component.Factory[File, Config, Dependencies]
--- Factory code block ---
func NewFactory ¶
func NewFactory(mockOn ...component.MockOption) Factory
type File ¶
type File interface {
component.Component
// EnsureReadonly ensures the file is readonly (can not Append).
// It should be fast when the file already is readonly.
// It will ensure the writeonly related resources are closed,
// and open the readonly related resources, such as mmap to save memory.
EnsureReadonly(ctx context.Context) (err error)
Count(ctx context.Context) (count uint32)
// Append appends feeds to the file.
// onSuccess is called when the feed is appended successfully (synchronously).
// The offset is the offset of the feed in the file.
// !!! It doesn't buffer the data between requests, so the caller should buffer the feeds to avoid high I/O.
Append(ctx context.Context, feeds []*Feed, onSuccess func(feed *Feed, offset uint64) error) (err error)
// Read reads a feed from the file.
Read(ctx context.Context, offset uint64) (feed *Feed, err error)
// Range ranges over all feeds in the file.
Range(ctx context.Context, iter func(feed *Feed, offset uint64) (err error)) (err error)
}
File is the interface for a chunk file. Concurrent safe.
Click to show internal directories.
Click to hide internal directories.