Skip to content

Commit

Permalink
feat: add Name() to expose DMap name
Browse files Browse the repository at this point in the history
  • Loading branch information
buraksezer committed Aug 14, 2021
1 parent 5b6fae6 commit 264bc4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type dmap struct {
storage *storage.Storage
}

// dmap represents a distributed map instance.
// DMap represents a distributed map instance.
type DMap struct {
name string
db *Olric
Expand All @@ -51,6 +51,11 @@ func (db *Olric) NewDMap(name string) (*DMap, error) {
}, nil
}

// Name exposes DMap name.
func (dm *DMap) Name() string {
return dm.name
}

// createDMap creates and returns a new dmap, internal representation of a dmap. This function is not thread-safe.
func (db *Olric) createDMap(part *partition, name string, str *storage.Storage) (*dmap, error) {
// create a new map here.
Expand Down
4 changes: 4 additions & 0 deletions dmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ func TestDMap_Standalone(t *testing.T) {
t.Fatalf("Expected value %v. Got: %v", value, val)
}

if d.Name() != d.name {
t.Fatalf("Expected DMap name: %s. Got: %s", d.name, d.Name())
}

// Delete it and check again.
err = d.Delete(key)
if err != nil {
Expand Down

0 comments on commit 264bc4f

Please sign in to comment.