Documentation
¶
Overview ¶
Package export runs the DB2 → SQLite export pipeline.
Index ¶
- Constants
- Variables
- func DefsSHA256(s *defs.Snapshot) (string, error)
- func FileName(version string) string
- func HotfixSHA256(inst *install.Install) (string, error)
- func IsFatal(err error) bool
- func RemoteFileName(version, source string) string
- type Options
- type Remote
- type StatusReport
- type Summary
- type TableFailure
- type TableStatusRow
- type Writer
- func (w *Writer) Close() error
- func (w *Writer) CreateIndexes(defs []*db2.Definition) error
- func (w *Writer) WriteHotfixLog(table string, logs []hotfix.LogEntry) error
- func (w *Writer) WriteMeta(meta map[string]string) error
- func (w *Writer) WriteTable(t *db2.Table) error
- func (w *Writer) WriteTableStatus(r TableStatusRow) error
Constants ¶
const ( SourceLocal = "local" SourceCDN = "cdn" )
Source values (_meta.source).
const ( StateNeverExported = "never_exported" StateUpToDate = "up_to_date" StateStale = "stale" ReasonBuildChanged = "build_changed" ReasonHotfixesChanged = "hotfixes_changed" ReasonSchemaChanged = "schema_changed" ReasonDefsChanged = "defs_changed" ReasonSourceChanged = "source_changed" )
Status states and reasons.
const CurrentName = "current.sqlite"
CurrentName is the symlink pointing at the latest export.
Variables ¶
ErrLocked means another export holds the output directory lock.
Functions ¶
func DefsSHA256 ¶
DefsSHA256 returns the digest of the snapshot's canonical content.
func FileName ¶
FileName returns the file name of a local export of version.
func HotfixSHA256 ¶
HotfixSHA256 returns the hex SHA-256 of the install's DBCache.bin, or "" when the file does not exist.
func IsFatal ¶
IsFatal reports whether a writer error means the database can no longer be written (disk full, I/O error, closed database) rather than a problem with one table.
Types ¶
type Options ¶
type Options struct {
Dir, OutDir string // OutDir also holds the optional defs.json.gz override; Dir is unused with Remote
Remote *Remote // nil = read the local install in Dir
// HotfixesPath overrides the DBCache.bin to apply. Empty: the install's
// DBCache.bin for a local export, no hotfixes for a remote one.
HotfixesPath string
ToolVersion string
Workers int // 0 → runtime.NumCPU()
Now func() time.Time
// contains filtered or unexported fields
}
Options configures Run.
type Remote ¶
type Remote struct {
Source string // e.g. SourceCDN
Version string
BuildNumber uint32
BuildKey string // build config hash
Locale string
// Open opens the storage with the snapshot's key ring. Run closes the
// returned source when it implements io.Closer.
Open func(keys db2.KeyRing) (dataset.FileSource, error)
}
Remote is a game build read from somewhere other than a local install. export never opens network storage itself: the caller provides Open.
type StatusReport ¶
type StatusReport struct {
State string `json:"state"`
Reasons []string `json:"reasons"`
InstalledVersion string `json:"installed_version"`
ExportedVersion string `json:"exported_version"`
Database string `json:"database"`
}
StatusReport describes how the last export compares to the install.
type Summary ¶
type Summary struct {
Version, OutputPath string
Source string // SourceLocal or SourceCDN
Counts map[dataset.TableStatus]int
Failed []TableFailure
Hotfix hotfix.Stats
SkippedRows int
MissingKeys map[uint64]int
DBCacheStatus dataset.HotfixStatus
ClientKeysAdded int
Duration time.Duration
DefsOrigin string // defs.OriginEmbedded or defs.OriginLocal
DefsCommit string // WoWDBDefs commit of the snapshot
DefsGeneratedAt string
}
Summary reports an export.
func Run ¶
Run exports every snapshot table. By default it reads the install in opts.Dir, writes <OutDir>/wowf-<version>.sqlite and points current.sqlite at it. With opts.Remote it reads that build instead, writes <OutDir>/wowf-<version>-<source>.sqlite and leaves current.sqlite alone: current always tracks the local install.
type TableFailure ¶
type TableFailure struct {
Name, Error string
}
TableFailure names a table that failed to export.
type TableStatusRow ¶
type TableStatusRow struct {
TableName string
FDID uint32
TableHash string
LayoutHash string
MatchedBy string
Status string
Error string
BaseRows int
HotfixUpserts int
HotfixDeletes int
HotfixReverts int
HotfixErrors int
SkippedRows int
SkippedSections int
}
TableStatusRow is one _tables row.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes an export database. It is not safe for concurrent use: a single goroutine owns it.
func OpenWriter ¶
OpenWriter creates a new database at path, which must not exist.
func (*Writer) Close ¶
Close closes the database and syncs the file to disk.
func (*Writer) CreateIndexes ¶
func (w *Writer) CreateIndexes(defs []*db2.Definition) error
CreateIndexes creates the reference and relation indexes of defs.
func (*Writer) WriteHotfixLog ¶
WriteHotfixLog inserts the hotfix log of table in one transaction.
func (*Writer) WriteMeta ¶
WriteMeta inserts or replaces _meta keys.
func (*Writer) WriteTable ¶
WriteTable creates the data table of t in one transaction (DDL included, so a failure leaves no partial table), inserts its rows in ascending ID order, and records its columns in _columns.
func (*Writer) WriteTableStatus ¶
func (w *Writer) WriteTableStatus(r TableStatusRow) error
WriteTableStatus inserts one _tables row.
Source Files
¶
- export.go
- status.go
- writer.go