Documentation
¶
Overview ¶
Package feed provides the test-data sources that are more than a file: rows of generated fake data and rows read from a database query.
Index ¶
- Constants
- Variables
- func Compile(kind string) (func(g *Generator, n uint64, row map[string]any) any, error)
- func Expand(s string, env, secrets map[string]string) string
- func SQLHost(driver, dsn string) (string, error)
- func SQLRows(ctx context.Context, driver, dsn, query string, limit int) ([]any, error)
- type Generator
Constants ¶
const MaxSQLRows = 1_000_000
MaxSQLRows bounds a SQL feeder: rows are held in memory for the run.
const MaxText = 64 << 20
MaxText bounds text(size): a generated payload is held in memory once per field and reused.
const SQLTimeout = time.Minute
SQLTimeout bounds the query.
Variables ¶
var Drivers = map[string]string{"postgres": "pgx", "mysql": "mysql"}
Drivers maps the scenario's driver names to database/sql drivers.
var Kinds = []string{
"name", "firstName", "lastName", "email", "username", "password", "phone", "uuid", "seq",
"company", "street", "city", "country", "zip", "word", "sentence", "paragraph",
"bool", "date", "datetime", "ipv4", "int(min,max)", "float(min,max)", "pick(a|b|c)", "text(size)",
}
Kinds lists the generator kinds, for help text and validation messages.
Functions ¶
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator makes a fresh row of fake data each time it is asked. Values that must not collide (email, username, seq) include the worker's index, so rows never repeat within a run, even across workers.
func NewGenerator ¶
NewGenerator compiles spec, a map of field name to kind, for worker index of count.
func (*Generator) SetAttempt ¶
SetAttempt marks a generator that takes over a lost worker's share (attempt 1, 2 ...), so its unique values differ from the lost worker's.