Browse Source

storage: Get -> ConsistentIndex in ConsistentIndexGetter

To make the method name more specific in the context.
Yicheng Qin 10 years ago
parent
commit
41cb39b68a
2 changed files with 4 additions and 4 deletions
  1. 3 3
      storage/consistent_watchable_store.go
  2. 1 1
      storage/kv_test.go

+ 3 - 3
storage/consistent_watchable_store.go

@@ -26,8 +26,8 @@ var (
 // ConsistentIndexGetter is an interface that wraps the Get method.
 // ConsistentIndexGetter is an interface that wraps the Get method.
 // Consistent index is the offset of an entry in a consistent replicated log.
 // Consistent index is the offset of an entry in a consistent replicated log.
 type ConsistentIndexGetter interface {
 type ConsistentIndexGetter interface {
-	// Get gets the consistent index of current executing entry.
-	Get() uint64
+	// ConsistentIndex returns the consistent index of current executing entry.
+	ConsistentIndex() uint64
 }
 }
 
 
 type consistentWatchableStore struct {
 type consistentWatchableStore struct {
@@ -80,7 +80,7 @@ func (s *consistentWatchableStore) TxnBegin() int64 {
 
 
 	// TODO: avoid this unnecessary allocation
 	// TODO: avoid this unnecessary allocation
 	bs := make([]byte, 8)
 	bs := make([]byte, 8)
-	binary.BigEndian.PutUint64(bs, s.ig.Get())
+	binary.BigEndian.PutUint64(bs, s.ig.ConsistentIndex())
 	// put the index into the underlying backend
 	// put the index into the underlying backend
 	// tx has been locked in TxnBegin, so there is no need to lock it again
 	// tx has been locked in TxnBegin, so there is no need to lock it again
 	s.watchableStore.store.tx.UnsafePut(metaBucketName, consistentIndexKeyName, bs)
 	s.watchableStore.store.tx.UnsafePut(metaBucketName, consistentIndexKeyName, bs)

+ 1 - 1
storage/kv_test.go

@@ -821,7 +821,7 @@ func TestWatchableKVWatch(t *testing.T) {
 
 
 type indexVal uint64
 type indexVal uint64
 
 
-func (v *indexVal) Get() uint64 { return uint64(*v) }
+func (v *indexVal) ConsistentIndex() uint64 { return uint64(*v) }
 
 
 func TestConsistentWatchableKVConsistentIndex(t *testing.T) {
 func TestConsistentWatchableKVConsistentIndex(t *testing.T) {
 	var idx indexVal
 	var idx indexVal