oplog

package
v0.0.0-...-d1d92f6 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShardByID        = "id"
	ShardByNamespace = "collection"
	ShardAutomatic   = "auto"
)
View Source
const (
	DefaultHashValue = 0
)

Variables

This section is empty.

Functions

func GetIdOrNSFromOplog

func GetIdOrNSFromOplog(log *PartialLog) interface{}

func Hash

func Hash(hashObject interface{}) uint32

func LogEntryEncode

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

Types

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.M              `bson:"o"`
	Query         bson.M              `bson:"o2"`
	UniqueIndexes bson.M              `bson:"uk"`

	/*
	 * 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

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