local

package
v0.2024.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

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

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.

Jump to

Keyboard shortcuts

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