Skip to content

CloudEvents: what these modules do not do

Each of these is a decision rather than a gap, and each is recorded in spec 0001 of the go/cloudevents module these replace.

It does not touch a transport

No connections, no subscriptions, no publishing. Encode returns a Wire: a content type, a map[string][]string and a []byte. What carries them is somebody else's problem.

The CloudEvents SDK ships protocol bindings, and they own the connection:

type Protocol struct{ Conn *nats.Conn }

func NewProtocol(url, sendSubject, receiveSubject string, natsOpts []nats.Option, ...)
func NewProtocolFromConn(conn *nats.Conn, sendSubject, receiveSubject string, ...)

NewProtocol dials. Even NewProtocolFromConn takes the raw connection and subscribes itself.

Adopting those would mean go/nats stops applying to CloudEvents traffic: no bounded subscriptions, no shed reporting, no controls lifecycle, no health probes. Two modules doing one job with different answers, and the safer one bypassed by the newer one.

TestNoTransportIsImported enforces the absence, in both modules, because a convenience helper taking a nats.Header would look like an improvement in review.

Structured mode is not the default

Structured mode puts the whole envelope in the body as JSON. That hides the attributes from anything routing on them, which is most of what the attributes are for, so binary mode stays the one to prefer.

It exists because a transport can limit its headers. SQS carries ten message attributes, and SNS refuses a body that is not UTF-8; an event with three extensions, or a protobuf payload, cannot cross either in binary mode. go/messaging spec 0014 is the consumer that needed it, and spec 0001 D2 is where it was left additive for one.

Batch mode, many events in one body, is not implemented.

It does not resolve a dataschema

The attribute is carried as an opaque, absolute URI and never dereferenced or validated against. That is go/schema's job, and keeping it out is what lets a service use CloudEvents with no registry at all.

go/schema and the CloudEvents formats are coupled by the URN grammar, which lives in go/urn, and by nothing else.

It does not use the SDK's Event type

envelope.Event is a struct with eight attribute fields, a map and a byte slice. See Why the specification and not the SDK.

Not decided yet

Whether the estate wants a correlation or causation attribute. Deferred by agreement with scoutdm: adding one later is easy and removing one is not, and neither of us can yet name the query it would answer.