Documentation
¶
Index ¶
- Constants
- Variables
- func CreateFile(filename string, mode os.FileMode, uid, gid int) (*os.File, error)
- func Fileinfo(fi os.FileInfo) (uid, gid int)
- func MD5Hash(b []byte) string
- func MkdirAll(path string, mode os.FileMode, uid, gid int) error
- func OnceCloser(c io.Closer) io.Closer
- func ParseSnapshotPath(s string) (index int, err error)
- func ParseWALSegmentPath(s string) (index int, offset int64, err error)
- func TruncateDuration(d time.Duration) time.Duration
- func WriteFile(name string, data []byte, perm os.FileMode, uid, gid int) error
- type FileEvent
- type FileWatcher
- type InotifyFileWatcher
- type LockingBuffer
- func (b *LockingBuffer) Bytes() []byte
- func (b *LockingBuffer) Cap() int
- func (b *LockingBuffer) Grow(n int)
- func (b *LockingBuffer) Len() int
- func (b *LockingBuffer) Next(n int) []byte
- func (b *LockingBuffer) Read(p []byte) (n int, err error)
- func (b *LockingBuffer) ReadByte() (byte, error)
- func (b *LockingBuffer) ReadBytes(delim byte) (line []byte, err error)
- func (b *LockingBuffer) ReadFrom(r io.Reader) (n int64, err error)
- func (b *LockingBuffer) ReadRune() (r rune, size int, err error)
- func (b *LockingBuffer) ReadString(delim byte) (line string, err error)
- func (b *LockingBuffer) Reset()
- func (b *LockingBuffer) String() string
- func (b *LockingBuffer) Truncate(n int)
- func (b *LockingBuffer) UnreadByte() error
- func (b *LockingBuffer) UnreadRune() error
- func (b *LockingBuffer) Write(p []byte) (n int, err error)
- func (b *LockingBuffer) WriteByte(c byte) error
- func (b *LockingBuffer) WriteRune(r rune) (n int, err error)
- func (b *LockingBuffer) WriteString(s string) (n int, err error)
- func (b *LockingBuffer) WriteTo(w io.Writer) (n int64, err error)
- type MultiReadCloser
- type ReadCloser
- type ReadCounter
Constants ¶
const ( FileEventCreated = 1 << iota FileEventModified FileEventDeleted )
File event mask constants.
const ( MaxUint = ^uint(0) MaxInt = int(MaxUint >> 1) )
Platform-independent maximum integer sizes.
Variables ¶
var ( OperationTotalCounterVec = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "litestream_replica_operation_total", Help: "The number of replica operations performed", }, []string{"replica_type", "operation"}) OperationBytesCounterVec = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "litestream_replica_operation_bytes", Help: "The number of bytes used by replica operations", }, []string{"replica_type", "operation"}) )
Shared replica metrics.
var ErrFileEventQueueOverflow = errors.New("file event queue overflow")
ErrFileEventQueueOverflow is returned when the file event queue has overflowed.
Functions ¶
func CreateFile ¶ added in v0.3.5
CreateFile creates the file and matches the mode & uid/gid of fi.
func MkdirAll ¶ added in v0.3.5
MkdirAll is a copy of os.MkdirAll() except that it attempts to set the mode/uid/gid to match fi for each created directory.
func OnceCloser ¶
OnceCloser returns a closer that will only ignore duplicate closes.
func ParseSnapshotPath ¶
ParseSnapshotPath parses the index from a snapshot filename. Used by path-based replicas.
func ParseWALSegmentPath ¶
ParseWALSegmentPath parses the index/offset from a segment filename. Used by path-based replicas.
func TruncateDuration ¶
TruncateDuration truncates d to the nearest major unit (s, ms, µs, ns).
Types ¶
type FileWatcher ¶
type FileWatcher interface {
Open() error
Close() error
// Returns a channel of events for watched files.
Events() <-chan FileEvent
// Adds a specific file to be watched.
Watch(filename string) error
// Removes a specific file from being watched.
Unwatch(filename string) error
}
FileWatcher represents a watcher of file events.
func NewFileWatcher ¶
func NewFileWatcher() FileWatcher
NewFileWatcher returns an instance of InotifyFileWatcher on Linux systems.
type InotifyFileWatcher ¶
type InotifyFileWatcher struct {
// contains filtered or unexported fields
}
InotifyFileWatcher watches files and is notified of events on them.
Watcher code based on https://github.com/fsnotify/fsnotify
func NewInotifyFileWatcher ¶
func NewInotifyFileWatcher() *InotifyFileWatcher
NewInotifyFileWatcher returns a new instance of InotifyFileWatcher.
func (*InotifyFileWatcher) Close ¶
func (w *InotifyFileWatcher) Close() (err error)
Close stops watching for file events and cleans up resources.
func (*InotifyFileWatcher) Events ¶
func (w *InotifyFileWatcher) Events() <-chan FileEvent
Events returns a read-only channel of file events.
func (*InotifyFileWatcher) Open ¶
func (w *InotifyFileWatcher) Open() (err error)
Open initializes the watcher and begins listening for file events.
func (*InotifyFileWatcher) Unwatch ¶
func (w *InotifyFileWatcher) Unwatch(filename string) error
Unwatch stops watching the given file or directory.
func (*InotifyFileWatcher) Watch ¶
func (w *InotifyFileWatcher) Watch(filename string) error
Watch begins watching the given file or directory.
type LockingBuffer ¶
type LockingBuffer struct {
// contains filtered or unexported fields
}
LockingBuffer wraps a bytes.Buffer with a mutex.
func (*LockingBuffer) Bytes ¶
func (b *LockingBuffer) Bytes() []byte
func (*LockingBuffer) Cap ¶
func (b *LockingBuffer) Cap() int
func (*LockingBuffer) Grow ¶
func (b *LockingBuffer) Grow(n int)
func (*LockingBuffer) Len ¶
func (b *LockingBuffer) Len() int
func (*LockingBuffer) Next ¶
func (b *LockingBuffer) Next(n int) []byte
func (*LockingBuffer) ReadByte ¶
func (b *LockingBuffer) ReadByte() (byte, error)
func (*LockingBuffer) ReadBytes ¶
func (b *LockingBuffer) ReadBytes(delim byte) (line []byte, err error)
func (*LockingBuffer) ReadString ¶
func (b *LockingBuffer) ReadString(delim byte) (line string, err error)
func (*LockingBuffer) Reset ¶
func (b *LockingBuffer) Reset()
func (*LockingBuffer) String ¶
func (b *LockingBuffer) String() string
func (*LockingBuffer) Truncate ¶
func (b *LockingBuffer) Truncate(n int)
func (*LockingBuffer) UnreadByte ¶
func (b *LockingBuffer) UnreadByte() error
func (*LockingBuffer) UnreadRune ¶
func (b *LockingBuffer) UnreadRune() error
func (*LockingBuffer) WriteByte ¶
func (b *LockingBuffer) WriteByte(c byte) error
func (*LockingBuffer) WriteString ¶
func (b *LockingBuffer) WriteString(s string) (n int, err error)
type MultiReadCloser ¶
type MultiReadCloser struct {
// contains filtered or unexported fields
}
MultiReadCloser is a logical concatenation of io.ReadCloser. It works like io.MultiReader except all objects are closed when Close() is called.
func NewMultiReadCloser ¶
func NewMultiReadCloser(a []io.ReadCloser) *MultiReadCloser
NewMultiReadCloser returns a new instance of MultiReadCloser.
func (*MultiReadCloser) Close ¶
func (mrc *MultiReadCloser) Close() (err error)
Close closes all underlying ReadClosers and returns first error encountered.
type ReadCloser ¶
type ReadCloser struct {
// contains filtered or unexported fields
}
ReadCloser wraps a reader to also attach a separate closer.
func NewReadCloser ¶
func NewReadCloser(r io.Reader, c io.Closer) *ReadCloser
NewReadCloser returns a new instance of ReadCloser.
func (*ReadCloser) Close ¶
func (r *ReadCloser) Close() error
Close closes the reader (if implementing io.ReadCloser) and the Closer.
type ReadCounter ¶ added in v0.3.5
type ReadCounter struct {
// contains filtered or unexported fields
}
ReadCounter wraps an io.Reader and counts the total number of bytes read.
func NewReadCounter ¶ added in v0.3.5
func NewReadCounter(r io.Reader) *ReadCounter
NewReadCounter returns a new instance of ReadCounter that wraps r.
func (*ReadCounter) N ¶ added in v0.3.5
func (r *ReadCounter) N() int64
N returns the total number of bytes read.