persist

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: 5 Imported by: 0

Documentation

Overview

Package persist provides logic for handling inbound readings and persisting them to a repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger   *log.Logger
	Readings Repository
}

The Config type contains fields used to configure a Persistor.

type Persistor

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

The Persistor type is used to handle inbound readings and persist them to the Repository implementation.

func New

func New(config Config) *Persistor

New returns a new instance of the Persistor type, configured using the provided Config.

func (*Persistor) HandleEvent

func (h *Persistor) HandleEvent(ctx context.Context, message json.RawMessage) error

HandleEvent handles an inbound JSON payload. It expects the payload to be unmarshallable into a storage.Reading type. Once decoded, the reading is persisted via the Repository implementation.

type Repository

type Repository interface {
	Save(ctx context.Context, reading reading.Reading) error
}

The Repository interface describes types that can store readings.

Jump to

Keyboard shortcuts

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