checkpoint

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OplogCollection = "oplog.rs"
	OplogDatabase   = "local"
	Newest          = -1
	Oldest          = 1
)

Variables

View Source
var (
	MongoTimestampMax = primitive.Timestamp{math.MaxUint32, math.MaxUint32}
	MongoTimestampMin = primitive.Timestamp{0, 0}
)

Functions

func CompareTimestamps

func CompareTimestamps(ts1, ts2 primitive.Timestamp) int

func FromInt64

func FromInt64(i int64) primitive.Timestamp

func Int64ToUnixTimestampSeconds

func Int64ToUnixTimestampSeconds(ts int64) int64

func IsZero

func IsZero(ts primitive.Timestamp) bool

func ToDate

func ToDate(ts primitive.Timestamp) time.Time

func ToInt64

func ToInt64(ts primitive.Timestamp) int64

Types

type Checkpoint

type Checkpoint struct {
	//Id              string    `bson:"_id" json:"_id" omitempty`
	Name      string              `bson:"name" json:"name" omitempty`
	SavedAt   time.Time           `bson:"saved" json:"saved" omitempty`
	Latest    time.Time           `bson:"latest" json:"latest" omitempty`
	LatestTs  primitive.Timestamp `bson:"ts" json:"ts" omitempty`
	LatestLSN int64               `bson:"lsn" json:"lsn" omitempty`
}

type CheckpointManager

type CheckpointManager interface {
	GetCheckpoint(context.Context) (Checkpoint, error)
	SetCheckpoint(context.Context, primitive.Timestamp, bool) error
	MoveCheckpointForward(primitive.Timestamp)
	StartAutosave(context.Context)
	StopAutosave()
}

type MongoCheckpoint

type MongoCheckpoint struct {

	// Database used to store the checkpoint
	DB string

	// Collection used to store the checkpoint
	Collection string

	// In-memory storage of the current checkpoint
	Current Checkpoint
	// contains filtered or unexported fields
}

func NewMongoCheckpointService

func NewMongoCheckpointService(name string, ckptDb string, ckptColl string) *MongoCheckpoint

func (*MongoCheckpoint) GetCheckpoint

func (s *MongoCheckpoint) GetCheckpoint(ctx context.Context) (Checkpoint, error)

func (*MongoCheckpoint) MoveCheckpointForward added in v0.0.13

func (s *MongoCheckpoint) MoveCheckpointForward(ts primitive.Timestamp)

func (*MongoCheckpoint) SetCheckpoint

func (s *MongoCheckpoint) SetCheckpoint(ctx context.Context, ts primitive.Timestamp, save bool) error

func (*MongoCheckpoint) StartAutosave

func (s *MongoCheckpoint) StartAutosave(context.Context)

func (*MongoCheckpoint) StopAutosave

func (s *MongoCheckpoint) StopAutosave()

type TsWindow

type TsWindow struct {
	Oldest primitive.Timestamp
	Newest primitive.Timestamp
}

func GetReplicasetOplogBoundaries

func GetReplicasetOplogBoundaries() (TsWindow, error)

Jump to

Keyboard shortcuts

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