Skip to content

Commit

Permalink
Merge pull request #183 from saeid-a/feat/store-GetRegion_byID
Browse files Browse the repository at this point in the history
Implement `GetRegionByID` function (#128)
  • Loading branch information
sjcsjc123 authored Jul 9, 2023
2 parents ee4c0ec + 9bab060 commit 127fac3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cluster/store/store.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package store

import (
"errors"
"github.com/ByteStorage/FlyDB/cluster/region"
"github.com/hashicorp/raft"
"sync"
Expand Down Expand Up @@ -37,6 +38,39 @@ type Store interface {
GetSize() int64
}

func (s *store) GetRegionByKey(key []byte) (*region.Region, error) {
panic("implement me")
}

func (s *store) GetRegionByID(id uint64) (*region.Region, error) {
s.mu.RLock()
defer s.mu.RUnlock()
if _, ok := s.regionList[id]; !ok {
return nil, errors.New("the specified region does not exist")
}
return s.regionList[id], nil
}

func (s *store) AddRegion(region *region.Region) error {
panic("implement me")
}

func (s *store) RemoveRegion(id uint64) error {
panic("implement me")
}

func (s *store) Split(region *region.Region, splitKey []byte) error {
panic("implement me")
}

func (s *store) Merge(regionA *region.Region, regionB *region.Region) error {
panic("implement me")
}

func (s *store) GetSize() int64 {
panic("implement me")
}

// newRaftNode creates a new raft node for the store.
func (s *store) newRaftNode() error {
// All new methods below can add other return values as needed, such as err
Expand Down
6 changes: 6 additions & 0 deletions cluster/store/store_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package store

import "testing"

func TestStore_GetRegionByID(t *testing.T) {
}

0 comments on commit 127fac3

Please sign in to comment.