Compare commits
3 Commits
v0.3.12
...
v0.3.14_de
| Author | SHA1 | Date | |
|---|---|---|---|
| c2946ef0d0 | |||
|
|
977d4a5ee4 | ||
|
|
c81010e7ab |
3
Makefile
3
Makefile
@@ -20,7 +20,8 @@ ifndef LITESTREAM_VERSION
|
||||
$(error LITESTREAM_VERSION is undefined)
|
||||
endif
|
||||
mkdir -p dist
|
||||
go build -v -ldflags "-s -w -X 'main.Version=${LITESTREAM_VERSION}'" -o dist/litestream ./cmd/litestream
|
||||
|
||||
GOOS=darwin GOARCH=amd64 CC="gcc -target amd64-apple-macos11" CGO_ENABLED=1 go build -v -ldflags "-s -w -X 'main.Version=${LITESTREAM_VERSION}'" -o dist/litestream ./cmd/litestream
|
||||
gon etc/gon.hcl
|
||||
mv dist/litestream.zip dist/litestream-${LITESTREAM_VERSION}-darwin-amd64.zip
|
||||
openssl dgst -sha256 dist/litestream-${LITESTREAM_VERSION}-darwin-amd64.zip
|
||||
|
||||
34
db.go
34
db.go
@@ -146,6 +146,40 @@ func NewDB(path string) *DB {
|
||||
return db
|
||||
}
|
||||
|
||||
// NewDB returns a new instance of DB for a given path.
|
||||
func NewLSDB(path string, metapath string) *DB {
|
||||
_, file := filepath.Split(path)
|
||||
|
||||
db := &DB{
|
||||
path: path,
|
||||
metaPath: filepath.Join(metapath, "."+file+MetaDirSuffix),
|
||||
notify: make(chan struct{}),
|
||||
|
||||
MinCheckpointPageN: DefaultMinCheckpointPageN,
|
||||
MaxCheckpointPageN: DefaultMaxCheckpointPageN,
|
||||
TruncatePageN: DefaultTruncatePageN,
|
||||
CheckpointInterval: DefaultCheckpointInterval,
|
||||
MonitorInterval: DefaultMonitorInterval,
|
||||
Logger: slog.With("db", path),
|
||||
}
|
||||
|
||||
db.dbSizeGauge = dbSizeGaugeVec.WithLabelValues(db.path)
|
||||
db.walSizeGauge = walSizeGaugeVec.WithLabelValues(db.path)
|
||||
db.totalWALBytesCounter = totalWALBytesCounterVec.WithLabelValues(db.path)
|
||||
db.shadowWALIndexGauge = shadowWALIndexGaugeVec.WithLabelValues(db.path)
|
||||
db.shadowWALSizeGauge = shadowWALSizeGaugeVec.WithLabelValues(db.path)
|
||||
db.syncNCounter = syncNCounterVec.WithLabelValues(db.path)
|
||||
db.syncErrorNCounter = syncErrorNCounterVec.WithLabelValues(db.path)
|
||||
db.syncSecondsCounter = syncSecondsCounterVec.WithLabelValues(db.path)
|
||||
db.checkpointNCounterVec = checkpointNCounterVec.MustCurryWith(prometheus.Labels{"db": db.path})
|
||||
db.checkpointErrorNCounterVec = checkpointErrorNCounterVec.MustCurryWith(prometheus.Labels{"db": db.path})
|
||||
db.checkpointSecondsCounterVec = checkpointSecondsCounterVec.MustCurryWith(prometheus.Labels{"db": db.path})
|
||||
|
||||
db.ctx, db.cancel = context.WithCancel(context.Background())
|
||||
|
||||
return db
|
||||
}
|
||||
|
||||
// SQLDB returns a reference to the underlying sql.DB connection.
|
||||
func (db *DB) SQLDB() *sql.DB {
|
||||
return db.db
|
||||
|
||||
@@ -99,7 +99,11 @@ func (r *Replica) Name() string {
|
||||
|
||||
// Logger returns the DB sub-logger for this replica.
|
||||
func (r *Replica) Logger() *slog.Logger {
|
||||
return r.db.Logger.With("replica", r.Name())
|
||||
logger := slog.Default()
|
||||
if r.db != nil {
|
||||
logger = r.db.Logger
|
||||
}
|
||||
return logger.With("replica", r.Name())
|
||||
}
|
||||
|
||||
// DB returns a reference to the database the replica is attached to, if any.
|
||||
|
||||
Reference in New Issue
Block a user