ingest

package
v0.1.0-alpha7 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

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

func New(config Config) *Ingestor

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.

func (*Ingestor) Register

func (h *Ingestor) Register(router *mux.Router)

Register the Ingestor's routes onto the HTTP router.

Jump to

Keyboard shortcuts

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