复制项目

This commit is contained in:
kim.dev.6789
2026-01-14 22:16:44 +08:00
parent e2577b8cee
commit e50142a3b9
691 changed files with 97009 additions and 1 deletions

View File

@@ -0,0 +1,49 @@
package versionctx
import (
"context"
"sync"
tablerelation "git.imall.cloud/openim/open-im-server-deploy/pkg/common/storage/model"
)
type Collection struct {
Name string
Doc *tablerelation.VersionLog
}
type versionKey struct{}
func WithVersionLog(ctx context.Context) context.Context {
return context.WithValue(ctx, versionKey{}, &VersionLog{})
}
func GetVersionLog(ctx context.Context) *VersionLog {
if v, ok := ctx.Value(versionKey{}).(*VersionLog); ok {
return v
}
return nil
}
type VersionLog struct {
lock sync.Mutex
data []Collection
}
func (v *VersionLog) Append(data ...Collection) {
if v == nil || len(data) == 0 {
return
}
v.lock.Lock()
defer v.lock.Unlock()
v.data = append(v.data, data...)
}
func (v *VersionLog) Get() []Collection {
if v == nil {
return nil
}
v.lock.Lock()
defer v.lock.Unlock()
return v.data
}