Documentation
¶
Index ¶
- Constants
- Variables
- func CSVTemplate(kind string) ([]byte, error)
- func CSVToMerge(kind string, data []byte) ([]byte, error)
- func Directory(ctx context.Context, db *sql.DB) (string, error)
- func IsInvalid(err error) bool
- func Parse(data []byte) (File, Preview, error)
- func ReadManaged(dir, name string) ([]byte, error)
- func SaveManaged(dir string, data []byte, now time.Time, dailyKeep, weeklyKeep int, ...) error
- func Validate(ctx context.Context, f File) error
- func WriteAtomic(path string, data []byte) error
- type ChangePreview
- type DifferenceCount
- type File
- type ManagedFile
- type ObjectPreview
- type Pending
- type Preview
- type Service
- func (s Service) CleanupExpired(ctx context.Context) error
- func (s Service) Export(ctx context.Context, kind string) ([]byte, error)
- func (s Service) List(ctx context.Context) ([]Pending, error)
- func (s Service) MergePreview(ctx context.Context, f File) (Preview, error)
- func (s Service) Restore(ctx context.Context, f File) error
- func (s Service) RestorePreview(ctx context.Context, target File) (Preview, string, error)
- func (s Service) Review(ctx context.Context, id string, approve bool, reviewer string) error
- func (s Service) Submit(ctx context.Context, data []byte, actor auth.Principal) (Pending, error)
Constants ¶
View Source
const MaxSize = 16 << 20
View Source
const SchemaVersion = 1
Variables ¶
View Source
var ErrConflict = errors.New("merge conflict")
View Source
var ErrInvalid = errors.New("invalid backup")
Functions ¶
func CSVTemplate ¶ added in v0.3.0
func CSVToMerge ¶ added in v0.3.0
CSVToMerge 把单一对象类型的 UTF-8 CSV 转成现有合并导入文件,后续仍走同一审批路径。
func ReadManaged ¶ added in v0.3.0
func SaveManaged ¶ added in v0.3.0
func WriteAtomic ¶
WriteAtomic writes one private backup in the data directory and fsyncs it before rename.
Types ¶
type ChangePreview ¶ added in v0.3.0
type DifferenceCount ¶ added in v0.3.0
type File ¶
type File struct {
SchemaVersion int `yaml:"schema_version" json:"schema_version"`
Kind string `yaml:"kind" json:"kind"`
ExportedAt string `yaml:"exported_at" json:"exported_at"`
Tables map[string][]map[string]any `yaml:"tables" json:"tables"`
Objects []map[string]any `yaml:"objects,omitempty" json:"objects,omitempty"`
}
type ManagedFile ¶ added in v0.3.0
type ManagedFile struct {
Name string `json:"name"`
Kind string `json:"kind"`
CreatedAt string `json:"created_at"`
Size int64 `json:"size"`
}
func ListManaged ¶ added in v0.3.0
func ListManaged(dir string) ([]ManagedFile, error)
type ObjectPreview ¶ added in v0.3.0
type Preview ¶
type Preview struct {
Kind string `json:"kind"`
Counts map[string]int `json:"counts"`
Objects []ObjectPreview `json:"objects,omitempty"`
Differences map[string]DifferenceCount `json:"differences,omitempty"`
ObjectDifferences map[string]DifferenceCount `json:"object_differences,omitempty"`
LostChanges []ChangePreview `json:"lost_changes,omitempty"`
}
type Service ¶
func (Service) CleanupExpired ¶ added in v0.3.0
func (Service) MergePreview ¶ added in v0.3.0
func (Service) RestorePreview ¶ added in v0.3.0
Click to show internal directories.
Click to hide internal directories.