MM-28247 Threads metadata table (#15571)

Этот коммит содержится в:
Eli Yukelzon
2020-10-01 18:48:38 +03:00
коммит произвёл GitHub
родитель 10961f9500
Коммит 595248b10e
17 изменённых файлов: 1007 добавлений и 9 удалений

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

@@ -45,6 +45,7 @@ type TimerLayer struct {
SystemStore store.SystemStore
TeamStore store.TeamStore
TermsOfServiceStore store.TermsOfServiceStore
ThreadStore store.ThreadStore
TokenStore store.TokenStore
UploadSessionStore store.UploadSessionStore
UserStore store.UserStore
@@ -161,6 +162,10 @@ func (s *TimerLayer) TermsOfService() store.TermsOfServiceStore {
return s.TermsOfServiceStore
}
func (s *TimerLayer) Thread() store.ThreadStore {
return s.ThreadStore
}
func (s *TimerLayer) Token() store.TokenStore {
return s.TokenStore
}
@@ -320,6 +325,11 @@ type TimerLayerTermsOfServiceStore struct {
Root *TimerLayer
}
type TimerLayerThreadStore struct {
store.ThreadStore
Root *TimerLayer
}
type TimerLayerTokenStore struct {
store.TokenStore
Root *TimerLayer
@@ -6846,6 +6856,86 @@ func (s *TimerLayerTermsOfServiceStore) Save(termsOfService *model.TermsOfServic
return result, err
}
func (s *TimerLayerThreadStore) Delete(postId string) error {
start := timemodule.Now()
err := s.ThreadStore.Delete(postId)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.Delete", success, elapsed)
}
return err
}
func (s *TimerLayerThreadStore) Get(id string) (*model.Thread, error) {
start := timemodule.Now()
result, err := s.ThreadStore.Get(id)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.Get", success, elapsed)
}
return result, err
}
func (s *TimerLayerThreadStore) Save(thread *model.Thread) (*model.Thread, error) {
start := timemodule.Now()
result, err := s.ThreadStore.Save(thread)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.Save", success, elapsed)
}
return result, err
}
func (s *TimerLayerThreadStore) SaveMultiple(thread []*model.Thread) ([]*model.Thread, int, error) {
start := timemodule.Now()
result, resultVar1, err := s.ThreadStore.SaveMultiple(thread)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.SaveMultiple", success, elapsed)
}
return result, resultVar1, err
}
func (s *TimerLayerThreadStore) Update(thread *model.Thread) (*model.Thread, error) {
start := timemodule.Now()
result, err := s.ThreadStore.Update(thread)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ThreadStore.Update", success, elapsed)
}
return result, err
}
func (s *TimerLayerTokenStore) Cleanup() {
start := timemodule.Now()
@@ -8800,6 +8890,7 @@ func New(childStore store.Store, metrics einterfaces.MetricsInterface) *TimerLay
newStore.SystemStore = &TimerLayerSystemStore{SystemStore: childStore.System(), Root: &newStore}
newStore.TeamStore = &TimerLayerTeamStore{TeamStore: childStore.Team(), Root: &newStore}
newStore.TermsOfServiceStore = &TimerLayerTermsOfServiceStore{TermsOfServiceStore: childStore.TermsOfService(), Root: &newStore}
newStore.ThreadStore = &TimerLayerThreadStore{ThreadStore: childStore.Thread(), Root: &newStore}
newStore.TokenStore = &TimerLayerTokenStore{TokenStore: childStore.Token(), Root: &newStore}
newStore.UploadSessionStore = &TimerLayerUploadSessionStore{UploadSessionStore: childStore.UploadSession(), Root: &newStore}
newStore.UserStore = &TimerLayerUserStore{UserStore: childStore.User(), Root: &newStore}