GetLog is a method on BoltDbStore that retrieves a log entry by its index
(index uint64, log *raft.Log)
| 108 | |
| 109 | // GetLog is a method on BoltDbStore that retrieves a log entry by its index |
| 110 | func (ds *BoltDbStore) GetLog(index uint64, log *raft.Log) error { |
| 111 | ds.mux.RLock() |
| 112 | defer ds.mux.RUnlock() |
| 113 | tx, err := ds.conn.Begin(false) // Start a read-only transaction |
| 114 | if err != nil { |
| 115 | return err |
| 116 | } |
| 117 | defer check(tx.Rollback) |
| 118 | |
| 119 | bucket := tx.Bucket(bucketLogs) // Get the logs bucket |
| 120 | val := bucket.Get(uint64ToBytes(index)) // Retrieve the log entry by index |
| 121 | |
| 122 | if val == nil { |
| 123 | return raft.ErrLogNotFound // Return an error if the log entry is not found |
| 124 | } |
| 125 | return encoding.DecodeMessagePack(val, log) // Decode the log entry and assign it to the log variable |
| 126 | } |
| 127 | |
| 128 | // StoreLog is a method on BoltDbStore that stores a single log entry |
| 129 | func (ds *BoltDbStore) StoreLog(log *raft.Log) error { |
nothing calls this directly
no test coverage detected