Documentation ¶
Overview ¶
package db provides some overarching variables, structs, and interfaces that different database implementations can use and implement and consumers can expect.
Index ¶
Constants ¶
const ( // TypeLabel is for labeling metrics; if there is a single metric for // successful queries, the typeLabel and corresponding type can be used // when incrementing the metric. TypeLabel = "type" InsertType = "insert" DeleteType = "delete" ReadType = "read" PingType = "ping" BlacklistReadType = "blacklistRead" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventType ¶
type EventType int
EventType is an enum for specifying the type of event being stored.
func ParseEventType ¶
ParseEventType returns the enum when given a string.
type Pruner ¶
type Pruner interface { GetRecordsToDelete(shard int, limit int, deathDate int64) ([]RecordToDelete, error) // PruneRecords(records []int) error DeleteRecord(shard int, deathdate int64, recordID int64) error }
Pruner is something that can get a list of expired records and delete them. Deleting is done individually.
type Record ¶
type Record struct { Type EventType `json:"recordtype" bson:"recordtype" gorm:"recordtype:int"` DeviceID string `json:"deviceid" bson:"deviceid"` BirthDate int64 `json:"birthdate" bson:"birthdate"` DeathDate int64 `json:"deathdate" bson:"deathdate"` Data []byte `json:"data" bson:"data"` Nonce []byte `json:"nonce" bson:"nonce"` Alg string `json:"alg" bson:"alg"` KID string `json:"kid" bson:"kid" gorm:"Column:kid"` RowID string `json:"rowid"` }
Record is the struct used to insert an event into the database. It includes the marshaled, and possibly encrypted, event ("Data") and then other metadata to be used for the record. If the data is encrypted, the Nonce, Alg, and KID values will be needed to determine how to correctly decrypt it.
type RecordGetter ¶
type RecordGetter interface { GetRecords(deviceID string, limit int, stateHash string) ([]Record, error) GetRecordsOfType(deviceID string, limit int, eventType EventType, stateHash string) ([]Record, error) GetStateHash(records []Record) (string, error) }
RecordGetter is something that can get records, including only getting records of a certain type.
type RecordToDelete ¶
type RecordToDelete struct { DeathDate int64 `json:"deathdate" bson:"deathdate"` RecordID int64 `json:"recordid" bson:"recordid"` }
RecordToDelete is the information needed to get out of the database in order to call the DeleteRecord function
Directories ¶
Path | Synopsis |
---|---|
package batchDeleter provides a wrapper around the db.Pruner to provide a way to get expired records at a given interval and delete them at a separate given interval.
|
package batchDeleter provides a wrapper around the db.Pruner to provide a way to get expired records at a given interval and delete them at a separate given interval. |
package batchInserter provides a wrapper around the db.Inserter to provide a way to group records together before inserting, in order to decrease database requests needed for inserting.
|
package batchInserter provides a wrapper around the db.Inserter to provide a way to group records together before inserting, in order to decrease database requests needed for inserting. |
package cassandra provides a way to connect to a cassandra database to keep track of device events.
|
package cassandra provides a way to connect to a cassandra database to keep track of device events. |
package postgresql provides a way to connect to a postgresql database to keep track of device events.
|
package postgresql provides a way to connect to a postgresql database to keep track of device events. |
Package dbretry contains structs that implement various db interfaces as well as consume them.
|
Package dbretry contains structs that implement various db interfaces as well as consume them. |