shadow

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceStrategyCoPartitioned

type BalanceStrategyCoPartitioned struct{}

func (*BalanceStrategyCoPartitioned) Name

func (strat *BalanceStrategyCoPartitioned) Name() string

func (*BalanceStrategyCoPartitioned) Plan

type DeviceState

type DeviceState struct {
	ID    string
	State DeviceStateMessage
}

TODO maybe use / embed DeviceStateMessage here - including Timestamp

type DeviceStateDB

type DeviceStateDB struct {
	ID              string
	ReportedVersion uint64
	ReportedState   postgres.Jsonb
	DesiredVersion  uint64
	DesiredState    postgres.Jsonb
}

type DeviceStateMessage added in v0.1.4

type DeviceStateMessage struct {
	Version   uint64
	State     json.RawMessage
	Timestamp time.Time
}

type Repo

type Repo interface {
	SetReported(DeviceState) (err error)
	GetReported(id string) (DeviceState, error)
	SetDesired(DeviceState) (err error)
	GetDesired(id string) (DeviceState, error)
}

func NewRedisRepo

func NewRedisRepo(addr string) (Repo, error)

type Server

type Server struct {
	Repo         Repo
	Producer     sarama.SyncProducer // Sync producer, we want to guarantee execution
	ProduceTopic string
	Log          *zap.Logger

	PubSub *pubsub.PubSub
}

Server is a data strcuture for shadow server

func (*Server) Get

func (s *Server) Get(context context.Context, request *shadowpb.GetRequest) (response *shadowpb.GetResponse, err error)

Get is a method to get a device state

func (*Server) PatchDesiredState

func (s *Server) PatchDesiredState(context context.Context, request *shadowpb.PatchDesiredStateRequest) (response *shadowpb.PatchDesiredStateResponse, err error)

PatchDesiredState is a method to patch a message to a device state

func (*Server) StreamReportedStateChanges

StreamReportedStateChanges is a method to start streaming of data from a device

type StateMerger

type StateMerger struct {
	SourceTopic    string // Incoming ticks
	MergedTopic    string // Full state with version
	RealDeltaTopic string // Deltas for each full state transition, with version

	ChangelogConsumerClient sarama.Client
	ChangelogProducerClient sarama.Client
	// contains filtered or unexported fields
}

func (*StateMerger) Cleanup

func (*StateMerger) ConsumeClaim

func (*StateMerger) Setup

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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