weather

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package weather provides a collection of weather service implementations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTemperature is thrown when the converted temperature exceeds the allowed value range.
	ErrInvalidTemperature = errors.New("given combination of value and unit of temperature invalid")
	// ErrNotFound is thrown when a city does not exist in the database.
	ErrNotFound = errors.New("given city could not be found")
)

Functions

This section is empty.

Types

type InMemoryService

type InMemoryService struct {
	// contains filtered or unexported fields
}

InMemoryService is a in-memory implementation of a weather data service.

func NewInMemoryService

func NewInMemoryService() *InMemoryService

NewInMemoryService creates a new InMemoryService.

func (*InMemoryService) Cities

func (service *InMemoryService) Cities() []string

Cities returns a list of all stored cities.

func (*InMemoryService) Report

func (service *InMemoryService) Report(city string, temperature float64, unit Unit) (int64, error)

Report stores the current temperature report in the memory.

func (*InMemoryService) TemperatureIn

func (service *InMemoryService) TemperatureIn(city string, unit Unit) (Report, error)

TemperatureIn retrieves the current temperature in the city.

type Report

type Report struct {
	Timestamp   int64
	Temperature float64
}

Report stores weather information at a specific point in time.

type Service

type Service interface {
	Report(city string, temperature float64, unit Unit) (int64, error)
	TemperatureIn(city string, unit Unit) (Report, error)
	Cities() []string
}

Service stores and retrieves local weather information.

type Unit

type Unit int

Unit is a kind of temperature measurement unit

const (
	Kelvin Unit = iota
	Celsius
	Fahrenheit
)

Units of measurement for temperature ranges.

Jump to

Keyboard shortcuts

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