stream_sum

package
v2.0.201+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Chunks = &topic.Description{
		Name: "examples/stream-sum/chunks",
	}
	Sums = &topic.Description{
		Name: "examples/stream-sum/sums",
	}
)

Functions

func FillPRNG

func FillPRNG(b []byte) []byte

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

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.
}

Value 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
summer is a consumer plugin (eg, should be built with `go build --buildmode=plugin`).
summer is a consumer plugin (eg, should be built with `go build --buildmode=plugin`).

Jump to

Keyboard shortcuts

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