models

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OplogArchBasePath   = "oplog_" + utility.VersionStr + "/"
	ArchNameTSDelimiter = "_"
	ArchiveTypeOplog    = "oplog"
	ArchiveTypeGap      = "gap"
)

Archive path constants

Variables

View Source
var (
	ArchRegexp = regexp.MustCompile(`^(oplog|gap)_(?P<startTS>[0-9]+\.[0-9]+)_(?P<endTS>[0-9]+\.[0-9]+)\.(?P<Ext>[^$]+)$`)
)
View Source
var ErrorDescriptions = map[ErrorCode]string{
	SplitFound:        "last known document was not found",
	VersionChanged:    "schema version of the user credential documents changed",
	CollectionRenamed: "collection renamed",
}

ErrorDescriptions maps error codes to messages

Functions

func BsonTimestampFromOplogTS

func BsonTimestampFromOplogTS(ots Timestamp) primitive.Timestamp

BsonTimestampFromOplogTS builds BSON primitive from Timestamp

func LessTS

func LessTS(ots1, ots2 Timestamp) bool

LessTS returns if first timestamp less than second

func NewError

func NewError(code ErrorCode, msg string) error

NewError builds Error with error code and message

Types

type Archive

type Archive struct {
	Start Timestamp
	End   Timestamp
	Ext   string
	Type  string
}

Archive defines oplog archive representation

func ArchFromFilename

func ArchFromFilename(path string) (Archive, error)

ArchFromFilename builds Arch from given path TODO: support empty extension

func NewArchive

func NewArchive(start, end Timestamp, ext string, atype string) (Archive, error)

NewArchive builds Archive struct with given arguments

func (Archive) Extension

func (a Archive) Extension() string

Extension returns extension of archive file name

func (Archive) Filename

func (a Archive) Filename() string

Filename builds archive filename from timestamps, extension and type example: oplog_1569009857.10_1569009101.99.lzma

func (Archive) In

func (a Archive) In(ts Timestamp) bool

In returns if oplog with given timestamp is exists in archive

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error ...

func (*Error) Error

func (e *Error) Error() string

Error ...

type ErrorCode

type ErrorCode int

ErrorCode ...

const (
	ValidationMessagePrefix           = "oplog validate error"
	SplitFound              ErrorCode = iota
	VersionChanged          ErrorCode = iota
	CollectionRenamed       ErrorCode = iota
)

Error codes generation

type IsMaster

type IsMaster struct {
	IsMaster  bool
	LastWrite IsMasterLastWrite
}

IsMaster ...

type IsMasterLastWrite

type IsMasterLastWrite struct {
	OpTime         OpTime
	MajorityOpTime OpTime
}

IsMasterLastWrite ...

type OpTime

type OpTime struct {
	TS   Timestamp
	Term int64
}

Optime ...

type Oplog

type Oplog struct {
	TS   Timestamp `bson:"ts"`
	OP   string    `bson:"op"`
	NS   string    `bson:"ns"`
	Data []byte
}

Oplog represents oplog raw and parsed metadata.

func OplogFromRaw

func OplogFromRaw(raw []byte) (Oplog, error)

OplogFromRaw tries to decode bytes to Oplog model

type OplogMeta

type OplogMeta struct {
	TS primitive.Timestamp `bson:"ts"`
	NS string              `bson:"ns"`
	Op string              `bson:"op"`
}

OplogMeta is used to decode raw bson record.

type Timestamp

type Timestamp struct {
	TS  uint32
	Inc uint32
}

Timestamp represents oplog record uniq id.

func MaxTS

func MaxTS(ots1, ots2 Timestamp) Timestamp

MaxTS returns maximum of two timestamps.

func TimestampFromBson

func TimestampFromBson(bts primitive.Timestamp) Timestamp

TimestampFromBson builds Timestamp from BSON primitive

func TimestampFromStr

func TimestampFromStr(s string) (Timestamp, error)

TimestampFromStr builds Timestamp from string

func (Timestamp) String

func (ots Timestamp) String() string

String returns text representation of Timestamp struct

Jump to

Keyboard shortcuts

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