Skip to content

Commit

Permalink
[dbnode] GetNamespaceFn returns public Namespace interface (#2696)
Browse files Browse the repository at this point in the history
  • Loading branch information
linasm authored Oct 6, 2020
1 parent ac2ef9b commit 47c219a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/dbnode/storage/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func (d *db) addNamespacesWithLock(namespaces []namespace.Metadata) error {

hooks := d.Options().NamespaceHooks()
for _, ns := range createdNamespaces {
err := hooks.OnCreatedNamespace(ns, d.namespaces.Get)
err := hooks.OnCreatedNamespace(ns, d.getNamespaceWithLock)
if err != nil {
return err
}
Expand All @@ -421,6 +421,10 @@ func (d *db) addNamespacesWithLock(namespaces []namespace.Metadata) error {
return nil
}

func (d *db) getNamespaceWithLock(id ident.ID) (Namespace, bool) {
return d.namespaces.Get(id)
}

func (d *db) newDatabaseNamespaceWithLock(
md namespace.Metadata,
) (databaseNamespace, error) {
Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/storage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1316,4 +1316,4 @@ type NamespaceHooks interface {
OnCreatedNamespace(Namespace, GetNamespaceFn) error
}

type GetNamespaceFn func (k ident.ID) (databaseNamespace, bool)
type GetNamespaceFn func (id ident.ID) (Namespace, bool)

0 comments on commit 47c219a

Please sign in to comment.