From 2f2906c3eea217f21755d3ee06b586366f44ef4a Mon Sep 17 00:00:00 2001 From: George MacRorie Date: Mon, 6 Apr 2020 14:24:10 +0100 Subject: [PATCH] feat(kv): enable reading from URM by user index --- CHANGELOG.md | 1 + kv/service.go | 11 +++-------- kv/urm_test.go | 12 ------------ 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85a626cf5b6..56dc1c8e7ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ 1. [17490](https://github.com/influxdata/influxdb/pull/17490): `influx config -`, to switch back to previous activated configuration 1. [17581](https://github.com/influxdata/influxdb/pull/17581): Introduce new navigation menu 1. [17595](https://github.com/influxdata/influxdb/pull/17595): Add -f (--file) option to `influx query` and `influx task` commands +1. [17618](https://github.com/influxdata/influxdb/pull/17618): Add index for URM by user ID to improve lookup performance ### Bug Fixes diff --git a/kv/service.go b/kv/service.go index dbc8c179b40..41822bf9018 100644 --- a/kv/service.go +++ b/kv/service.go @@ -79,7 +79,7 @@ func NewService(log *zap.Logger, kv Store, configs ...ServiceConfig) *Service { id, _ := urm.UserID.Encode() return id, nil }, - )), + ), WithIndexReadPathEnabled), disableAuthorizationsForMaxPermissions: func(context.Context) bool { return false }, @@ -115,18 +115,13 @@ func NewService(log *zap.Logger, kv Store, configs ...ServiceConfig) *Service { s.clock = clock.New() } - if s.Config.URMByUserIndexReadPathEnabled { - WithIndexReadPathEnabled(s.urmByUserIndex) - } - return s } // ServiceConfig allows us to configure Services type ServiceConfig struct { - SessionLength time.Duration - Clock clock.Clock - URMByUserIndexReadPathEnabled bool + SessionLength time.Duration + Clock clock.Clock } // AutoMigrationStore is a Store which also describes whether or not diff --git a/kv/urm_test.go b/kv/urm_test.go index 3a41fcc9d08..e09cd5e987c 100644 --- a/kv/urm_test.go +++ b/kv/urm_test.go @@ -28,22 +28,10 @@ func TestBoltUserResourceMappingService(t *testing.T) { influxdbtesting.UserResourceMappingService(initURMServiceFunc(NewTestBoltStore), t) } -func TestBoltUserResourceMappingService_WithUserIndex(t *testing.T) { - influxdbtesting.UserResourceMappingService(initURMServiceFunc(NewTestBoltStore, kv.ServiceConfig{ - URMByUserIndexReadPathEnabled: true, - }), t) -} - func TestInmemUserResourceMappingService(t *testing.T) { influxdbtesting.UserResourceMappingService(initURMServiceFunc(NewTestBoltStore), t) } -func TestInmemUserResourceMappingService_WithUserIndex(t *testing.T) { - influxdbtesting.UserResourceMappingService(initURMServiceFunc(NewTestBoltStore, kv.ServiceConfig{ - URMByUserIndexReadPathEnabled: true, - }), t) -} - type userResourceMappingTestFunc func(influxdbtesting.UserResourceFields, *testing.T) (influxdb.UserResourceMappingService, func()) func initURMServiceFunc(storeFn func(*testing.T) (kv.Store, func(), error), confs ...kv.ServiceConfig) userResourceMappingTestFunc {