From 47c219a96038b9704d66b9c4abe7ea7266ffbcfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Med=C5=BEi=C5=ABnas?= Date: Tue, 6 Oct 2020 13:31:37 +0300 Subject: [PATCH] [dbnode] GetNamespaceFn returns public Namespace interface (#2696) --- src/dbnode/storage/database.go | 6 +++++- src/dbnode/storage/types.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dbnode/storage/database.go b/src/dbnode/storage/database.go index d46355e398..99dc96e2c3 100644 --- a/src/dbnode/storage/database.go +++ b/src/dbnode/storage/database.go @@ -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 } @@ -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) { diff --git a/src/dbnode/storage/types.go b/src/dbnode/storage/types.go index 004503d005..ac4252b24c 100644 --- a/src/dbnode/storage/types.go +++ b/src/dbnode/storage/types.go @@ -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)