Documentation
¶
Overview ¶
Package firestorefixture exercises the generated Firestore entity codec against the firestorebind runtime and the driver's wire protocol.
The calls below are what generation is directed by: each one names the type it binds, and the generator emits exactly the methods those calls need.
Index ¶
- Variables
- func ActiveReadingCount(ctx context.Context, active bool, opts ...datastore.ReadOption) (int64, error)
- func ActiveReadingCountTx(ctx context.Context, tx *firestorebind.Tx, active bool) (int64, error)
- func AnySensorOrNote(ctx context.Context, sensors []SensorID, note string, ...) iter.Seq2[Reading, error]
- func HotOrNamed(ctx context.Context, sensor SensorID, note string, from time.Time, ...) (firestorebind.Page[Reading], error)
- func HotOrNamedTx(ctx context.Context, tx *firestorebind.Tx, sensor SensorID, note string, ...) (firestorebind.Page[Reading], error)
- func InsertTask(ctx context.Context, t Task) (datastore.Key, error)
- func QueryReadings(ctx context.Context, q *datastore.Query) iter.Seq2[Reading, error]
- func ReadingTimes(ctx context.Context, sensor SensorID, opts ...datastore.ReadOption) (firestorebind.Page[Reading], error)
- func ReadingTimesTx(ctx context.Context, tx *firestorebind.Tx, sensor SensorID) (firestorebind.Page[Reading], error)
- func ReadingsBySensor(ctx context.Context, sensor SensorID, opts ...datastore.ReadOption) iter.Seq2[Reading, error]
- func ReadingsForAnySensor(ctx context.Context, sensors []SensorID, opts ...datastore.ReadOption) (firestorebind.Page[Reading], error)
- func ReadingsForAnySensorTx(ctx context.Context, tx *firestorebind.Tx, sensors []SensorID) (firestorebind.Page[Reading], error)
- func ReadingsFrom(ctx context.Context, cursor datastore.Cursor, size int, ...) (firestorebind.Page[Reading], error)
- func ReadingsFromTx(ctx context.Context, tx *firestorebind.Tx, cursor datastore.Cursor, size int) (firestorebind.Page[Reading], error)
- func ReadingsSince(ctx context.Context, from time.Time, size int, opts ...datastore.ReadOption) (firestorebind.Page[Reading], error)
- func ReadingsSinceTx(ctx context.Context, tx *firestorebind.Tx, from time.Time, size int) (firestorebind.Page[Reading], error)
- func ReadingsUnder(ctx context.Context, parent datastore.Key, opts ...datastore.ReadOption) iter.Seq2[Reading, error]
- func RemoveReading(ctx context.Context, r Reading) error
- func RenameInTransaction(ctx context.Context, key datastore.Key, title string) error
- func StoreReading(ctx context.Context, r Reading) (datastore.Key, error)
- func StoreReadings(ctx context.Context, rs []Reading) ([]datastore.Key, error)
- func StoreSession(ctx context.Context, s Session) (datastore.Key, error)
- func SweepKeys(ctx context.Context, keys []datastore.Key) error
- func TaskKeys(ctx context.Context, title string, opts ...datastore.ReadOption) (firestorebind.KeyPage, error)
- func TaskKeysTx(ctx context.Context, tx *firestorebind.Tx, title string) (firestorebind.KeyPage, error)
- func WarmReadingsBySensor(ctx context.Context, sensor SensorID, from time.Time, ...) iter.Seq2[Reading, error]
- type Reading
- type SensorID
- type Session
- type Site
- type Task
Constants ¶
This section is empty.
Variables ¶
var HotOrNamedIndex = datastore.Index{ Kind: hotOrNamedKind, Properties: []datastore.IndexProperty{ {Name: "sensor", Direction: datastore.Ascending}, {Name: "at", Direction: datastore.Ascending}, }, }
HotOrNamedIndex is the composite index HotOrNamed declares it needs.
It is a description, not a request: applying an index is an admin-API operation. Feed it to datastore.MarshalIndexYAML and to whatever owns index.yaml in this project.
var ReadingTimesIndex = datastore.Index{ Kind: readingTimesKind, Properties: []datastore.IndexProperty{ {Name: "sensor", Direction: datastore.Ascending}, {Name: "at", Direction: datastore.Ascending}, }, }
ReadingTimesIndex is the composite index ReadingTimes declares it needs.
It is a description, not a request: applying an index is an admin-API operation. Feed it to datastore.MarshalIndexYAML and to whatever owns index.yaml in this project.
var WarmReadingsBySensorIndex = datastore.Index{ Kind: warmReadingsBySensorKind, Properties: []datastore.IndexProperty{ {Name: "sensor", Direction: datastore.Ascending}, {Name: "at", Direction: datastore.Descending}, }, }
WarmReadingsBySensorIndex is the composite index WarmReadingsBySensor declares it needs.
It is a description, not a request: applying an index is an admin-API operation. Feed it to datastore.MarshalIndexYAML and to whatever owns index.yaml in this project.
Functions ¶
func ActiveReadingCount ¶
func ActiveReadingCount(ctx context.Context, active bool, opts ...datastore.ReadOption) (int64, error)
ActiveReadingCount queries Reading.
func ActiveReadingCountTx ¶
ActiveReadingCountTx is ActiveReadingCount inside a transaction, so its read joins the snapshot the transaction is built on rather than seeing what has been committed since.
func AnySensorOrNote ¶
func AnySensorOrNote(ctx context.Context, sensors []SensorID, note string, opts ...datastore.ReadOption) iter.Seq2[Reading, error]
AnySensorOrNote queries Reading.
One range can issue many requests; nothing here reports the boundary.
The filter is disjunctive. Datastore puts the whole filter in disjunctive normal form and caps the result at datastore.MaxDisjunctions, so an or nested inside an and multiplies rather than adds. Nothing counts that here: the expansion rule is the service's, and a count that disagreed would refuse a query that works.
This query combines filters and ordering in a shape that may require a composite index. Nothing in the toolchain verifies that one exists, so a missing index surfaces as FAILED_PRECONDITION on the first run.
func HotOrNamed ¶
func HotOrNamed(ctx context.Context, sensor SensorID, note string, from time.Time, opts ...datastore.ReadOption) (firestorebind.Page[Reading], error)
HotOrNamed queries Reading.
The filter is disjunctive. Datastore puts the whole filter in disjunctive normal form and caps the result at datastore.MaxDisjunctions, so an or nested inside an and multiplies rather than adds. Nothing counts that here: the expansion rule is the service's, and a count that disagreed would refuse a query that works.
func HotOrNamedTx ¶
func HotOrNamedTx(ctx context.Context, tx *firestorebind.Tx, sensor SensorID, note string, from time.Time) (firestorebind.Page[Reading], error)
HotOrNamedTx is HotOrNamed inside a transaction, so its read joins the snapshot the transaction is built on rather than seeing what has been committed since.
func InsertTask ¶
InsertTask exercises the put-if-absent verb over the id-keyed type.
func QueryReadings ¶
QueryReadings iterates a kind, which is what Scan would have been.
func ReadingTimes ¶
func ReadingTimes(ctx context.Context, sensor SensorID, opts ...datastore.ReadOption) (firestorebind.Page[Reading], error)
ReadingTimes queries Reading.
This is a projection: only the selected properties are read, and every other field of the returned value is its zero value. Do not write one back with Store or Update, which replace the whole entity and would therefore erase everything this query did not ask for.
A projection reads from an index, so every selected property must be indexed, and the service rejects projecting a property an equality filter already fixes.
func ReadingTimesTx ¶
func ReadingTimesTx(ctx context.Context, tx *firestorebind.Tx, sensor SensorID) (firestorebind.Page[Reading], error)
ReadingTimesTx is ReadingTimes inside a transaction, so its read joins the snapshot the transaction is built on rather than seeing what has been committed since.
func ReadingsBySensor ¶
func ReadingsBySensor(ctx context.Context, sensor SensorID, opts ...datastore.ReadOption) iter.Seq2[Reading, error]
ReadingsBySensor queries Reading.
One range can issue many requests; nothing here reports the boundary.
func ReadingsForAnySensor ¶
func ReadingsForAnySensor(ctx context.Context, sensors []SensorID, opts ...datastore.ReadOption) (firestorebind.Page[Reading], error)
ReadingsForAnySensor queries Reading.
func ReadingsForAnySensorTx ¶
func ReadingsForAnySensorTx(ctx context.Context, tx *firestorebind.Tx, sensors []SensorID) (firestorebind.Page[Reading], error)
ReadingsForAnySensorTx is ReadingsForAnySensor inside a transaction, so its read joins the snapshot the transaction is built on rather than seeing what has been committed since.
func ReadingsFrom ¶
func ReadingsFrom(ctx context.Context, cursor datastore.Cursor, size int, opts ...datastore.ReadOption) (firestorebind.Page[Reading], error)
ReadingsFrom queries Reading.
func ReadingsFromTx ¶
func ReadingsFromTx(ctx context.Context, tx *firestorebind.Tx, cursor datastore.Cursor, size int) (firestorebind.Page[Reading], error)
ReadingsFromTx is ReadingsFrom inside a transaction, so its read joins the snapshot the transaction is built on rather than seeing what has been committed since.
func ReadingsSince ¶
func ReadingsSince(ctx context.Context, from time.Time, size int, opts ...datastore.ReadOption) (firestorebind.Page[Reading], error)
ReadingsSince queries Reading.
func ReadingsSinceTx ¶
func ReadingsSinceTx(ctx context.Context, tx *firestorebind.Tx, from time.Time, size int) (firestorebind.Page[Reading], error)
ReadingsSinceTx is ReadingsSince inside a transaction, so its read joins the snapshot the transaction is built on rather than seeing what has been committed since.
func ReadingsUnder ¶
func ReadingsUnder(ctx context.Context, parent datastore.Key, opts ...datastore.ReadOption) iter.Seq2[Reading, error]
ReadingsUnder queries Reading.
One range can issue many requests; nothing here reports the boundary.
This query combines filters and ordering in a shape that may require a composite index. Nothing in the toolchain verifies that one exists, so a missing index surfaces as FAILED_PRECONDITION on the first run.
func RemoveReading ¶
RemoveReading is a key-only use.
func RenameInTransaction ¶
RenameInTransaction is a read-modify-write, which is the only thing a transaction is for here: nothing on this wire evaluates a predicate.
func StoreReading ¶
StoreReading is an encode-side use, whose type comes from the value argument.
func StoreReadings ¶
StoreReadings exercises the size-chunked batch write.
func StoreSession ¶
StoreSession is the encode-side use that directs the Session codec, and the only reason the ttl declaration reaches generated code.
func SweepKeys ¶
SweepKeys deletes by key rather than by value, which is the shape a keys-only query hands back and the shape a namespace teardown needs.
func TaskKeys ¶
func TaskKeys(ctx context.Context, title string, opts ...datastore.ReadOption) (firestorebind.KeyPage, error)
TaskKeys queries Task.
func TaskKeysTx ¶
func TaskKeysTx(ctx context.Context, tx *firestorebind.Tx, title string) (firestorebind.KeyPage, error)
TaskKeysTx is TaskKeys inside a transaction, so its read joins the snapshot the transaction is built on rather than seeing what has been committed since.
Types ¶
type Reading ¶
type Reading struct {
ID SensorID `firestore:"-,name"`
Parent datastore.Key `firestore:"-,parent"`
Ver int64 `firestore:"-,version"`
Sensor SensorID `firestore:"sensor"`
Note string `firestore:"note"`
At time.Time `firestore:"at"`
Scale float64 `firestore:"scale"`
Small float32 `firestore:"small"`
Count int64 `firestore:"count"`
Tiny uint16 `firestore:"tiny"`
Active bool `firestore:"active"`
Blob []byte `firestore:"blob"`
Ref datastore.Key `firestore:"ref"`
Where datastore.LatLng `firestore:"where"`
Tags []string `firestore:"tags,omitempty"`
Nested Site `firestore:"site"`
Extra *string `firestore:"extra"`
Body string `firestore:"body,noindex"`
Raw datastore.Value `firestore:"raw"`
}
Reading covers every property form the generator supports.
ID carries the key's name and is absent from the properties: Datastore stores a key beside them, so writing it as a property too would store identity twice.
func LoadReading ¶
LoadReading is a decode-side use: T appears only in the result, so the AST carries it even before any codec exists.
func LoadReadings ¶
func LoadReadings(ctx context.Context, keys []datastore.Key) ([]Reading, []datastore.Key, []datastore.Key, error)
LoadReadings exercises the key-chunked batch read and its three results.
func (*Reading) DecodeEntity ¶
DecodeEntity fills Reading from a Datastore entity. A property the entity does not carry leaves its field untouched, since Datastore is schemaless and an older writer is normal rather than exceptional.
func (Reading) EncodeEntity ¶
EncodeEntity converts Reading into a Datastore entity.
The key travels beside the properties rather than among them, so the identity fields are absent from the property map and cannot drift from it.
func (Reading) EntityVersion ¶
EntityVersion is the version Reading was read at. A non-zero version makes a later Store or Update conditional on the stored entity still being at it.
type SensorID ¶
type SensorID string
SensorID is a named string, so the codec has to convert rather than assign.
type Session ¶
type Session struct {
Token string `firestore:"-,name"`
Subject string `firestore:"subject"`
ExpiresAt time.Time `firestore:"expires_at,ttl"`
}
Session carries an expiry property. The ttl option changes nothing about how ExpiresAt is written — it is an ordinary timestamp property — and produces one generated fact: this kind's TTL policy targets "expires_at". Applying that policy stays a deployment step, since Datastore mode has no expiry on the wire.
func (Session) EncodeEntity ¶
EncodeEntity converts Session into a Datastore entity.
The key travels beside the properties rather than among them, so the identity fields are absent from the property map and cannot drift from it.
func (Session) ExpiryProperty ¶
ExpiryProperty is the property a TTL policy for kind Session should expire entities by. Nothing here applies one: Datastore mode has no expiry on the wire, so a policy is applied out of band with gcloud over this property.
type Site ¶
Site is a nested entity, stored as an entityValue. It declares no identity, because an entityValue carries no key.
func (*Site) DecodeEntity ¶
DecodeEntity fills Site from a Datastore entity. A property the entity does not carry leaves its field untouched, since Datastore is schemaless and an older writer is normal rather than exceptional.
func (Site) EncodeEntity ¶
EncodeEntity converts Site into a Datastore entity.
The key travels beside the properties rather than among them, so the identity fields are absent from the property map and cannot drift from it.
type Task ¶
Task uses an integer id rather than a name, and stores nothing but its own identity plus one property.
func (*Task) DecodeEntity ¶
DecodeEntity fills Task from a Datastore entity. A property the entity does not carry leaves its field untouched, since Datastore is schemaless and an older writer is normal rather than exceptional.
func (Task) EncodeEntity ¶
EncodeEntity converts Task into a Datastore entity.
The key travels beside the properties rather than among them, so the identity fields are absent from the property map and cannot drift from it.