Documentation
¶
Index ¶
- type BinloggerEncryptManager
- type EncryptedFile
- func (f *EncryptedFile) Close() error
- func (f *EncryptedFile) Lock() error
- func (f *EncryptedFile) Read(b []byte) (int, error)
- func (f *EncryptedFile) ReadAt(b []byte, off int64) (n int, err error)
- func (f *EncryptedFile) Seek(offset int64, whence int) (int64, error)
- func (f *EncryptedFile) Size() (int64, error)
- func (f *EncryptedFile) Unlock() error
- type FileReader
- type SegmentConverter
- type WalEncryptManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinloggerEncryptManager ¶
type BinloggerEncryptManager struct {
// contains filtered or unexported fields
}
BinloggerEncryptManager adapt binlog file encryption interface based on fileEncryptManager Added encryption logic for backward files at startup.
func NewBinloggerEncryptManager ¶
func NewBinloggerEncryptManager(path string, encryptor crypto.SymmetricKey, logger protocol.Logger) (*BinloggerEncryptManager, error)
NewBinloggerEncryptManager path: keep the same path as blockfiledb
func (BinloggerEncryptManager) Close ¶
func (m BinloggerEncryptManager) Close() error
Close close manager
func (*BinloggerEncryptManager) EncryptAsync ¶
func (m *BinloggerEncryptManager) EncryptAsync(segment string)
EncryptAsync Encrypts a segment file asynchronously. It will add the segment name to the filesToEncryptedCh channel, which will be processed in the processEncryptQueue goroutine.
func (*BinloggerEncryptManager) OpenFileReader ¶
func (m *BinloggerEncryptManager) OpenFileReader(path string) (FileReader, error)
OpenFileReader strictly speaking, you need to verify that the path is consistent with the path of BinloggerEncryptManager to prevent the file from being found or parsed incorrectly.
type EncryptedFile ¶
type EncryptedFile struct {
// contains filtered or unexported fields
}
EncryptedFile represents an encrypted file that implements the FileReader interface.
func (*EncryptedFile) Read ¶
func (f *EncryptedFile) Read(b []byte) (int, error)
Read reads the data. If the data has not been decrypted, decrypt it first and then read it.
func (*EncryptedFile) ReadAt ¶
func (f *EncryptedFile) ReadAt(b []byte, off int64) (n int, err error)
ReadAt reads the data. If the data has not been decrypted, decrypt it first and then read it.
func (*EncryptedFile) Seek ¶
func (f *EncryptedFile) Seek(offset int64, whence int) (int64, error)
Seek reposition the read position. Same as os.File seek behavior.
func (*EncryptedFile) Size ¶
func (f *EncryptedFile) Size() (int64, error)
Size returns the decrypted file size. If the file is not decrypted, decrypt it first.
type SegmentConverter ¶
type SegmentConverter interface { //NameToIndex convert segment name to index. NameToIndex(string) (uint64, error) //IndexToName convert segment index to name. IndexToName(uint64) string //NameIsValid check whether the segment name is a legal name. NameIsValid(string) bool }
SegmentConverter used to convert segment names and index names. The file encryption manager will record the index value of the encrypted file.
type WalEncryptManager ¶
type WalEncryptManager struct {
// contains filtered or unexported fields
}
WalEncryptManager wal file encrypt manager.
func NewWalEncryptManager ¶
func NewWalEncryptManager(path string, encryptor crypto.SymmetricKey, logger protocol.Logger) (*WalEncryptManager, error)
NewWalEncryptManager new wal encrypt manager
func (*WalEncryptManager) EncryptAsync ¶
func (m *WalEncryptManager) EncryptAsync(segment string)
EncryptAsync Encrypts a segment file asynchronously.
func (*WalEncryptManager) Read ¶
func (m *WalEncryptManager) Read(segFile string) ([]byte, error)
func (*WalEncryptManager) TruncateBack ¶
func (m *WalEncryptManager) TruncateBack(index uint64) error
TruncateBack for TruncateBack, the encryption index value needs to be moved to the index specified by the parameter, and then the files waiting to be encrypted are filtered that file index >= index no longer need to be encrypted.
func (*WalEncryptManager) TruncateFront ¶
func (m *WalEncryptManager) TruncateFront(index uint64) error
TruncateFront truncate操作和读文件存在一定的间隙,即虽然加密器知晓被truncate了,但不知道index对应的文件是否真正的是非加密的 所以在TruncateFront之后,需要保证调用者再次读取的时候,文件已经是非加密的了
Source Files
¶
- binlogger_encryptor.go
- file.go
- log_file_enctyptor.go
- wal_encryptor.go