From 359bdc33635781588c0e564cb2cf5a9bc8125740 Mon Sep 17 00:00:00 2001 From: Akash Chetty Date: Wed, 9 Nov 2022 17:22:27 +0530 Subject: [PATCH 1/7] chore(warehouse): added support for bigquery custom partition for workspaaceIDs --- warehouse/bigquery/bigquery.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/warehouse/bigquery/bigquery.go b/warehouse/bigquery/bigquery.go index e4bb40fa9a..bb3a8aed03 100644 --- a/warehouse/bigquery/bigquery.go +++ b/warehouse/bigquery/bigquery.go @@ -26,6 +26,7 @@ var ( isUsersTableDedupEnabled bool isDedupEnabled bool enableDeleteByJobs bool + customPartitionsEnabledWorkspaceIDs []string ) type HandleT struct { @@ -300,12 +301,12 @@ func (bq *HandleT) loadTable(tableName string, _, getLoadFileLocFromTableUploads loadTableByAppend := func() (err error) { stagingLoadTable.partitionDate = time.Now().Format("2006-01-02") - outputTable := tableName + outputTable := partitionedTable(tableName, stagingLoadTable.partitionDate) // Tables created by RudderStack are ingestion-time partitioned table with pseudo column named _PARTITIONTIME. BigQuery automatically assigns rows to partitions based // on the time when BigQuery ingests the data. To support custom field partitions, omitting loading into partitioned table like tableName$20191221 // TODO: Support custom field partition on users & identifies tables - if !customPartitionsEnabled { - outputTable = partitionedTable(tableName, stagingLoadTable.partitionDate) + if customPartitionsEnabled || misc.Contains(customPartitionsEnabledWorkspaceIDs, bq.warehouse.WorkspaceID) { + outputTable = tableName } loader := bq.db.Dataset(bq.namespace).Table(outputTable).LoaderFrom(gcsRef) @@ -656,6 +657,7 @@ func loadConfig() { config.RegisterBoolConfigVariable(false, &isUsersTableDedupEnabled, true, "Warehouse.bigquery.isUsersTableDedupEnabled") // TODO: Deprecate with respect to isDedupEnabled config.RegisterBoolConfigVariable(false, &isDedupEnabled, true, "Warehouse.bigquery.isDedupEnabled") config.RegisterBoolConfigVariable(false, &enableDeleteByJobs, true, "Warehouse.bigquery.enableDeleteByJobs") + config.RegisterStringSliceConfigVariable(nil, &customPartitionsEnabledWorkspaceIDs, true, "Warehouse.bigquery.customPartitionsEnabledWorkspaceIDs") } func Init() { From 991a433b950d99e0bc72ac7d9caeb6a070c04afe Mon Sep 17 00:00:00 2001 From: Akash Chetty Date: Thu, 10 Nov 2022 14:36:35 +0530 Subject: [PATCH 2/7] added test cases. --- config/load.go | 18 ++++ warehouse/bigquery/bigquery_test.go | 160 +++++++++++++++++++--------- 2 files changed, 125 insertions(+), 53 deletions(-) diff --git a/config/load.go b/config/load.go index 6a826fa8a6..1ff1e31e73 100644 --- a/config/load.go +++ b/config/load.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "reflect" "time" "github.com/fsnotify/fsnotify" @@ -161,6 +162,23 @@ func (c *Config) checkAndHotReloadConfig(configMap map[string][]*configValue) { fmt.Printf("The value of key:%s & variable:%p changed from %v to %v\n", key, configVal, *value, _value) *value = _value } + case *[]string: + var _value []string + var isSet bool + for _, key := range configVal.keys { + if c.IsSet(key) { + isSet = true + _value = c.GetStringSlice(key, configVal.defaultValue.([]string)) + break + } + } + if !isSet { + _value = configVal.defaultValue.([]string) + } + if !reflect.DeepEqual(_value, *value) { + fmt.Printf("The value of key:%s & variable:%p changed from %v to %v\n", key, configVal, *value, _value) + *value = _value + } } } } diff --git a/warehouse/bigquery/bigquery_test.go b/warehouse/bigquery/bigquery_test.go index b11da1be9c..79551dd5ad 100644 --- a/warehouse/bigquery/bigquery_test.go +++ b/warehouse/bigquery/bigquery_test.go @@ -8,6 +8,7 @@ import ( "log" "os" "testing" + "time" backendconfig "github.com/rudderlabs/rudder-server/config/backend-config" @@ -25,14 +26,7 @@ import ( "github.com/stretchr/testify/assert" ) -type TestHandle struct { - DB *bigquery.Client - WriteKey string - Schema string - Tables []string -} - -var handle *TestHandle +type TestHandle struct{} func (*TestHandle) VerifyConnection() error { credentials, err := testhelper.BigqueryCredentials() @@ -40,7 +34,7 @@ func (*TestHandle) VerifyConnection() error { return err } return testhelper.WithConstantBackoff(func() (err error) { - handle.DB, err = bigquery2.Connect(context.TODO(), &credentials) + _, err = bigquery2.Connect(context.TODO(), &credentials) if err != nil { err = fmt.Errorf("could not connect to warehouse bigquery with error: %s", err.Error()) return @@ -50,10 +44,23 @@ func (*TestHandle) VerifyConnection() error { } func TestBigQueryIntegration(t *testing.T) { + credentials, err := testhelper.BigqueryCredentials() + require.NoError(t, err) + + var ( + schema = testhelper.Schema(warehouseutils.BQ, testhelper.BigqueryIntegrationTestSchema) + writeKey = "J77aX7tLFJ84qYU6UrN8ctecwZt" + tables = []string{"identifies", "users", "tracks", "product_track", "pages", "screens", "aliases", "_groups", "groups"} + db *bigquery.Client + ) + + db, err = bigquery2.Connect(context.TODO(), &credentials) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, testhelper.WithConstantBackoff(func() (err error) { - return handle.DB.Dataset(handle.Schema).DeleteWithContents(context.TODO()) - }), fmt.Sprintf("Failed dropping dataset %s for BigQuery", handle.Schema)) + return db.Dataset(schema).DeleteWithContents(context.TODO()) + }), fmt.Sprintf("Failed dropping dataset %s for BigQuery", schema)) }) t.Run("Merge Mode", func(t *testing.T) { @@ -66,12 +73,12 @@ func TestBigQueryIntegration(t *testing.T) { warehouseTest := &testhelper.WareHouseTest{ Client: &client.Client{ - BQ: handle.DB, + BQ: db, Type: client.BQClient, }, - WriteKey: handle.WriteKey, - Schema: handle.Schema, - Tables: handle.Tables, + WriteKey: writeKey, + Schema: schema, + Tables: tables, MessageId: uuid.Must(uuid.NewV4()).String(), Provider: warehouseutils.BQ, SourceID: "24p1HhPk09FW25Kuzxv7GshCLKR", @@ -112,47 +119,99 @@ func TestBigQueryIntegration(t *testing.T) { }) t.Run("Append Mode", func(t *testing.T) { - require.NoError(t, testhelper.SetConfig([]warehouseutils.KeyValue{ + testCases := []struct { + name string + customPartitionsEnabledWorkspaceIDs []string + prerequisite func(t *testing.T) + }{ { - Key: "Warehouse.bigquery.isDedupEnabled", - Value: false, + name: "Append mode without custom partitions", }, - })) - - warehouseTest := &testhelper.WareHouseTest{ - Client: &client.Client{ - BQ: handle.DB, - Type: client.BQClient, + { + name: "Append mode with custom partitions", + customPartitionsEnabledWorkspaceIDs: []string{"BpLnfgDsc2WD8F2qNfHK5a84jjJ"}, + prerequisite: func(t *testing.T) { + err = db.Dataset(schema).Create(context.Background(), &bigquery.DatasetMetadata{ + Location: "US", + }) + require.NoError(t, err) + + err = db.Dataset(schema).Table("tracks").Create( + context.Background(), + &bigquery.TableMetadata{ + Schema: []*bigquery.FieldSchema{{ + Name: "timestamp", + Type: bigquery.DateFieldType, + }}, + TimePartitioning: &bigquery.TimePartitioning{ + Field: "timestamp", + Expiration: 90 * 24 * time.Hour, + }, + }) + require.NoError(t, err) + }, }, - WriteKey: handle.WriteKey, - Schema: handle.Schema, - Tables: handle.Tables, - MessageId: uuid.Must(uuid.NewV4()).String(), - Provider: warehouseutils.BQ, - SourceID: "24p1HhPk09FW25Kuzxv7GshCLKR", - DestinationID: "26Bgm9FrQDZjvadSwAlpd35atwn", } - // Scenario 1 - warehouseTest.TimestampBeforeSendingEvents = timeutil.Now() - warehouseTest.UserId = testhelper.GetUserId(warehouseutils.BQ) - - sendEventsMap := testhelper.SendEventsMap() - testhelper.SendEvents(t, warehouseTest, sendEventsMap) - testhelper.SendIntegratedEvents(t, warehouseTest, sendEventsMap) - testhelper.SendModifiedEvents(t, warehouseTest, sendEventsMap) - testhelper.SendModifiedEvents(t, warehouseTest, sendEventsMap) - - testhelper.VerifyEventsInStagingFiles(t, warehouseTest, testhelper.StagingFilesEventsMap()) - testhelper.VerifyEventsInLoadFiles(t, warehouseTest, loadFilesEventsMap()) - testhelper.VerifyEventsInTableUploads(t, warehouseTest, tableUploadsEventsMap()) - testhelper.VerifyEventsInWareHouse(t, warehouseTest, appendEventsMap()) - - testhelper.VerifyWorkspaceIDInStats(t) + for _, tc := range testCases { + tc := tc + + t.Run(tc.name, func(t *testing.T) { + _ = db.Dataset(schema).DeleteWithContents(context.TODO()) + + if tc.prerequisite != nil { + tc.prerequisite(t) + } + + require.NoError(t, testhelper.SetConfig([]warehouseutils.KeyValue{ + { + Key: "Warehouse.bigquery.isDedupEnabled", + Value: false, + }, + { + Key: "Warehouse.bigquery.customPartitionsEnabledWorkspaceIDs", + Value: tc.customPartitionsEnabledWorkspaceIDs, + }, + })) + + warehouseTest := &testhelper.WareHouseTest{ + Client: &client.Client{ + BQ: db, + Type: client.BQClient, + }, + WriteKey: writeKey, + Schema: schema, + Tables: tables, + MessageId: uuid.Must(uuid.NewV4()).String(), + Provider: warehouseutils.BQ, + SourceID: "24p1HhPk09FW25Kuzxv7GshCLKR", + DestinationID: "26Bgm9FrQDZjvadSwAlpd35atwn", + } + + // Scenario 1 + warehouseTest.TimestampBeforeSendingEvents = timeutil.Now() + warehouseTest.UserId = testhelper.GetUserId(warehouseutils.BQ) + + sendEventsMap := testhelper.SendEventsMap() + testhelper.SendEvents(t, warehouseTest, sendEventsMap) + testhelper.SendIntegratedEvents(t, warehouseTest, sendEventsMap) + testhelper.SendModifiedEvents(t, warehouseTest, sendEventsMap) + testhelper.SendModifiedEvents(t, warehouseTest, sendEventsMap) + + testhelper.VerifyEventsInStagingFiles(t, warehouseTest, testhelper.StagingFilesEventsMap()) + testhelper.VerifyEventsInLoadFiles(t, warehouseTest, loadFilesEventsMap()) + testhelper.VerifyEventsInTableUploads(t, warehouseTest, tableUploadsEventsMap()) + testhelper.VerifyEventsInWareHouse(t, warehouseTest, appendEventsMap()) + + testhelper.VerifyWorkspaceIDInStats(t) + }) + } }) } func TestBigQueryConfigurationValidation(t *testing.T) { + t.Skip() + configurations := testhelper.PopulateTemplateConfigurations() bqCredentials, err := testhelper.BigqueryCredentials() require.NoError(t, err) @@ -233,10 +292,5 @@ func TestMain(m *testing.M) { return } - handle = &TestHandle{ - WriteKey: "J77aX7tLFJ84qYU6UrN8ctecwZt", - Schema: testhelper.Schema(warehouseutils.BQ, testhelper.BigqueryIntegrationTestSchema), - Tables: []string{"identifies", "users", "tracks", "product_track", "pages", "screens", "aliases", "_groups", "groups"}, - } - os.Exit(testhelper.Run(m, handle)) + os.Exit(testhelper.Run(m, &TestHandle{})) } From a1d8a9f981af1f6f361f8c180ee569548410a741 Mon Sep 17 00:00:00 2001 From: Akash Chetty Date: Thu, 10 Nov 2022 15:15:21 +0530 Subject: [PATCH 3/7] some more changes. --- warehouse/bigquery/bigquery_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/warehouse/bigquery/bigquery_test.go b/warehouse/bigquery/bigquery_test.go index 79551dd5ad..d174ffd9f8 100644 --- a/warehouse/bigquery/bigquery_test.go +++ b/warehouse/bigquery/bigquery_test.go @@ -8,7 +8,6 @@ import ( "log" "os" "testing" - "time" backendconfig "github.com/rudderlabs/rudder-server/config/backend-config" @@ -141,11 +140,10 @@ func TestBigQueryIntegration(t *testing.T) { &bigquery.TableMetadata{ Schema: []*bigquery.FieldSchema{{ Name: "timestamp", - Type: bigquery.DateFieldType, + Type: bigquery.TimestampFieldType, }}, TimePartitioning: &bigquery.TimePartitioning{ - Field: "timestamp", - Expiration: 90 * 24 * time.Hour, + Field: "timestamp", }, }) require.NoError(t, err) From dd391f3675ca34960b048e96222684510c6b64f4 Mon Sep 17 00:00:00 2001 From: Akash Chetty Date: Thu, 10 Nov 2022 15:39:14 +0530 Subject: [PATCH 4/7] review comments. --- go.mod | 4 ++-- go.sum | 4 ++++ warehouse/bigquery/bigquery.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 39b67b6f34..1128b85efb 100644 --- a/go.mod +++ b/go.mod @@ -193,8 +193,8 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be // indirect - golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect - golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect + golang.org/x/exp v0.0.0-20221109205753-fc8884afc316 // indirect + golang.org/x/sys v0.1.0 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index 4e92408caa..36d0734b71 100644 --- a/go.sum +++ b/go.sum @@ -1095,6 +1095,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= +golang.org/x/exp v0.0.0-20221109205753-fc8884afc316 h1:FedCSp0+vayF11p3wAQndIgu+JTcW2nLp5M+HSefjlM= +golang.org/x/exp v0.0.0-20221109205753-fc8884afc316/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1277,6 +1279,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI= golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= diff --git a/warehouse/bigquery/bigquery.go b/warehouse/bigquery/bigquery.go index bb3a8aed03..7c4270c47f 100644 --- a/warehouse/bigquery/bigquery.go +++ b/warehouse/bigquery/bigquery.go @@ -8,12 +8,14 @@ import ( "time" "cloud.google.com/go/bigquery" + "github.com/rudderlabs/rudder-server/config" "github.com/rudderlabs/rudder-server/utils/googleutils" "github.com/rudderlabs/rudder-server/utils/logger" "github.com/rudderlabs/rudder-server/utils/misc" "github.com/rudderlabs/rudder-server/warehouse/client" warehouseutils "github.com/rudderlabs/rudder-server/warehouse/utils" + "golang.org/x/exp/slices" "google.golang.org/api/googleapi" "google.golang.org/api/iterator" "google.golang.org/api/option" @@ -305,7 +307,7 @@ func (bq *HandleT) loadTable(tableName string, _, getLoadFileLocFromTableUploads // Tables created by RudderStack are ingestion-time partitioned table with pseudo column named _PARTITIONTIME. BigQuery automatically assigns rows to partitions based // on the time when BigQuery ingests the data. To support custom field partitions, omitting loading into partitioned table like tableName$20191221 // TODO: Support custom field partition on users & identifies tables - if customPartitionsEnabled || misc.Contains(customPartitionsEnabledWorkspaceIDs, bq.warehouse.WorkspaceID) { + if customPartitionsEnabled || slices.Contains(customPartitionsEnabledWorkspaceIDs, bq.warehouse.WorkspaceID) { outputTable = tableName } From fa1c50fe92e7a0beef9757d30f48770e9fdae527 Mon Sep 17 00:00:00 2001 From: Akash Chetty Date: Thu, 10 Nov 2022 16:59:07 +0530 Subject: [PATCH 5/7] some more changes --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1128b85efb..66b88ec6e6 100644 --- a/go.mod +++ b/go.mod @@ -193,7 +193,7 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be // indirect - golang.org/x/exp v0.0.0-20221109205753-fc8884afc316 // indirect + golang.org/x/exp v0.0.0-20221109205753-fc8884afc316 golang.org/x/sys v0.1.0 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect From dc1c1c9a3db02cc1378275e53419a7d7b1391b57 Mon Sep 17 00:00:00 2001 From: Akash Chetty Date: Thu, 10 Nov 2022 17:03:13 +0530 Subject: [PATCH 6/7] some more changes --- go.sum | 4 ---- 1 file changed, 4 deletions(-) diff --git a/go.sum b/go.sum index 36d0734b71..7f0e28cb5e 100644 --- a/go.sum +++ b/go.sum @@ -1093,8 +1093,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= -golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/exp v0.0.0-20221109205753-fc8884afc316 h1:FedCSp0+vayF11p3wAQndIgu+JTcW2nLp5M+HSefjlM= golang.org/x/exp v0.0.0-20221109205753-fc8884afc316/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= @@ -1277,8 +1275,6 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= From 0b94588b68399a1efbde9c990c4815a2b666f6d6 Mon Sep 17 00:00:00 2001 From: Akash Chetty Date: Thu, 10 Nov 2022 20:16:42 +0530 Subject: [PATCH 7/7] review comments --- config/load.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/load.go b/config/load.go index 1ff1e31e73..94b1e8a0e2 100644 --- a/config/load.go +++ b/config/load.go @@ -2,9 +2,10 @@ package config import ( "fmt" - "reflect" "time" + "golang.org/x/exp/slices" + "github.com/fsnotify/fsnotify" "github.com/joho/godotenv" "github.com/spf13/viper" @@ -175,7 +176,7 @@ func (c *Config) checkAndHotReloadConfig(configMap map[string][]*configValue) { if !isSet { _value = configVal.defaultValue.([]string) } - if !reflect.DeepEqual(_value, *value) { + if slices.Compare(_value, *value) != 0 { fmt.Printf("The value of key:%s & variable:%p changed from %v to %v\n", key, configVal, *value, _value) *value = _value }