Skip to content

Add option to configure pre-defined "extraFields" to be added to each emitted thingEvent #2072

@thjaeckle

Description

@thjaeckle

With the Ditto Signal Enrichment it is possible to dynamically configure for a single subscriber of "Thing Events" (whenever a Thing is modified) to get additional fields, which were not part of the change.
For example, all attributes or a special attribute which is required for the event consumer to have a context.

This works and is great.
However, this is also quite "costly" for Ditto - as the Gateway (for SSE and WebSocket) or Connectivity service of Ditto has to do another "internal" round-trip to fetch those extraFields. There are optimizations in place in order to cache them in a "smart cache" (which updates itself, etc.), but in the worst case, e.g. if the cache is full, this means a lot of roundtrips and networking.

There are scenarios when specific fields are always needed - that's why I suggest to configure (in the things service configuration) pre-defined extraFields which are pro-actively always sent in a DittoHeader field.
When the Connection or WebSocket "demands" this extraField (and e.g. no other), it can just use it from this header without additional roundtrips.
This should be configurable on a namespace level.

Example configuration:

pre-defined-extra-fields = [
  {
    namespaces = [
      "*"
    ]
    condition = "exists(definition)" # could be an option to also support a RQL condition here
    extra-fields = [
      "definition"
    ]
  },
  {
    namespaces = [
      "org.eclipse.ditto.lamps"
    ]
    extra-fields = [
      "attributes/manufacturer",
      "attributes/serial"
    ]
  }
]

One example use case behind this:

  • We want to always get the definition of a Thing to "know" its current thing model (and semantic version of it)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions