Skip to main content

Module shared

Module shared 

Source
Expand description

The device-shadow state machine shared by the IoT Data Plane handlers: deep-merge with null-deletion semantics, state.delta computation, per-leaf metadata timestamp stamping, and epoch-time helpers.

Kept in one place so update / get / delete cannot diverge on the shadow document’s wire shape.

Functions§

compute_delta
Compute state.delta: the subset of desired whose value differs from reported (a leaf missing from reported, or nested objects that differ). Returns None when there is no difference.
merge_into
Deep-merge patch into target. A null leaf in patch deletes that key from target (AWS shadow semantics); nested objects merge recursively; every other value overwrites.
now_millis
Current time as epoch milliseconds. Retained-message lastModifiedTime is epoch millis.
now_secs
Current time as epoch seconds. AWS shadow timestamp / metadata leaves are epoch seconds.
stamp_metadata
Stamp per-leaf metadata timestamps for every leaf touched by patch. A null leaf in patch removes the corresponding metadata leaf; objects recurse; arrays become an array of { "timestamp": ts } (one per element); scalars become { "timestamp": ts }.