Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{ IncrementalUpdate: true, }
DefaultOptions is a default Device Shadow options.
var ErrIncompatibleMapping = errors.New("unable to convert state to struct")
ErrIncompatibleMapping is returned if state can't be converted into struct.
var ErrInvalidResponse = errors.New("invalid response from AWS IoT")
ErrInvalidResponse is returned if failed to parse response from AWS IoT.
var ErrRejected = errors.New("rejected")
ErrRejected is returned if AWS IoT responded on rejected topic.
var ErrUnsupportedMapKeyType = errors.New("unsupported map key type")
ErrUnsupportedMapKeyType is returned if map key type is not string.
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 Metadata ¶
type Metadata struct {
Timestamp int `json:"timestamp"`
}
Metadata represents metadata of state attribute.
type NestedMetadata ¶
type NestedMetadata map[string]interface{}
NestedMetadata is JSON unmarshaller for state metadata.
func (*NestedMetadata) UnmarshalJSON ¶
func (n *NestedMetadata) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type NestedState ¶
type NestedState map[string]interface{}
NestedState is JSON unmarshaller for state metadata.
func (*NestedState) UnmarshalJSON ¶
func (n *NestedState) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Option ¶
Option is a functional option of UpdateJob.
func WithIncrementalUpdate ¶
WithIncrementalUpdate enables increamental update of state document. Enabled by default.
type Shadow ¶
type Shadow interface { mqtt.Handler // 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 NestedState)) // OnError sets handler of asynchronous errors. OnError(func(error)) }
Shadow is an interface of Thing Shadow.
type ThingDocument ¶
type ThingDocument struct { State ThingState `json:"state"` Metadata ThingStateMetadata `json:"metadata"` Version int `json:"version,omitempty"` Timestamp int `json:"timestamp,omitempty"` ClientToken string `json:"clientToken,omitempty"` MaybeIncomplete bool `json:"-"` }
ThingDocument represents Thing Shadow Document.
type ThingState ¶
type ThingState struct { Desired NestedState `json:"desired,omitempty"` Reported NestedState `json:"reported,omitempty"` Delta NestedState `json:"delta,omitempty"` }
ThingState represents Thing Shadow State.
type ThingStateMetadata ¶
type ThingStateMetadata struct { Desired NestedMetadata `json:"desired,omitempty"` Reported NestedMetadata `json:"reported,omitempty"` Delta NestedMetadata `json:"delta,omitempty"` }
ThingStateMetadata represents Thing Shadow State metadata.