MM-56402: Initialize replica conn pool on-demand (#26410)

Previously, we would setup both pools only when
GetMasterDB was called. This was inefficient and
would waste open connections if the replica wasn't used
at all.

We fix it to initialize the pools as they are called.

https://mattermost.atlassian.net/browse/MM-56402
```release-note
NONE
```

Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Этот коммит содержится в:
Agniva De Sarker
2024-03-08 13:11:48 +05:30
коммит произвёл GitHub
родитель bc887441d0
Коммит 89f5a0deec
2 изменённых файлов: 32 добавлений и 32 удалений

Просмотреть файл

@@ -12,18 +12,10 @@ import (
func TestStore(t *testing.T) {
t.Run("master db singleton", func(t *testing.T) {
config := &model.Config{
SqlSettings: model.SqlSettings{
DriverName: model.NewString("test"),
DataSource: model.NewString("TestStore-master-db"),
},
}
api := &plugintest.API{}
defer api.AssertExpectations(t)
api.On("GetUnsanitizedConfig").Return(config)
driver := &plugintest.Driver{}
defer driver.AssertExpectations(t)
driver.On("Conn", true).Return("test", nil)
driver.On("ConnPing", "test").Return(nil)
driver.On("ConnClose", "test").Return(nil)
@@ -52,6 +44,7 @@ func TestStore(t *testing.T) {
}
driver := &plugintest.Driver{}
defer driver.AssertExpectations(t)
driver.On("Conn", true).Return("test", nil)
driver.On("ConnPing", "test").Return(nil)
driver.On("ConnClose", "test").Return(nil)
@@ -88,7 +81,7 @@ func TestStore(t *testing.T) {
api.On("GetUnsanitizedConfig").Return(config)
driver := &plugintest.Driver{}
driver.On("Conn", true).Return("test", nil)
defer driver.AssertExpectations(t)
driver.On("Conn", false).Return("test", nil)
driver.On("ConnPing", "test").Return(nil)
driver.On("ConnClose", "test").Return(nil)