mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
The server module named github.com/hanzoai/team/server/v8 — a path that resolves to the retired workspace's repository, not this one — while server/public still published github.com/mattermost/mattermost/server/public. Both are github.com/hanzoteam/server/... now, which is where this code actually lives. That second half is what made the binary unbootable. Upstream's public path stayed claimed by upstream, mattermost-plugin-ai imported it, and the build linked public/model twice; public/plugin's gob.Register then ran twice under one name and panicked at init, before main. Reverting the rename traded the brand for a working binary. Rebranding the plugin alongside it needs no such trade: the agents fork is github.com/hanzoteam/agents/v2 against our public module, so no module named mattermost/mattermost is in the graph at all. Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and it is ours.
70 lines
2.2 KiB
Go
70 lines
2.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package localcachelayer
|
|
|
|
import (
|
|
"github.com/hanzoteam/server/server/public/model"
|
|
"github.com/hanzoteam/server/server/public/shared/mlog"
|
|
"github.com/hanzoteam/server/server/public/shared/request"
|
|
|
|
"github.com/hanzoteam/server/server/v8/channels/store"
|
|
)
|
|
|
|
type LocalCacheTemporaryPostStore struct {
|
|
store.TemporaryPostStore
|
|
rootStore *LocalCacheStore
|
|
}
|
|
|
|
func (s *LocalCacheTemporaryPostStore) handleClusterInvalidateTemporaryPosts(msg *model.ClusterMessage) {
|
|
if err := s.rootStore.temporaryPostCache.Purge(); err != nil {
|
|
s.rootStore.logger.Error("failed to purge temporary post cache", mlog.Err(err))
|
|
}
|
|
}
|
|
|
|
func (s LocalCacheTemporaryPostStore) ClearCaches() {
|
|
if err := s.rootStore.temporaryPostCache.Purge(); err != nil {
|
|
s.rootStore.logger.Error("failed to purge temporary post cache", mlog.Err(err))
|
|
}
|
|
|
|
if s.rootStore.metrics != nil {
|
|
s.rootStore.metrics.IncrementMemCacheInvalidationCounter(s.rootStore.temporaryPostCache.Name())
|
|
}
|
|
}
|
|
|
|
func (s LocalCacheTemporaryPostStore) InvalidateTemporaryPost(id string) {
|
|
s.rootStore.doInvalidateCacheCluster(s.rootStore.temporaryPostCache, id, nil)
|
|
if s.rootStore.metrics != nil {
|
|
s.rootStore.metrics.IncrementMemCacheInvalidationCounter(s.rootStore.temporaryPostCache.Name())
|
|
}
|
|
}
|
|
|
|
func (s LocalCacheTemporaryPostStore) Save(rctx request.CTX, post *model.TemporaryPost) (*model.TemporaryPost, error) {
|
|
defer s.InvalidateTemporaryPost(post.ID)
|
|
return s.TemporaryPostStore.Save(rctx, post)
|
|
}
|
|
|
|
func (s LocalCacheTemporaryPostStore) Get(rctx request.CTX, id string, allowFromCache bool) (*model.TemporaryPost, error) {
|
|
if !allowFromCache {
|
|
return s.TemporaryPostStore.Get(rctx, id, false)
|
|
}
|
|
|
|
var post *model.TemporaryPost
|
|
if err := s.rootStore.doStandardReadCache(s.rootStore.temporaryPostCache, id, &post); err == nil {
|
|
return post, nil
|
|
}
|
|
|
|
post, err := s.TemporaryPostStore.Get(rctx, id, false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
s.rootStore.doStandardAddToCache(s.rootStore.temporaryPostCache, id, post)
|
|
return post, nil
|
|
}
|
|
|
|
func (s LocalCacheTemporaryPostStore) Delete(rctx request.CTX, id string) error {
|
|
defer s.InvalidateTemporaryPost(id)
|
|
return s.TemporaryPostStore.Delete(rctx, id)
|
|
}
|