shared

package
v0.0.0-...-d221b79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditDeviceFromEvent

func EditDeviceFromEvent(e sd.State, device sd.StaticDevice) (sd.StaticDevice, bool, *nerr.E)

func ForwardAndStoreEvent

func ForwardAndStoreEvent(v events.Event, c Cache) (bool, *nerr.E)

func ForwardDevice

func ForwardDevice(device sd.StaticDevice, changes bool, c Cache) *nerr.E

func ForwardRoom

func ForwardRoom(room sd.StaticRoom, changes bool, c Cache) *nerr.E

func GetDeviceTypeByID

func GetDeviceTypeByID(id string) string

func GetNewDevice

func GetNewDevice(id string) (sd.StaticDevice, *nerr.E)

func GetNewRoom

func GetNewRoom(id string) (sd.StaticRoom, *nerr.E)

func HasTag

func HasTag(toCheck string, tags []string) bool

func PushAllDevices

func PushAllDevices(c Cache)

func SetDeviceField

func SetDeviceField(key string, value interface{}, updateTime time.Time, t sd.StaticDevice) (bool, sd.StaticDevice, *nerr.E)

SetDeviceField returns the new device, as well as a boolean denoting if the field was already set to the provided value.

If passing in an alert, we assume that the value is a statdefinition.Alert. Alerts are denoted by alert.<alertName>. Alerts always return true.

NOTE: If in the code you can formulate a separate StaticDevice and compare it, defer to that approach, as the performance gain is quite significant.

Types

type Cache

type Cache interface {
	CheckAndStoreDevice(device sd.StaticDevice) (bool, sd.StaticDevice, *nerr.E)
	CheckAndStoreRoom(room sd.StaticRoom) (bool, sd.StaticRoom, *nerr.E)

	GetDeviceRecord(deviceID string) (sd.StaticDevice, *nerr.E)
	GetRoomRecord(roomID string) (sd.StaticRoom, *nerr.E)
	GetAllDeviceRecords() ([]sd.StaticDevice, *nerr.E)
	GetAllRoomRecords() ([]sd.StaticRoom, *nerr.E)

	StoreDeviceEvent(toSave sd.State) (bool, sd.StaticDevice, *nerr.E)
	StoreAndForwardEvent(event events.Event) (bool, *nerr.E)

	RemoveDevice(deviceID string) *nerr.E       //Removes a specific device record
	RemoveRoom(roomID string) *nerr.E           //Removes a specific room record
	NukeRoom(roomID string) ([]string, *nerr.E) //Removes a room and all of it's devices

	GetCacheType() string
	GetCacheName() string
}

Cache is our state cache - it's meant to be a representation of the static indexes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL