scanbuf

package
v1.50.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package scanbuf provides a pooled buffer for bufio.Scanner instances that need to handle large JSONL lines (base64-encoded tool output, etc.). Allocating a fresh multi-MB buffer per scan is a significant allocation source for pollers that scan many files per tick; pooling amortizes it.

Index

Constants

View Source
const MaxTokenSize = 10 * 1024 * 1024

MaxTokenSize is the maximum line size supported by buffers from this pool. Pass it as bufio.Scanner's max — the scanner grows its buffer up to this ceiling only when a line actually requires it.

Variables

This section is empty.

Functions

func Get

func Get() *[]byte

Get returns a buffer for use as bufio.Scanner's initial buffer (pass scanbuf.MaxTokenSize as the scanner's max size). The caller must return it via Put when done.

func Put

func Put(buf *[]byte)

Put returns a buffer acquired from Get back to the pool.

Types

This section is empty.

Jump to

Keyboard shortcuts

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