fix(pkg/sensor): use context to terminate go routines

This commit is contained in:
2019-06-17 23:37:48 +02:00
parent 502e3b3b1c
commit 2941f7a527
11 changed files with 298 additions and 80 deletions

View File

@ -1,15 +1,24 @@
package sensor
import "github.com/go-flucky/flucky/pkg/types"
import (
"context"
"sync"
"github.com/go-flucky/flucky/pkg/types"
)
// HumiditySensor is a interface to describe required functions to measure humidities
type HumiditySensor interface {
GetSensorModel() types.SensorModel
ReadHumidity() (*types.Humidity, error)
ReadHumidityWriteIntoChannel(humidityChannel chan<- *types.Humidity, errorChannel chan<- error, wg *sync.WaitGroup)
ReadHumidityContinously(ctx context.Context, humidityChannel chan<- *types.Humidity, errorChannel chan<- error)
}
// TemperatureSensor is a interface to describe required functions to measure temperatures
type TemperatureSensor interface {
GetSensorModel() types.SensorModel
ReadTemperature() (*types.Temperature, error)
ReadTemperatureWriteIntoChannel(temperatureChannel chan<- *types.Temperature, errorChannel chan<- error, wg *sync.WaitGroup)
ReadTemperatureContinously(ctx context.Context, temperatureChannel chan<- *types.Temperature, errorChannel chan<- error)
}