Documentation
¶
Overview ¶
Package source defines where Records come from. Anything that can yield Records (a text file, stdin, a CSV, a network stream) implements Source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDrained = errors.New("source: drained")
ErrDrained is returned by Next when the source has no more records.
Functions ¶
This section is empty.
Types ¶
type InMemory ¶
type InMemory struct {
// contains filtered or unexported fields
}
InMemory is a Source backed by a fixed slice of records, for tests and wiring examples.
func NewInMemory ¶
NewInMemory returns a Source that yields the given records in order.
type Source ¶
type Source interface {
// Next returns the next record. It returns ErrDrained once the source
// is exhausted, and any other error is a real failure. Returned records
// must stay valid and unmodified across later Next calls, so a source
// must not reuse buffers between records. The built-ins copy.
Next(ctx context.Context) (domain.Record, error)
// Close releases underlying resources. It is safe to call more than
// once and concurrently with Next, and it must interrupt a blocked
// Next. The engine closes a source to unwind a pending read.
Close() error
}
Source yields Records until it is drained or closed.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package jsonl implements source.Source over JSON Lines: one JSON object per line.
|
Package jsonl implements source.Source over JSON Lines: one JSON object per line. |
|
Package text implements source.Source over line-oriented text: files and stdin.
|
Package text implements source.Source over line-oriented text: files and stdin. |
Click to show internal directories.
Click to hide internal directories.