MM-21898 - Part 1: Generate and use an interface instead of *A… (#13840)

* Generate and use an interface instead of *App
Этот коммит содержится в:
Eli Yukelzon
2020-02-13 13:26:58 +01:00
коммит произвёл GitHub
родитель 66fc096768
Коммит 17523fa5d9
200 изменённых файлов: 4553 добавлений и 2361 удалений

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

@@ -44,14 +44,14 @@ func (a *App) SetPluginKeyWithOptions(pluginId string, key string, value []byte,
return false, err
}
updated, err := a.Srv.Store.Plugin().SetWithOptions(pluginId, key, value, options)
updated, err := a.Srv().Store.Plugin().SetWithOptions(pluginId, key, value, options)
if err != nil {
mlog.Error("Failed to set plugin key value with options", mlog.String("plugin_id", pluginId), mlog.String("key", key), mlog.Err(err))
return updated, err
}
// Clean up a previous entry using the hashed key, if it exists.
if err := a.Srv.Store.Plugin().Delete(pluginId, getKeyHash(key)); err != nil {
if err := a.Srv().Store.Plugin().Delete(pluginId, getKeyHash(key)); err != nil {
mlog.Error("Failed to clean up previously hashed plugin key value", mlog.String("plugin_id", pluginId), mlog.String("key", key), mlog.Err(err))
}
@@ -64,14 +64,14 @@ func (a *App) CompareAndDeletePluginKey(pluginId string, key string, oldValue []
Key: key,
}
deleted, err := a.Srv.Store.Plugin().CompareAndDelete(kv, oldValue)
deleted, err := a.Srv().Store.Plugin().CompareAndDelete(kv, oldValue)
if err != nil {
mlog.Error("Failed to compare and delete plugin key value", mlog.String("plugin_id", pluginId), mlog.String("key", key), mlog.Err(err))
return deleted, err
}
// Clean up a previous entry using the hashed key, if it exists.
if err := a.Srv.Store.Plugin().Delete(pluginId, getKeyHash(key)); err != nil {
if err := a.Srv().Store.Plugin().Delete(pluginId, getKeyHash(key)); err != nil {
mlog.Error("Failed to clean up previously hashed plugin key value", mlog.String("plugin_id", pluginId), mlog.String("key", key), mlog.Err(err))
}
@@ -79,7 +79,7 @@ func (a *App) CompareAndDeletePluginKey(pluginId string, key string, oldValue []
}
func (a *App) GetPluginKey(pluginId string, key string) ([]byte, *model.AppError) {
if kv, err := a.Srv.Store.Plugin().Get(pluginId, key); err == nil {
if kv, err := a.Srv().Store.Plugin().Get(pluginId, key); err == nil {
return kv.Value, nil
} else if err.StatusCode != http.StatusNotFound {
mlog.Error("Failed to query plugin key value", mlog.String("plugin_id", pluginId), mlog.String("key", key), mlog.Err(err))
@@ -87,7 +87,7 @@ func (a *App) GetPluginKey(pluginId string, key string) ([]byte, *model.AppError
}
// Lookup using the hashed version of the key for keys written prior to v5.6.
if kv, err := a.Srv.Store.Plugin().Get(pluginId, getKeyHash(key)); err == nil {
if kv, err := a.Srv().Store.Plugin().Get(pluginId, getKeyHash(key)); err == nil {
return kv.Value, nil
} else if err.StatusCode != http.StatusNotFound {
mlog.Error("Failed to query plugin key value using hashed key", mlog.String("plugin_id", pluginId), mlog.String("key", key), mlog.Err(err))
@@ -98,13 +98,13 @@ func (a *App) GetPluginKey(pluginId string, key string) ([]byte, *model.AppError
}
func (a *App) DeletePluginKey(pluginId string, key string) *model.AppError {
if err := a.Srv.Store.Plugin().Delete(pluginId, getKeyHash(key)); err != nil {
if err := a.Srv().Store.Plugin().Delete(pluginId, getKeyHash(key)); err != nil {
mlog.Error("Failed to delete plugin key value", mlog.String("plugin_id", pluginId), mlog.String("key", key), mlog.Err(err))
return err
}
// Also delete the key without hashing
if err := a.Srv.Store.Plugin().Delete(pluginId, key); err != nil {
if err := a.Srv().Store.Plugin().Delete(pluginId, key); err != nil {
mlog.Error("Failed to delete plugin key value using hashed key", mlog.String("plugin_id", pluginId), mlog.String("key", key), mlog.Err(err))
return err
}
@@ -113,7 +113,7 @@ func (a *App) DeletePluginKey(pluginId string, key string) *model.AppError {
}
func (a *App) DeleteAllKeysForPlugin(pluginId string) *model.AppError {
if err := a.Srv.Store.Plugin().DeleteAllForPlugin(pluginId); err != nil {
if err := a.Srv().Store.Plugin().DeleteAllForPlugin(pluginId); err != nil {
mlog.Error("Failed to delete all plugin key values", mlog.String("plugin_id", pluginId), mlog.Err(err))
return err
}
@@ -122,11 +122,11 @@ func (a *App) DeleteAllKeysForPlugin(pluginId string) *model.AppError {
}
func (a *App) DeleteAllExpiredPluginKeys() *model.AppError {
if a.Srv == nil {
if a.Srv() == nil {
return nil
}
if err := a.Srv.Store.Plugin().DeleteAllExpired(); err != nil {
if err := a.Srv().Store.Plugin().DeleteAllExpired(); err != nil {
mlog.Error("Failed to delete all expired plugin key values", mlog.Err(err))
return err
}
@@ -135,7 +135,7 @@ func (a *App) DeleteAllExpiredPluginKeys() *model.AppError {
}
func (a *App) ListPluginKeys(pluginId string, page, perPage int) ([]string, *model.AppError) {
data, err := a.Srv.Store.Plugin().List(pluginId, page*perPage, perPage)
data, err := a.Srv().Store.Plugin().List(pluginId, page*perPage, perPage)
if err != nil {
mlog.Error("Failed to list plugin key values", mlog.Int("page", page), mlog.Int("perPage", perPage), mlog.Err(err))