Documentation
¶
Overview ¶
Package ingest provides the HTTP handling methods for inbound sensor readings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Writer EventWriter
APIKey string
Logger *log.Logger
}
The Config type contains fields used to configure the Ingestor.
type EventWriter ¶
type EventWriter interface {
Write(ctx context.Context, message json.RawMessage) error
}
The EventWriter interface describes types that can publish messages onto an event stream.
type Ingestor ¶
type Ingestor struct {
// contains filtered or unexported fields
}
The Ingestor type is responsible for responding to HTTP requests to publish events onto an event sink and probing for liveness/readiness.
func New ¶
New returns a new instance of the Ingestor type that will publish Reading events onto the provided EventWriter implementation to the desired subject. The Ingestor.Register method should be used to register the handling methods onto an HTTP router.
func (*Ingestor) Ingest ¶
func (h *Ingestor) Ingest(w http.ResponseWriter, r *http.Request)
Ingest readings from the request body, publishing each onto the configured EventWriter. This method expects the request body to contain a JSON stream of individual readings. Each reading is validated then published. It expects basic authentication on the inbound request where the password matches the configured API key.