Documentation ¶
Index ¶
- Variables
- func VerifyAPIKey(apiTokens []string) kitendpoint.Middleware
- type HealthCheckResponse
- type HealthCheckServicer
- type Measurement
- type MeasurementMessage
- type ProtectedOperationRequest
- type ReadingResponse
- type Sensor
- type SensorReading
- type SensorReadingQueueMessage
- type SensorReadingsServicer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTokenVerificationFailure signifies that an auth token was missing or invalid ErrTokenVerificationFailure = errors.New("API token was missing or invalid") )
Functions ¶
func VerifyAPIKey ¶
func VerifyAPIKey(apiTokens []string) kitendpoint.Middleware
VerifyAPIKey checks the API key in a request
Types ¶
type HealthCheckResponse ¶
type HealthCheckResponse struct {
Status string `json:"status"`
}
HealthCheckResponse has fields with healthcheck status
type HealthCheckServicer ¶
HealthCheckServicer provides functions for performing component healthcheck
func NewHealthCheck ¶
func NewHealthCheck(c *config.Configuration) HealthCheckServicer
NewHealthCheck creates a new healthcheck
type Measurement ¶
type Measurement struct { Name string `json:"name"` Value float64 `json:"value"` Unit string `json:"unit"` }
Measurement contains the measurement details
type MeasurementMessage ¶
type MeasurementMessage struct { Timestamp int32 `json:"timestamp"` RelayID string `json:"relay_id"` Status string `json:"status"` Sensors []Sensor `json:"sensors"` APIToken string }
MeasurementMessage represents a message to be enqueued for later processing
func (*MeasurementMessage) FieldMap ¶
func (m *MeasurementMessage) FieldMap(req *http.Request) binding.FieldMap
FieldMap binds fields to their JSON labels
func (*MeasurementMessage) GetToken ¶
func (m *MeasurementMessage) GetToken() string
GetToken returns the API token associated with the request
type ProtectedOperationRequest ¶
type ProtectedOperationRequest interface {
GetToken() string
}
ProtectedOperationRequest is used to indicate a request type uses auth tokens
type ReadingResponse ¶
type ReadingResponse struct {
Status string `json:"status"`
}
ReadingResponse has fields with operation status
type Sensor ¶
type Sensor struct { ID string `json:"id"` SensorReadings []SensorReading `json:"readings"` }
Sensor represents a sensor with a collection of readings to be saved
type SensorReading ¶
type SensorReading struct { Timestamp int32 `json:"timestamp"` Measurements []Measurement `json:"measurements"` }
SensorReading represents a reading from a point in time with one or more measurements
func (*SensorReading) FieldMap ¶
func (s *SensorReading) FieldMap() binding.FieldMap
FieldMap binds fields to their JSON labels
type SensorReadingQueueMessage ¶
type SensorReadingQueueMessage struct { RelayID string `json:"relay_id"` SensorID string `json:"sensor_id"` ReadingTimestamp int32 `json:"reading_timestamp"` ReportingTimestamp int32 `json:"reporting_timestamp"` Measurements []Measurement `json:"measurements"` }
SensorReadingQueueMessage holds one or more measurements to be written
type SensorReadingsServicer ¶
type SensorReadingsServicer interface {
HandleMeasurementMessage(context.Context, interface{}) (interface{}, error)
}
SensorReadingsServicer provides functions for dealing with new sensor readings
func NewSensorReadingServicer ¶
func NewSensorReadingServicer(c *config.Configuration) SensorReadingsServicer
NewSensorReadingServicer creates a new healthcheck