From 36f8931621ae202ac2163eb26e49dd3ff81ffc44 Mon Sep 17 00:00:00 2001 From: Ilja Neumann Date: Thu, 1 Oct 2020 13:21:42 +0200 Subject: [PATCH] Rename index package to indexer --- accounts/pkg/{index => indexer}/data_test.go | 2 +- accounts/pkg/{index => indexer}/errors.go | 2 +- .../{index/index.go => indexer/indexer.go} | 28 +++++++++---------- .../index_test.go => indexer/indexer_test.go} | 2 +- accounts/pkg/{index => indexer}/map.go | 4 +-- accounts/pkg/{index => indexer}/non_unique.go | 2 +- .../pkg/{index => indexer}/non_unique_test.go | 2 +- accounts/pkg/{index => indexer}/reflect.go | 2 +- accounts/pkg/{index => indexer}/unique.go | 4 +-- .../pkg/{index => indexer}/unique_test.go | 4 +-- 10 files changed, 26 insertions(+), 26 deletions(-) rename accounts/pkg/{index => indexer}/data_test.go (98%) rename accounts/pkg/{index => indexer}/errors.go (97%) rename accounts/pkg/{index/index.go => indexer/indexer.go} (69%) rename accounts/pkg/{index/index_test.go => indexer/indexer_test.go} (99%) rename accounts/pkg/{index => indexer}/map.go (88%) rename accounts/pkg/{index => indexer}/non_unique.go (99%) rename accounts/pkg/{index => indexer}/non_unique_test.go (99%) rename accounts/pkg/{index => indexer}/reflect.go (97%) rename accounts/pkg/{index => indexer}/unique.go (96%) rename accounts/pkg/{index => indexer}/unique_test.go (98%) diff --git a/accounts/pkg/index/data_test.go b/accounts/pkg/indexer/data_test.go similarity index 98% rename from accounts/pkg/index/data_test.go rename to accounts/pkg/indexer/data_test.go index a81e7bc2d0..fd024f4ebb 100644 --- a/accounts/pkg/index/data_test.go +++ b/accounts/pkg/indexer/data_test.go @@ -1,4 +1,4 @@ -package index +package indexer import ( "encoding/json" diff --git a/accounts/pkg/index/errors.go b/accounts/pkg/indexer/errors.go similarity index 97% rename from accounts/pkg/index/errors.go rename to accounts/pkg/indexer/errors.go index e8db526e49..2edea8c711 100644 --- a/accounts/pkg/index/errors.go +++ b/accounts/pkg/indexer/errors.go @@ -1,4 +1,4 @@ -package index +package indexer import ( "fmt" diff --git a/accounts/pkg/index/index.go b/accounts/pkg/indexer/indexer.go similarity index 69% rename from accounts/pkg/index/index.go rename to accounts/pkg/indexer/indexer.go index 356be85b55..020a3d7d3f 100644 --- a/accounts/pkg/index/index.go +++ b/accounts/pkg/indexer/indexer.go @@ -1,13 +1,13 @@ -// Package index provides symlink-based index for on-disk document-directories. -package index +// Package indexer provides symlink-based indexer for on-disk document-directories. +package indexer import ( "github.com/rs/zerolog" "path" ) -// Index is a facade to configure and query over multiple indices. -type Index struct { +// Indexer is a facade to configure and query over multiple indices. +type Indexer struct { config *Config indices indexMap } @@ -18,8 +18,8 @@ type Config struct { Log zerolog.Logger } -// IndexType can be implemented to create new index-strategies. See Unique for example. -// Each index implementation is bound to one data-column (IndexBy) and a data-type (TypeName) +// IndexType can be implemented to create new indexer-strategies. See Unique for example. +// Each indexer implementation is bound to one data-column (IndexBy) and a data-type (TypeName) type IndexType interface { Init() error Lookup(v string) ([]string, error) @@ -32,14 +32,14 @@ type IndexType interface { FilesDir() string } -func NewIndex(cfg *Config) *Index { - return &Index{ +func NewIndex(cfg *Config) *Indexer { + return &Indexer{ config: cfg, indices: indexMap{}, } } -func (i Index) AddUniqueIndex(t interface{}, indexBy, pkName, entityDirName string) error { +func (i Indexer) AddUniqueIndex(t interface{}, indexBy, pkName, entityDirName string) error { typeName := getTypeFQN(t) fullDataPath := path.Join(i.config.DataDir, entityDirName) indexPath := path.Join(i.config.DataDir, i.config.IndexRootDirName) @@ -50,7 +50,7 @@ func (i Index) AddUniqueIndex(t interface{}, indexBy, pkName, entityDirName stri return idx.Init() } -func (i Index) AddNonUniqueIndex(t interface{}, indexBy, pkName, entityDirName string) error { +func (i Indexer) AddNonUniqueIndex(t interface{}, indexBy, pkName, entityDirName string) error { typeName := getTypeFQN(t) fullDataPath := path.Join(i.config.DataDir, entityDirName) indexPath := path.Join(i.config.DataDir, i.config.IndexRootDirName) @@ -61,8 +61,8 @@ func (i Index) AddNonUniqueIndex(t interface{}, indexBy, pkName, entityDirName s return idx.Init() } -// Add a new entry to the index -func (i Index) Add(t interface{}) error { +// Add a new entry to the indexer +func (i Indexer) Add(t interface{}) error { typeName := getTypeFQN(t) fields, ok := i.indices[typeName] @@ -89,7 +89,7 @@ func (i Index) Add(t interface{}) error { // Find a entry by type,field and value. // // Find a User type by email // man.Find("User", "Email", "foo@example.com") -func (i Index) Find(typeName, key, value string) (pk string, err error) { +func (i Indexer) Find(typeName, key, value string) (pk string, err error) { var res = []string{} if indices, ok := i.indices[typeName][key]; ok { for _, idx := range indices { @@ -111,7 +111,7 @@ func (i Index) Find(typeName, key, value string) (pk string, err error) { } */ -func (i Index) Delete(typeName, pk string) error { +func (i Indexer) Delete(typeName, pk string) error { return nil } diff --git a/accounts/pkg/index/index_test.go b/accounts/pkg/indexer/indexer_test.go similarity index 99% rename from accounts/pkg/index/index_test.go rename to accounts/pkg/indexer/indexer_test.go index f6839a361c..b9f3e3e859 100644 --- a/accounts/pkg/index/index_test.go +++ b/accounts/pkg/indexer/indexer_test.go @@ -1,4 +1,4 @@ -package index +package indexer import ( "github.com/rs/zerolog" diff --git a/accounts/pkg/index/map.go b/accounts/pkg/indexer/map.go similarity index 88% rename from accounts/pkg/index/map.go rename to accounts/pkg/indexer/map.go index 54300974fc..024bb62cb6 100644 --- a/accounts/pkg/index/map.go +++ b/accounts/pkg/indexer/map.go @@ -1,6 +1,6 @@ -package index +package indexer -// indexMap stores the index layout at runtime. +// indexMap stores the indexer layout at runtime. type indexMap map[tName]typeMapping type tName = string diff --git a/accounts/pkg/index/non_unique.go b/accounts/pkg/indexer/non_unique.go similarity index 99% rename from accounts/pkg/index/non_unique.go rename to accounts/pkg/indexer/non_unique.go index 7046c4ddd0..e51f71a568 100644 --- a/accounts/pkg/index/non_unique.go +++ b/accounts/pkg/indexer/non_unique.go @@ -1,4 +1,4 @@ -package index +package indexer import ( "errors" diff --git a/accounts/pkg/index/non_unique_test.go b/accounts/pkg/indexer/non_unique_test.go similarity index 99% rename from accounts/pkg/index/non_unique_test.go rename to accounts/pkg/indexer/non_unique_test.go index 473604d018..b0abf61822 100644 --- a/accounts/pkg/index/non_unique_test.go +++ b/accounts/pkg/indexer/non_unique_test.go @@ -1,4 +1,4 @@ -package index +package indexer import ( "github.com/stretchr/testify/assert" diff --git a/accounts/pkg/index/reflect.go b/accounts/pkg/indexer/reflect.go similarity index 97% rename from accounts/pkg/index/reflect.go rename to accounts/pkg/indexer/reflect.go index 3775c2cafe..90036b3e19 100644 --- a/accounts/pkg/index/reflect.go +++ b/accounts/pkg/indexer/reflect.go @@ -1,4 +1,4 @@ -package index +package indexer import ( "errors" diff --git a/accounts/pkg/index/unique.go b/accounts/pkg/indexer/unique.go similarity index 96% rename from accounts/pkg/index/unique.go rename to accounts/pkg/indexer/unique.go index 685c8d4642..baaba43882 100644 --- a/accounts/pkg/index/unique.go +++ b/accounts/pkg/indexer/unique.go @@ -1,4 +1,4 @@ -package index +package indexer import ( "errors" @@ -11,7 +11,7 @@ import ( // Unique ensures that only one document of the same type and key-value combination can exist in the index. // -// Modeled by creating a index-folder per entity and key with symlinks which point to respective documents which contain +// Modeled by creating a indexer-folder per entity and key with symlinks which point to respective documents which contain // the link-filename as value. // // Directory Layout diff --git a/accounts/pkg/index/unique_test.go b/accounts/pkg/indexer/unique_test.go similarity index 98% rename from accounts/pkg/index/unique_test.go rename to accounts/pkg/indexer/unique_test.go index f9b4eb0e23..f7e0ed6e08 100644 --- a/accounts/pkg/index/unique_test.go +++ b/accounts/pkg/indexer/unique_test.go @@ -1,4 +1,4 @@ -package index +package indexer import ( "github.com/stretchr/testify/assert" @@ -114,7 +114,7 @@ func TestErrors(t *testing.T) { func getUniqueIdxSut(t *testing.T) (sut IndexType, dataPath string) { dataPath = writeIndexTestData(t, testData, "Id") - sut = NewUniqueIndex("User", "Email", path.Join(dataPath, "users"), path.Join(dataPath, "index.disk")) + sut = NewUniqueIndex("User", "Email", path.Join(dataPath, "users"), path.Join(dataPath, "indexer.disk")) err := sut.Init() if err != nil { t.Fatal(err)