mutator

package
v0.0.0-...-9be813a Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package mutator defines the operations to transform mutations into changes in the map as well as operations to write and read mutations to and from the database.

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxMutationSize represent the maximum allowed mutation size in bytes.
	MaxMutationSize = 16 * 1024
	// ErrReplay occurs when two mutations acting on the same entry & epoch
	// occur.
	ErrReplay = errors.New("mutation replay")
	// ErrSize occurs when the mutation size is larger than the allowed upper
	// bound.
	ErrSize = errors.New("mutation: too large")
	// ErrPreviousHash occurs when the mutation the hash of the previous
	// entry provided in the mutation does not match the previous entry
	// itself.
	ErrPreviousHash = errors.New("mutation: previous entry hash does not match the hash provided in the mutation")
	// ErrMissingKey occurs when a mutation does not have authorized keys.
	ErrMissingKey = errors.New("mutation: missing authorized key(s)")
	// ErrInvalidSig occurs when either the current or previous update entry
	// signature verification fails.
	ErrInvalidSig = errors.New("mutation: invalid signature")
	// ErrUnauthorized occurs when the mutation has not been signed by a key in the
	// previous entry.
	ErrUnauthorized = errors.New("mutation: unauthorized")
)

Functions

This section is empty.

Types

type MutationStorage

type MutationStorage interface {
	// ReadPage returns mutations in the interval (start, end] for mapID.
	// pageSize specifies the maximum number of items to return.
	// Returns the maximum sequence number returned.
	ReadPage(ctx context.Context, mapID, start, end int64, pageSize int32) (int64, []*pb.Entry, error)
	// ReadBatch returns mutations in the interval (start, ∞] for mapID.
	// ReadBatch will not return more than batchSize entries.
	// Returns the maximum sequence number returned.
	ReadBatch(ctx context.Context, mapID, start int64, batchSize int32) (int64, []*QueueMessage, error)
	// Write saves the mutation in the database. Write returns the sequence
	// number that is written.
	Write(ctx context.Context, mapID int64, mutation *pb.EntryUpdate) (int64, error)
}

MutationStorage reads and writes mutations to the database.

type Mutator

type Mutator interface {
	// Mutate verifies that this is a valid mutation for this item and
	// applies mutation to value.
	Mutate(value, mutation proto.Message) (proto.Message, error)
}

Mutator verifies mutations and transforms values in the map.

type QueueMessage

type QueueMessage struct {
	ID        int64
	Mutation  *pb.Entry
	ExtraData *pb.Committed
}

QueueMessage represents a change to a user, and associated data.

Directories

Path Synopsis
Package entry implements a simple replacement strategy as a mapper.
Package entry implements a simple replacement strategy as a mapper.

Jump to

Keyboard shortcuts

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