oplog

package
v0.0.0-...-b6f2496 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionMark = "$v"
	UuidMark    = "ui"
)
View Source
const (
	ShardByID        = "id"
	ShardByNamespace = "collection"
	ShardAutomatic   = "auto"
)
View Source
const (
	DefaultHashValue = 0
)
View Source
const (
	PrimaryKey = "_id"
)

Variables

This section is empty.

Functions

func ConvertBsonD2M

func ConvertBsonD2M(input bson.D) (bson.M, map[string]struct{})

convert bson.D to bson.M

func ExtraCommandName

func ExtraCommandName(o bson.D) (string, bool)

func GetIdOrNSFromOplog

func GetIdOrNSFromOplog(log *PartialLog) interface{}

func GetKey

func GetKey(log bson.D, wanted string) interface{}

func GetKeyWithIndex

func GetKeyWithIndex(log bson.D, wanted string) (interface{}, int)

func Hash

func Hash(hashObject interface{}) uint32

func IsRunOnAdminCommand

func IsRunOnAdminCommand(operation string) bool

func IsSyncDataCommand

func IsSyncDataCommand(operation string) bool

func LogEntryEncode

func LogEntryEncode(logs []*GenericOplog) [][]byte

func RemoveFiled

func RemoveFiled(input bson.D, key string) bson.D

func SetFiled

func SetFiled(input bson.D, key string, value interface{})

Types

type CommandOperation

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

type GenericOplog

type GenericOplog struct {
	Raw    []byte
	Parsed *PartialLog
}

type Hasher

type Hasher interface {
	DistributeOplogByMod(log *PartialLog, mod int) uint32
}

type PartialLog

type PartialLog struct {
	Timestamp     bson.MongoTimestamp `bson:"ts"`
	Operation     string              `bson:"op"`
	Gid           string              `bson:"g"`
	Namespace     string              `bson:"ns"`
	Object        bson.D              `bson:"o"`
	Query         bson.M              `bson:"o2"`
	UniqueIndexes bson.M              `bson:"uk"`
	Lsid          interface{}         `bson:"lsid"`        // mark the session id, used in transaction
	FromMigrate   bool                `bson:"fromMigrate"` // move chunk

	/*
	 * Every field subsequent declared is NEVER persistent or
	 * transfer on network connection. They only be parsed from
	 * respective logic
	 */
	UniqueIndexesUpdates bson.M // generate by CollisionMatrix
	RawSize              int    // generate by Decorator
	SourceId             int    // generate by Validator
}

func LogParsed

func LogParsed(logs []*GenericOplog) []*PartialLog

func NewPartialLog

func NewPartialLog(data bson.M) *PartialLog

func (*PartialLog) Dump

func (partialLog *PartialLog) Dump(keys map[string]struct{}) bson.D

dump according to the given keys, "keys" == nil means ignore keys

type PrimaryKeyHasher

type PrimaryKeyHasher struct {
	Hasher
}

func (*PrimaryKeyHasher) DistributeOplogByMod

func (objectIdHasher *PrimaryKeyHasher) DistributeOplogByMod(log *PartialLog, mod int) uint32

we need to ensure that oplog entry will be sent to the same job[$hash] if they have the same ObjectID. thus we can consume the oplog entry sequentially

type TableHasher

type TableHasher struct {
	Hasher
}

func (*TableHasher) DistributeOplogByMod

func (collectionHasher *TableHasher) DistributeOplogByMod(log *PartialLog, mod int) uint32

Jump to

Keyboard shortcuts

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