Designing a Small Data Exchange Contract
A data exchange specification should name the encoding, record structure, required fields, and handling of invalid or newer values.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Write one minimal sample
A sensor export might use UTF-8 and one JSON object per line, requiring a numeric reading and source ID. Include a row with an accented note to exercise text encoding alongside ordinary values.
Test boundaries between components
Give the reader an unsupported version and a structurally valid record with an invalid field. Treat those outcomes intentionally before connecting the writer. Record versioning sets expectations for data saved at different times.[1]
Write an example that reflects both producer and reader assumptions
A sensor report could fix UTF-8 JSON as encoding, milliseconds as the unit and reading_id as a required string. A reader should recover the reading ID verbatim and interpret duration five as five milliseconds. If an older sender used seconds, it needs an explicit format version or migration rule. See record versioning.
Example { "version":2, "reading_id":"R-04", "duration_ms":5 }
Required types: integer version, string ID, nonnegative integer duration
Absent duration and unknown version have distinct outcomes
Validate with a compatibility fixture
Save one current example, one supported old record and one malformed input. Exercise the producer and consumer independently. State which unknown fields can be ignored and how incomplete input is reported.