Documentation
¶
Index ¶
- Constants
- func Migrations(log logs.Log) []migration.Migrator
- type AlarmCause
- type Event
- type EventDB
- func (e *EventDB) AddEvent(eventType EventType, detail *EventDetail) error
- func (e *EventDB) AddListener(listener chan *Event)
- func (e *EventDB) Arm(userID int64, deviceID string) error
- func (e *EventDB) ArmDisarm(arm bool, userID int64, deviceID string) error
- func (e *EventDB) Disarm(userID int64, deviceID string) error
- func (e *EventDB) GetCloudQueue() ([]*Event, error)
- func (e *EventDB) IsAlarmTriggered() bool
- func (e *EventDB) IsArmed() bool
- func (e *EventDB) IsArmedAndUntriggered() bool
- func (e *EventDB) MarkInCloud(eventIDs []int64) error
- func (e *EventDB) Panic(userID int64, deviceID string)
- type EventDetail
- type EventType
Constants ¶
View Source
const MaxCloudSendEventAge = 24 * time.Hour
If we're resyncing with the cloud, then ignore events older than this. If this was infinite, and a system was connected to the cloud for the first time, then there could be a gigantic backlog. So we need to limit this.
View Source
const MaxEventCount = 100000
Maximum number of events to keep in the database.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlarmCause ¶
type AlarmCause string
const ( // SYNC-ALARM-CAUSES AlarmCauseCameraObject AlarmCause = "camera-object" // Camera detected an object AlarmCausePanic AlarmCause = "panic" // Panic button pressed )
type Event ¶
type Event struct {
ID int64 `json:"id" gorm:"primaryKey"`
Time dbh.IntTime `json:"time" gorm:"not null"`
EventType EventType `json:"eventType" gorm:"not null"`
Detail *dbh.JSONField[EventDetail] `json:"detail"`
InCloud bool `json:"inCloud" gorm:"not null"` // True if we've sent to the cloud
}
SYNC-EVENT
type EventDB ¶
EventDB tracks high level events, such as alarm activations
func (*EventDB) AddEvent ¶
func (e *EventDB) AddEvent(eventType EventType, detail *EventDetail) error
func (*EventDB) AddListener ¶
Add listener channel that will receive new events. Your channel should not block - give it a buffer and keep it drained.
func (*EventDB) GetCloudQueue ¶
Get the list of events that need to be sent to the cloud, from oldest to newest
func (*EventDB) IsAlarmTriggered ¶
func (*EventDB) IsArmedAndUntriggered ¶
func (*EventDB) MarkInCloud ¶
Mark the given events as being sent to the cloud.
type EventDetail ¶
type EventDetail struct {
UserID int64 `json:"userID,omitempty"` // Populated for arm,disarm,panic
DeviceID string `json:"deviceID,omitempty"` // Populated for arm,disarm,panic
AlarmCause AlarmCause `json:"alarmCause,omitempty"` // Populated for any alarm
CameraID int64 `json:"cameraID,omitempty"` // Populated for alarm, if cause is "camera-object"
}
SYNC-EVENT-DETAIL
Click to show internal directories.
Click to hide internal directories.