Documentation
¶
Overview ¶
This file manages schema modification.
There are a couple pieces to this:
1 Each schema modification is in a self contained directory with the a directory name 2. Each modification must contain an 'upgrade.sql' 3. Each modification *may* contain a 'downgrade.sql' script 4. Failure to include a downgrade script means we cannot downgrade past a particular version.
Every revision is stored in a directory named:
rev.<SHA1_HEX>.<description> Each directory contains: (mandatory) prev.txt -- contains the revision code for the previous patch (mandatory) upgrade.sql -- upgrade sql (optional) downgrade.sql -- downgrade sql
Index ¶
- Constants
- Variables
- func GetPatchDirectory(patch_root, revision string) (result string, err error)
- type DBRcs
- func (self *DBRcs) Changelog(patch_root string) (err error)
- func (self *DBRcs) Close() (err error)
- func (self *DBRcs) ComputeHistory(patch_root string) (err error)
- func (self *DBRcs) CreateNextRev(patch_root string, description string) (prev string, rev string, err error)
- func (self *DBRcs) CurrentDBVersion() (db_ver string, err error)
- func (self *DBRcs) Downgrade(patch_root, version string) (err error)
- func (self *DBRcs) FindLastVersion(patch_root string) (result string, err error)
- func (self *DBRcs) Init(config *util.MzConfig) (err error)
- func (self *DBRcs) InitVersioning() (err error)
- func (self *DBRcs) Upgrade(patch_root string, verbose bool) (err error)
- type Device
- type DeviceList
- type Position
- type Storage
- func (self *Storage) CheckNonce(nonce string) (bool, error)
- func (self *Storage) Close()
- func (self *Storage) DeleteDevice(devId string) (err error)
- func (self *Storage) GcDatabase(devId, userId string) (err error)
- func (self *Storage) GetDeviceInfo(devId string) (devInfo *Device, err error)
- func (self *Storage) GetDevicesForUser(userId, oldUserId string) (devices []DeviceList, err error)
- func (self *Storage) GetNonce() (string, error)
- func (self *Storage) GetPending(devId string) (cmd, ctype string, err error)
- func (self *Storage) GetPositions(devId string) (positions []Position, err error)
- func (self *Storage) GetUserFromDevice(deviceId string) (userId, name string, err error)
- func (self *Storage) Init() (err error)
- func (self *Storage) PurgeCommands(devId string) (err error)
- func (self *Storage) PurgePosition(devId string) (err error)
- func (self *Storage) RegisterDevice(userid string, dev Device) (devId string, err error)
- func (self *Storage) SetAccessToken(devId, token string) (err error)
- func (self *Storage) SetDeviceLocation(devId string, position Position) (err error)
- func (self *Storage) SetDeviceLock(devId string, state bool) (err error)
- func (self *Storage) StoreCommand(devId, command, cType string) (err error)
- func (self *Storage) Touch(devId string) (err error)
- type Unstructured
Constants ¶
const (
DB_VERSION = "20140707"
)
Variables ¶
var ErrDatabase = errors.New("Database Error")
var ErrUnknownDevice = errors.New("Unknown device")
Functions ¶
func GetPatchDirectory ¶
Types ¶
type DBRcs ¶
func (*DBRcs) ComputeHistory ¶
func (*DBRcs) CreateNextRev ¶
func (*DBRcs) CurrentDBVersion ¶
func (*DBRcs) FindLastVersion ¶
func (*DBRcs) InitVersioning ¶
type Device ¶
type Device struct { ID string // device Id User string // userID Name string PreviousPositions []Position HasPasscode bool // is device lockable LoggedIn bool // is the device logged in Secret string // HAWK secret PushUrl string // SimplePush URL Pending string // pending command LastExchange int32 // last time we did anything Accepts string // commands the device accepts AccessToken string // OAuth Access token }
Device information
type DeviceList ¶
type Position ¶
type Position struct { Latitude float64 Longitude float64 Altitude float64 Accuracy float64 Time int64 Cmd map[string]interface{} }
Device position
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage abstration
func Open ¶
func Open(config *util.MzConfig, logger *util.HekaLogger, metrics *util.Metrics) (store *Storage, err error)
Open the database.
func (*Storage) CheckNonce ¶
Does the user's nonce match?
func (*Storage) DeleteDevice ¶
func (*Storage) GcDatabase ¶
Remove old postion information for devices. This previously removed "expired" location records. We currently only retain the latest record for a user.
func (*Storage) GetDeviceInfo ¶
Return known info about a device.
func (*Storage) GetDevicesForUser ¶
func (self *Storage) GetDevicesForUser(userId, oldUserId string) (devices []DeviceList, err error)
Get all known devices for this user.
func (*Storage) GetPending ¶
Get pending commands.
func (*Storage) GetPositions ¶
func (*Storage) GetUserFromDevice ¶
func (*Storage) PurgeCommands ¶
func (*Storage) PurgePosition ¶
remove all tracking information for devId.
func (*Storage) RegisterDevice ¶
Register a new device to a given userID.
func (*Storage) SetAccessToken ¶
func (*Storage) SetDeviceLocation ¶
Add the location information to the known set for a device.
func (*Storage) SetDeviceLock ¶
Shorthand function to set the lock state for a device.
func (*Storage) StoreCommand ¶
Store a command into the list of pending commands for a device.