Skip to content

Why CloudEvents

streamview reads messages from different brokers, webhooks from different services, and records from files. Each source has its own form. You do not have to send CloudEvents: streamview makes them. The server needs one form, so that the timeline works the same for all sources.

For each event, the server needs four facts:

  • Which lane the event is in.
  • Which time the event is at.
  • Which event it is, so that the server can ignore a duplicate.
  • Which order the event is a part of.

CloudEvents is an open specification that has a field for each of the first three facts: type, time, and source with id. For the fourth fact, streamview uses correlationid, or the trace ID in the traceparent field of the tracing extension.

Thus streamview did not need a format of its own. If your services already publish CloudEvents, streamview needs no configuration to read them.

Most messages in Kafka, NATS, and RabbitMQ are plain JSON. The adapters put such a message into an event. The topic or the subject becomes the type. The position of the message in the broker becomes the id. The message becomes data.

The position is the same each time that streamview reads the message. Thus, when you start streamview again with the same SQLite file, the server ignores the messages that it already has.

The one fact that the adapter cannot find is the order. The --correlation-field option gives the name of the field that has it, for example orderId.

A webhook and a plain JSON record have no topic. The server looks for the four facts in the data.

For a webhook, the name in the address and a header or a field of the body give the type. For a record, a field that you name gives the type, and a second field gives the time. If you name no fields, the server looks at the field names that most services use.

A record has no position in a broker. Thus the server calculates the id from the text of the record. The same record always gets the same id, and the server ignores it when it comes again.

streamview does not use the value of specversion, and it does not validate an event against the specification. It needs only id, source, and type. See Event format.