stream_sum

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SumsJournal pb.Journal = "examples/stream-sum/sums"

Variables

Functions

func ChunkMappingKey

func ChunkMappingKey(m message.Message, b []byte) []byte

func FillPRNG

func FillPRNG(b []byte) []byte

FillPRNG generates fast but high-quality random entropy into the provided byte slice.

func NewChunkMapping

func NewChunkMapping(ctx context.Context, jc pb.JournalClient) (message.MappingFunc, error)

Types

type Chunk

type Chunk struct {
	ID    StreamID // Unique ID of the stream.
	SeqNo int      // Monotonic sequence number. One begins a new stream under this unique StreamID.
	Data  []byte   // Raw data included in the Value. If empty, this is the stream's final chunk.
}

Chunk is an ordered slice of stream content.

type StreamID

type StreamID [16]byte

StreamID uniquely identifies a stream.

func NewStreamID

func NewStreamID() StreamID

NewStreamID returns a new, globally unique StreamID.

type Sum

type Sum struct {
	ID    StreamID // Unique ID of the stream.
	SeqNo int      // SeqNo of last Chunk summed.
	Value uint64   // Computed sum through SeqNo.
}

Sum represents a partial or final CRC64 sum of a stream.

func (*Sum) Update

func (s *Sum) Update(chunk Chunk) (done bool, err error)

Update folds a Chunk into this Sum, returning whether this is the last Chunk of the Stream. Update requires that SeqNo be totally ordered, however replays of previous SeqNo are ignored.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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