Documentation ¶
Index ¶
- Constants
- type Replica
- func (r *Replica) CalcPos(ctx context.Context, generation string) (pos litestream.Pos, err error)
- func (r *Replica) DB() *litestream.DB
- func (r *Replica) EnforceRetention(ctx context.Context) (err error)
- func (r *Replica) GenerationDir(generation string) string
- func (r *Replica) GenerationStats(ctx context.Context, generation string) (stats litestream.GenerationStats, err error)
- func (r *Replica) Generations(ctx context.Context) ([]string, error)
- func (r *Replica) Init(ctx context.Context) (err error)
- func (r *Replica) LastPos() litestream.Pos
- func (r *Replica) MaxSnapshotIndex(generation string) (int, error)
- func (r *Replica) Name() string
- func (r *Replica) SnapshotDir(generation string) string
- func (r *Replica) SnapshotPath(generation string, index int) string
- func (r *Replica) SnapshotReader(ctx context.Context, generation string, index int) (io.ReadCloser, error)
- func (r *Replica) Snapshots(ctx context.Context) ([]*litestream.SnapshotInfo, error)
- func (r *Replica) Start(ctx context.Context)
- func (r *Replica) Stop()
- func (r *Replica) Sync(ctx context.Context) (err error)
- func (r *Replica) Type() string
- func (r *Replica) WALDir(generation string) string
- func (r *Replica) WALReader(ctx context.Context, generation string, index int) (io.ReadCloser, error)
- func (r *Replica) WALs(ctx context.Context) ([]*litestream.WALInfo, error)
Constants ¶
const ( DefaultSyncInterval = 10 * time.Second DefaultRetention = 24 * time.Hour DefaultRetentionCheckInterval = 1 * time.Hour )
S3 replica default settings.
const MaxKeys = 1000
MaxKeys is the number of keys S3 can operate on per batch.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Replica ¶
type Replica struct { // AWS authentication keys. AccessKeyID string SecretAccessKey string // S3 bucket information Region string Bucket string Path string // Time between syncs with the shadow WAL. SyncInterval time.Duration // Time to keep snapshots and related WAL files. // Database is snapshotted after interval and older WAL files are discarded. Retention time.Duration // Time between retention checks. RetentionCheckInterval time.Duration // Time between validation checks. ValidationInterval time.Duration // If true, replica monitors database for changes automatically. // Set to false if replica is being used synchronously (such as in tests). MonitorEnabled bool // contains filtered or unexported fields }
Replica is a replica that replicates a DB to an S3 bucket.
func NewReplica ¶
func NewReplica(db *litestream.DB, name string) *Replica
NewReplica returns a new instance of Replica.
func (*Replica) CalcPos ¶
CalcPos returns the position for the replica for the current generation. Returns a zero value if there is no active generation.
func (*Replica) DB ¶
func (r *Replica) DB() *litestream.DB
DB returns the parent database reference.
func (*Replica) EnforceRetention ¶
EnforceRetention forces a new snapshot once the retention interval has passed. Older snapshots and WAL files are then removed.
func (*Replica) GenerationDir ¶
GenerationDir returns the path to a generation's root directory.
func (*Replica) GenerationStats ¶
func (r *Replica) GenerationStats(ctx context.Context, generation string) (stats litestream.GenerationStats, err error)
GenerationStats returns stats for a generation.
func (*Replica) Generations ¶
Generations returns a list of available generation names.
func (*Replica) LastPos ¶
func (r *Replica) LastPos() litestream.Pos
LastPos returns the last successfully replicated position.
func (*Replica) MaxSnapshotIndex ¶
MaxSnapshotIndex returns the highest index for the snapshots.
func (*Replica) SnapshotDir ¶
SnapshotDir returns the path to a generation's snapshot directory.
func (*Replica) SnapshotPath ¶
SnapshotPath returns the path to a snapshot file.
func (*Replica) SnapshotReader ¶
func (r *Replica) SnapshotReader(ctx context.Context, generation string, index int) (io.ReadCloser, error)
SnapshotReader returns a reader for snapshot data at the given generation/index.
func (*Replica) Snapshots ¶
func (r *Replica) Snapshots(ctx context.Context) ([]*litestream.SnapshotInfo, error)
Snapshots returns a list of available snapshots in the replica.
func (*Replica) Stop ¶
func (r *Replica) Stop()
Stop cancels any outstanding replication and blocks until finished.