Documentation ¶
Overview ¶
Package events provides methods for working with CloudEvents.
Package events
Index ¶
Constants ¶
const CloudEventsSpecVersion = "1.0"
The version of the CloudEvents specification the package adheres to.
Variables ¶
This section is empty.
Functions ¶
func RegisteredTypes ¶
RegisteredTypes returns a map of all registered event types. The key is the event type name.
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is an instance of a certain event type.
func (Event) Attributes ¶
Attributes returns the attributes attached to the event. These attributes are optional and this function may return an empty map.
func (*Event) MarshalJSON ¶
MarshalJSON serializes the event to JSON, following the CloudEvents specification.
func (*Event) MarshalProto ¶
MarshalProto serializes the event to the CloudEvents Protobuf wire format.
func (Event) Message ¶
func (e Event) Message() protoreflect.ProtoMessage
Message returns the underlying message (aka data) of the event.
type EventContentType ¶
type EventContentType string
The content type of an event.
const ( ContentTypeProtobuf EventContentType = "application/protobuf" ContentTypeJSON EventContentType = "application/json" )
type EventNotFoundError ¶
type EventNotFoundError struct {
// contains filtered or unexported fields
}
EventNotFoundError indicates that no matching PubSub provider was found.
func (*EventNotFoundError) Error ¶
func (e *EventNotFoundError) Error() string
type EventType ¶
type EventType struct {
// contains filtered or unexported fields
}
EventType describes the type of an event.
func RegisterType ¶
func RegisterType(name, source string, desc protoreflect.MessageDescriptor) *EventType
RegisterType registers a new event type. It is intended for use in init() functions for each event type. It will panic if errors are encountered.
func (EventType) Descriptor ¶
func (t EventType) Descriptor() protoreflect.MessageDescriptor
Descriptor returns the message descriptor for messages of the event type.
func (*EventType) New ¶
func (t *EventType) New(id string, msg protoreflect.ProtoMessage, attributes map[string]any) (*Event, error)
New creates a new event of a given type.
The "id" and "msg" parameters are required. The "attributes" parameter supports the following value types:
- string
- int
- bool
- []byte
- time.Time