chunk

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2019 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunker

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

Chunker lets you spread items you want to send over multiple chunks. This type is not thread-safe.

func New

func New(s Sender) *Chunker

New returns a new Chunker.

func (*Chunker) Flush

func (c *Chunker) Flush() error

Flush sends remaining items in the current chunk, if any.

func (*Chunker) Send

func (c *Chunker) Send(it Item) error

Send will append an item to the current chunk and send the chunk if it is full.

type Item

type Item interface{}

Item could be e.g. a commit in an RPC that returns a chunked stream of commits.

type Sender

type Sender interface {
	// Reset should create a fresh response message.
	Reset()
	// Append should append the given item to the slice in the current response message
	Append(Item)
	// Send should send the current response message
	Send() error
}

Sender encapsulates a gRPC response stream and the current chunk that's being built.

Reset, Append, [Append...], Send, Reset, Append, [Append...], Send, ...

Jump to

Keyboard shortcuts

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