Documentation
¶
Overview ¶
Package weather provides current weather conditions
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores a single weather observation and notifies clients when this observation changes. Cache instances can be safely used with multiple goroutines.
func (*Cache) Get ¶
func (c *Cache) Get() (*Observation, <-chan struct{})
Get returns the current observation in this cache. Clients can use the returned channel to block until a new observation is available.
func (*Cache) Set ¶
func (c *Cache) Set(observation *Observation)
Set updates the observation in this cache and notifies all waiting clients.
type Observation ¶
type Observation struct { // Temperature in celsius Temperature float64 `xml:"temp_c"` // Weather conditions e.g 'Fair' or 'Partly Cloudy' Weather string `xml:"weather"` }
Observation represents a weather observation. These instances must be treated as immutable.
func Get ¶
func Get(station string) (observation *Observation, err error)
Get returns the current observation from a NOAA weather station. For example "KNUQ" means moffett field.
type OpenWeatherConn ¶
type OpenWeatherConn struct {
// contains filtered or unexported fields
}
OpenWeatherConn represents a connection to the open weather servers
func NewOpenWeatherConn ¶
func NewOpenWeatherConn(apiKey string) *OpenWeatherConn
NewOpenWeatherConn returns a new, long lived, open weather connection.
func (*OpenWeatherConn) Get ¶
func (c *OpenWeatherConn) Get(cityId string) ( observation *Observation, err error)
Get returns the weather for a particular city. The city ID for a city can be found by downloading city.list.json.gz from http://bulk.openweathermap.org/sample/. For example, Mountain View, CA is "5375480"
type PurpleAirConn ¶
type PurpleAirConn struct {
// contains filtered or unexported fields
}
PurpleAirConn represents a connection to purple air
func NewPurpleAirConn ¶
func NewPurpleAirConn() *PurpleAirConn
NewPurpleAirConn returns a new, long lived, purple air connection.
type Report ¶
type Report struct { // Temperature in celsius Temperature float64 // Weather conditions e.g 'Fair' or 'Partly Cloudy' Condition string // The Air Quality Index (0-500) AQI int }
Report represents a weather report which may include readings from multiple services.
type ReportCache ¶
type ReportCache struct {
// contains filtered or unexported fields
}
ReportCache stores a single weather report and notifies clients when this report changes. ReportCache instances can be safely used with multiple goroutines.
func NewReportCache ¶
func NewReportCache() *ReportCache
NewReportCache creates a new report cache containing a zero value report.
func (*ReportCache) Close ¶
func (r *ReportCache) Close() error
Close frees resources associated with this report cache.
func (*ReportCache) Get ¶
func (r *ReportCache) Get() (*Report, <-chan struct{})
Get returns a shallow copy of the current report. Clients can use the returned channel to block until a new report is available.
func (*ReportCache) Set ¶
func (r *ReportCache) Set(report *Report)
Set updates the report in this report cache and notifies all waiting clients.