loader

package
v0.0.0-...-81c6b1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RollbackToVersion

func RollbackToVersion(metadataColl *mongo.Collection, historyColl *mongo.Collection, docID primitive.ObjectID, version int32) error

RollbackToVersion 回滚数据到指定版本

Types

type EmbedLoader

type EmbedLoader struct {
	Fs       embed.FS
	Filename string
}

func (*EmbedLoader) Exists

func (el *EmbedLoader) Exists() bool

func (*EmbedLoader) Load

func (el *EmbedLoader) Load() ([]byte, error)

type History

type History struct {
	DocId        primitive.ObjectID `bson:"doc_id" json:"doc_id"`
	Version      string             `bson:"version" json:"version"`
	Type         string             `bson:"type" json:"type"`
	Timestamp    primitive.DateTime `bson:"timestamp" json:"timestamp"`
	ChangeNumber int                `bson:"change_number" json:"change_number"`
}

type Manager

type Manager struct {
	Embed *EmbedLoader
	Mongo *MongoLoader
	Yaml  *YamlLoader
}

func (*Manager) History

func (m *Manager) History() []History

History 历史版本

func (*Manager) Load

func (m *Manager) Load() ([]byte, error)

Load 加载

func (*Manager) Version

func (m *Manager) Version() string

Version 版本

type MongoLoader

type MongoLoader struct {
	Client             *mongo.Client
	MetadataCollection string
	HistoryCollection  string
	Database           string
	Version            string
}

func (*MongoLoader) Exists

func (ml *MongoLoader) Exists() bool

func (*MongoLoader) GetCurrentVersion

func (ml *MongoLoader) GetCurrentVersion() (string, error)

GetCurrentVersion 查询当前版本

func (*MongoLoader) GetHistoryVersions

func (ml *MongoLoader) GetHistoryVersions() ([]History, error)

GetHistoryVersions 获取历史版本信息

func (*MongoLoader) Load

func (ml *MongoLoader) Load() ([]byte, error)

Load 获取当前最新版本的数据

func (*MongoLoader) Save

func (ml *MongoLoader) Save(rawData []byte, changeNumber int) error

Save 存储新版本数据

type YamlLoader

type YamlLoader struct {
	Filename string
}

func (*YamlLoader) Exists

func (yl *YamlLoader) Exists() bool

func (*YamlLoader) Load

func (yl *YamlLoader) Load() ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL