Documentation ¶
Overview ¶
Package rivers provides functionality to read water temperature and water level data recorded by sensors installed in rivers in Ireland.
Index ¶
- func RunCLI()
- func RunPuller()
- func RunServer()
- type Client
- func (c *Client) GetDayLevel(stationID string) ([]Reading, error)
- func (c *Client) GetDayTemperature(stationID string) ([]Reading, error)
- func (c *Client) GetDayVoltage(stationID string) ([]Reading, error)
- func (c *Client) GetGroupWaterLevel(groupID int) ([]Reading, error)
- func (c *Client) GetLatestWaterLevels() ([]StationWaterLevelReading, error)
- func (c *Client) GetMonthLevel(stationID string) ([]Reading, error)
- func (c *Client) GetMonthTemperature(stationID string) ([]Reading, error)
- func (c *Client) GetWeekLevel(stationID string) ([]Reading, error)
- func (c *Client) GetWeekTemperature(stationID string) ([]Reading, error)
- type FileStore
- type Puller
- type Reading
- type Saver
- type Sensor
- type SensorReading
- type Station
- type StationWaterLevelReading
- type WaterLevelProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client holds data required to communicate with the web service.
func NewClient ¶
func NewClient() *Client
NewClient knows how to construct a new default rivers client. The client will be used to retrieve information about various measures recorded by sensors.
func (*Client) GetDayLevel ¶
GetDayLevel knows how to return water level readings recorded for last 24hr period for the given stationID number.
func (*Client) GetDayTemperature ¶
GetDayTemperature knows how to return water temperature recorded for last 24hr period for the given stationID number.
func (*Client) GetDayVoltage ¶
GetDayVoltage knows how to return sensor voltage data recorded over last 24h.
func (*Client) GetGroupWaterLevel ¶
GetGroupWaterLevel returns water level readings for stations that belong to provided groupID. The value of roupID should be between 1 and 28.
func (*Client) GetLatestWaterLevels ¶
func (c *Client) GetLatestWaterLevels() ([]StationWaterLevelReading, error)
GetLatestWaterLevels returns latest water level readings from sensors.
func (*Client) GetMonthLevel ¶
GetMonthLevel knows how to return water level readings recorded for last 4 weeks period for the given stationID number.
func (*Client) GetMonthTemperature ¶
GetMonthTemperature knows how to return water temperature recorded for last 4 weeks period for the given stationID number.
func (*Client) GetWeekLevel ¶
GetWeekLevel knows how to return water level readings recorded for last week period for the given stationID number.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore represents a data store.
func NewFileStore ¶
NewFileStore takes a path and creates a new file store. It errors if the filepath is empty.
func (*FileStore) Records ¶
func (fs *FileStore) Records() ([]StationWaterLevelReading, error)
Records returns records stored in a file.
func (*FileStore) Save ¶
func (fs *FileStore) Save(records []StationWaterLevelReading) error
Save takes a slice of records and saves them in a file.
type Reading ¶
Reading represents water level recorded by a gauge at the particular time.
func LoadCSV ¶
LoadCSV knows how to open and read given csv file. Upon successful run it returns a slice of level structs.
type Saver ¶
type Saver interface {
Save(records []StationWaterLevelReading) error
}
Saver is the interface that wraps the basic Save method.
Save takes records and stores them in a store.
type Sensor ¶
type Sensor struct { StationID string `json:"station_id"` StationName string `json:"station_name"` Type string `json:"type"` Value string `json:"value"` Timestamp string `json:"timestamp"` ErrorCode int `json:"err_code"` RegionID string `json:"region_id"` }
Sensor holds data from a station.
type SensorReading ¶
type SensorReading struct { StationID string StationName string SensorID string RegionID int Value float64 Timestamp time.Time ErrCode int }
SensorReading represents data received from a sensor.
type Station ¶
type Station struct { ID string `json:"id"` Name string `json:"name"` RegionID int `json:"region_id"` RegionName string `json:"region_name"` Lat float64 `json:"lat"` Long float64 `json:"long"` Sensors []Sensor `json:"sensors"` }
Station represents a station with multiple sensors.
type StationWaterLevelReading ¶
type StationWaterLevelReading struct { StationID string `json:"station_id"` Name string `json:"name,omitempty"` RegionID int `json:"region_id,omitempty"` Readtime time.Time `json:"readtime"` WaterLevel float64 `json:"water_level"` }
StationWaterLevelReading represents data received from a water level sensor.
func GetLatestWaterLevels ¶
func GetLatestWaterLevels() ([]StationWaterLevelReading, error)
GetLatestWaterLevels returns latests readings from all stations.
This func uses default rivers' client under the hood.
type WaterLevelProvider ¶
type WaterLevelProvider interface {
GetLatestWaterLevels() []StationWaterLevelReading
}
WaterLevelProvider is the interface that wraps the GetLatestWaterLevels method.
GetLatestWaterLevels returns a slice of water level readings from sensors.