shadow

package
v0.0.0-...-0fa7426 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright © 2020 Randy Ridgley randy.ridgley@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidResponse = errors.New("invalid response from AWS IoT")

ErrInvalidResponse is returned if failed to parse response from AWS IoT.

View Source
var ErrRejected = errors.New("rejected")
View Source
var ErrVersionConflict = errors.New("version conflict")

ErrVersionConflict means thing state update was aborted due to version conflict.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Code        int    `json:"code"`
	Message     string `json:"message"`
	Timestamp   int64  `json:"timestamp"`
	ClientToken string `json:"clientToken"`
}

ErrorResponse represents error response from AWS IoT.

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Error implements error interface.

type Shadow

type Shadow interface {
	// Get thing state and update local state document.
	Get(ctx context.Context) (*ThingDocument, error)
	// Report thing state and update local state document.
	Report(ctx context.Context, state interface{}) (*ThingDocument, error)
	// Desire sets desired thing state and update local state document.
	Desire(ctx context.Context, state interface{}) (*ThingDocument, error)
	// Document returns full thing document.
	Document() *ThingDocument
	// Delete thing shadow.
	Delete(ctx context.Context) error
	// OnDelta sets handler of state deltas.
	OnDelta(func(delta map[string]interface{}))
	// OnError sets handler of asynchronous errors.
	OnError(func(error))
}

Shadow is an interface of Thing Shadow.

func New

func New(ctx context.Context, thing device.Thing) (Shadow, error)

type ThingDocument

type ThingDocument struct {
	State       ThingState `json:"state"`
	Version     int        `json:"version,omitempty"`
	Timestamp   int        `json:"timestamp,omitempty"`
	ClientToken string     `json:"clientToken,omitempty"`
}

ThingDocument represents Thing Shadow Document.

type ThingState

type ThingState struct {
	Desired  map[string]interface{} `json:"desired,omitempty"`
	Reported map[string]interface{} `json:"reported,omitempty"`
	Delta    map[string]interface{} `json:"delta,omitempty"`
}

ThingState represents Thing Shadow State.

Jump to

Keyboard shortcuts

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