Skip to content

ADR 21_event store

MaxThom edited this page May 26, 2025 · 1 revision

Architecture Design Record

ADR-21, Events Store

The goal is to have an event store that will keep tracks of all generated events of the system. This must be link to the device twin using K8s style of references. Needs to add to SDK a generate events object/functions.

  • add a new event object in surreal
  • liscen to all events and write to event store
  • new event object part of an event with msg, desc, related object Event: {id: uuidv7, title: "device online", message: "device 'xx' has came online", related: {api:"device", apiVersion:"v1alpha", name:"xx", namespace:"default"}}
  • Payload is the related object
  • The event could be in a header, cbor, protobuf, or json

events layout

events stack with 30 minutes of receiving a new one

apiVersion: "mir/v1alpha"
kind: "event"
meta:
  name: ""
  namespace: ""
  labels: <string, string>
  annotations: <string, string>
spec:
  type: [normal|warning]
  reason: <string> # Short msg
  message: <string> # Long msg
  payload: <json> # Extra data in json
  relatedObject:
    apiVersion: <string>
    kind: <string>
    meta:
      name: <string>
      namespace: <string>
status:
  count: <number>
  first_at: <datetime>
  last_at: <datetime>

event message Payload

meta:
  name: ""
  namespace: ""
  labels: <string, string>
  annotations: <string, string>
spec:
  type: [normal|warning]
  reason: <string> # Short msg
  message: <string> # Long msg
  payload: <json> # Extra data in json
  relatedObject:
    apiVersion: <string>
    kind: <string>
    meta:
      name: <string>
      namespace: <string>
  • name is random guid
  • namespace could be derived from the related object
  • payload is going to be json with structpb
  • labels:
    • route:
    • original-trigger:
  • subject id is the id of the related object

Clone this wiki locally