Documentation
¶
Overview ¶
Package generation is what `brevis-sql build` writes when a model is rebuilt, and what `brevis-sql-api` reads to know its cached answers are stale -- through a Redis client of its own, written against RESP2.
A CLIENT IN THIS FILE AND NOT A LIBRARY, for the reason the BigQuery REST endpoint is two hundred lines in this module rather than the official client: `brevis-sql` runs as a step in every pipeline that builds a model, its weight is guarded by `sql-weight.sh`, and what it asks of Redis is SET. What the API asks is GET, MGET and SET with an expiry. Five commands, one protocol, specified and short; the cost is this file and its fuzz test.
WHAT IT DOES NOT DO: Sentinel, Cluster redirection, pipelining, pub/sub. Cluster works only because every key this module writes carries the `{brevis}` hash tag, which puts an MGET's keys on one slot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Model ¶
Model is a relation's name as a generation is keyed: the same for the build that writes it, the step that bumps it and the API that reads it.
FOUND IN THE SHIP REVIEW: those three named a model three ways and nothing made them agree, so a generation was written under one name and read under another, and an answer stayed until its ttl. Postgres folds an unquoted identifier to lower case, so the name is lowered there; BigQuery names are case-sensitive and may lead with the project, which is dropped -- a build writes `schema.name` whatever project it ran in.
func NewToken ¶
func NewToken() string
NewToken is a fresh generation: when it was written, and sixteen random hex digits.
NOT A RUN ID, because a step is given none -- the engine hands a step its parameters and nothing that names the run. What a generation has to be is DIFFERENT after every rebuild, and this is; the time in front is for the human reading Redis, not for any comparison.
func Read ¶
Read is each model's generation, in the order asked, in one round trip. A model with none is "": built by something that does not write one, or never built -- either way a stable part of a cache key.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a small pool of connections to one Redis.
func Open ¶
Open reads an address -- `host:port`, `redis://[user:password@]host:port[/db]` or `rediss://` for TLS -- and connects to nothing yet.
AN ERROR NEVER QUOTES THE ADDRESS, which may carry a password.