Migrate Plugin.List to Sync by default (#11582)
Этот коммит содержится в:
коммит произвёл
Saturnino Abril
родитель
673ed02a0d
Коммит
ff5b221598
@@ -125,12 +125,12 @@ func (a *App) DeleteAllExpiredPluginKeys() *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) ListPluginKeys(pluginId string, page, perPage int) ([]string, *model.AppError) {
|
||||
result := <-a.Srv.Store.Plugin().List(pluginId, page*perPage, perPage)
|
||||
data, err := a.Srv.Store.Plugin().List(pluginId, page*perPage, perPage)
|
||||
|
||||
if result.Err != nil {
|
||||
mlog.Error("Failed to list plugin key values", mlog.Int("page", page), mlog.Int("perPage", perPage), mlog.Err(result.Err))
|
||||
return nil, result.Err
|
||||
if err != nil {
|
||||
mlog.Error("Failed to list plugin key values", mlog.Int("page", page), mlog.Int("perPage", perPage), mlog.Err(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result.Data.([]string), nil
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ func (ps SqlPluginStore) DeleteAllExpired() store.StoreChannel {
|
||||
})
|
||||
}
|
||||
|
||||
func (ps SqlPluginStore) List(pluginId string, offset int, limit int) store.StoreChannel {
|
||||
func (ps SqlPluginStore) List(pluginId string, offset int, limit int) ([]string, *model.AppError) {
|
||||
if limit <= 0 {
|
||||
limit = DEFAULT_PLUGIN_KEY_FETCH_LIMIT
|
||||
}
|
||||
@@ -169,13 +169,11 @@ func (ps SqlPluginStore) List(pluginId string, offset int, limit int) store.Stor
|
||||
offset = 0
|
||||
}
|
||||
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
var keys []string
|
||||
_, err := ps.GetReplica().Select(&keys, "SELECT PKey FROM PluginKeyValueStore WHERE PluginId = :PluginId order by PKey limit :Limit offset :Offset", map[string]interface{}{"PluginId": pluginId, "Limit": limit, "Offset": offset})
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlPluginStore.List", "store.sql_plugin_store.list.app_error", nil, fmt.Sprintf("plugin_id=%v, err=%v", pluginId, err.Error()), http.StatusInternalServerError)
|
||||
} else {
|
||||
result.Data = keys
|
||||
}
|
||||
})
|
||||
var keys []string
|
||||
_, err := ps.GetReplica().Select(&keys, "SELECT PKey FROM PluginKeyValueStore WHERE PluginId = :PluginId order by PKey limit :Limit offset :Offset", map[string]interface{}{"PluginId": pluginId, "Limit": limit, "Offset": offset})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlPluginStore.List", "store.sql_plugin_store.list.app_error", nil, fmt.Sprintf("plugin_id=%v, err=%v", pluginId, err.Error()), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return keys, nil
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ type PluginStore interface {
|
||||
Delete(pluginId, key string) StoreChannel
|
||||
DeleteAllForPlugin(PluginId string) StoreChannel
|
||||
DeleteAllExpired() StoreChannel
|
||||
List(pluginId string, page, perPage int) StoreChannel
|
||||
List(pluginId string, page, perPage int) ([]string, *model.AppError)
|
||||
}
|
||||
|
||||
type RoleStore interface {
|
||||
|
||||
@@ -110,19 +110,28 @@ func (_m *PluginStore) Get(pluginId string, key string) (*model.PluginKeyValue,
|
||||
}
|
||||
|
||||
// List provides a mock function with given fields: pluginId, page, perPage
|
||||
func (_m *PluginStore) List(pluginId string, page int, perPage int) store.StoreChannel {
|
||||
func (_m *PluginStore) List(pluginId string, page int, perPage int) ([]string, *model.AppError) {
|
||||
ret := _m.Called(pluginId, page, perPage)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int, int) store.StoreChannel); ok {
|
||||
var r0 []string
|
||||
if rf, ok := ret.Get(0).(func(string, int, int) []string); ok {
|
||||
r0 = rf(pluginId, page, perPage)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
|
||||
r1 = rf(pluginId, page, perPage)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// SaveOrUpdate provides a mock function with given fields: keyVal
|
||||
|
||||
Ссылка в новой задаче
Block a user