Documentation ¶
Overview ¶
Package spec provides spec-version metadata.
For use by code that maps events using (prefixed) attribute name strings. Supports handling multiple spec versions uniformly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( VS *Versions V03 Version V1 Version )
Built-in un-prefixed versions.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute interface { Kind() Kind // Name of the attribute with respect to the current spec Version() with prefix PrefixedName() string // Name of the attribute with respect to the current spec Version() Name() string // Version of the spec that this attribute belongs to Version() Version // Get the value of this attribute from an event context Get(event.EventContextReader) interface{} // Set the value of this attribute on an event context Set(event.EventContextWriter, interface{}) error // Delete this attribute from and event context, when possible Delete(event.EventContextWriter) error }
Attribute is a named attribute accessor. The attribute name is specific to a Version.
type Kind ¶
type Kind uint8
Kind is a version-independent identifier for a CloudEvent context attribute.
func (Kind) IsRequired ¶
IsRequired returns true for attributes defined as "required" by the CE spec.
type Version ¶
type Version interface { // String name of the version, e.g. "1.0" String() string // Prefix for attribute names. Prefix() string // Attribute looks up a prefixed attribute name (case insensitive). // Returns nil if not found. Attribute(prefixedName string) Attribute // Attribute looks up the attribute from kind. // Returns nil if not found. AttributeFromKind(kind Kind) Attribute // Attributes returns all the context attributes for this version. Attributes() []Attribute // Convert translates a context to this version. Convert(event.EventContextConverter) event.EventContext // NewContext returns a new context for this version. NewContext() event.EventContext // SetAttribute sets named attribute to value. // // Name is case insensitive. // Does nothing if name does not start with prefix. SetAttribute(context event.EventContextWriter, name string, value interface{}) error }
Version provides meta-data for a single spec-version.
type Versions ¶
type Versions struct {
// contains filtered or unexported fields
}
Versions contains all known versions with the same attribute prefix.
func WithPrefix ¶
WithPrefix returns a set of versions with prefix added to all attribute names.
func WithPrefixMatchExact ¶
WithPrefixMatchExact returns a set of versions with prefix added to all attribute names.
func (*Versions) PrefixedSpecVersionName ¶
PrefixedSpecVersionName returns the specversion attribute PrefixedName