Documentation
¶
Overview ¶
Package local implements a local model of the AirThings api. The types in this package decouple the needs of Smart Core from any limitations in the AirThings api.
Index ¶
- type Location
- func (m *Location) GetLatestSample(deviceID string) (api.DeviceSampleResponseEnriched, bool)
- func (m *Location) PullLatestSamples(deviceID string) (api.DeviceSampleResponseEnriched, <-chan api.DeviceSampleResponseEnriched, ...)
- func (m *Location) UpdateLatestSamples(samples api.GetLocationSamplesResponseEnriched) <-chan struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Location ¶
type Location struct {
// contains filtered or unexported fields
}
Location holds information about devices in a particular location.
func NewLocation ¶
func NewLocation() *Location
func (*Location) GetLatestSample ¶
func (m *Location) GetLatestSample(deviceID string) (api.DeviceSampleResponseEnriched, bool)
GetLatestSample returns the latest sample for the given device, or false if there is none.
func (*Location) PullLatestSamples ¶
func (m *Location) PullLatestSamples(deviceID string) (api.DeviceSampleResponseEnriched, <-chan api.DeviceSampleResponseEnriched, func())
PullLatestSamples subscribes to changes to the latest sample for the given device. Changes will be published to the returned chan, the current value will be returned immediately. Call the returned func to unsubscribe, the chan will be closed. It is safe to unsubscribe on a different goroutine.
func (*Location) UpdateLatestSamples ¶
func (m *Location) UpdateLatestSamples(samples api.GetLocationSamplesResponseEnriched) <-chan struct{}
UpdateLatestSamples writes updates and notifies subscribers. The returned chan will be closed when all subscribers have been notified.