MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / GetLog

Method GetLog

lib/datastore/flydb.go:50–59  ·  view source on GitHub ↗

GetLog is a method on FlyDbStore that retrieves a log entry by its index

(index uint64, log *raft.Log)

Source from the content-addressed store, hash-verified

48
49// GetLog is a method on FlyDbStore that retrieves a log entry by its index
50func (fds *FlyDbStore) GetLog(index uint64, log *raft.Log) error {
51 val, err := fds.conn.Get(uint64ToBytes(index)) // Retrieve the log entry by index
52 if err != nil {
53 return err
54 }
55 if val == nil {
56 return raft.ErrLogNotFound // Return an error if the log entry is not found
57 }
58 return encoding.DecodeMessagePack(val, log) // Decode the log entry and assign it to the log variable
59}
60
61// StoreLog is a method on FlyDbStore that stores a single log entry
62func (fds *FlyDbStore) StoreLog(log *raft.Log) error {

Callers 15

TestRocksDbStore_GetLogFunction · 0.45
TestBoltDbStore_GetLogFunction · 0.45
TestBoltDbStore_StoreLogFunction · 0.45
TestInMemStore_GetLogFunction · 0.45
TestInMemStore_StoreLogFunction · 0.45
TestInMemStore_StoreLogsFunction · 0.45

Calls 3

DecodeMessagePackFunction · 0.92
uint64ToBytesFunction · 0.85
GetMethod · 0.65

Tested by 15

TestRocksDbStore_GetLogFunction · 0.36
TestBoltDbStore_GetLogFunction · 0.36
TestBoltDbStore_StoreLogFunction · 0.36
TestInMemStore_GetLogFunction · 0.36
TestInMemStore_StoreLogFunction · 0.36
TestInMemStore_StoreLogsFunction · 0.36