batch

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package batch coalesces what a run writes for a host to which each write is costly, such as a debug adapter sending an event per write or a page posted a message per write. The language writes each print at once (stdlib.md, File); batching is the host's choice.

Index

Constants

View Source
const Size = 4096

Size is how many bytes a batch holds before it is sent without waiting for the delay.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

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

Writer collects writes to several streams and sends them in batches, in the order written: a write to another stream sends what the first one holds first. A batch is sent once it holds Size bytes, delay after its first write, and at Flush.

func New

func New(delay time.Duration, send func(stream string, p []byte)) *Writer

New returns a Writer that hands each batch to send, under its lock, so send must not write to the Writer.

func (*Writer) Flush

func (w *Writer) Flush()

Flush sends what is held now.

func (*Writer) Stream

func (w *Writer) Stream(name string) io.Writer

Stream returns the writer of one stream.

Jump to

Keyboard shortcuts

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