eventgrid

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudEvent

type CloudEvent struct {
	Time        time.Time `json:"time"`
	Data        any       `json:"data,omitempty"`
	SpecVersion string    `json:"specversion"`
	Type        string    `json:"type"`
	Source      string    `json:"source"`
	ID          string    `json:"id"`
	Subject     string    `json:"subject,omitempty"`
	DataSchema  string    `json:"dataschema,omitempty"`
}

CloudEvent represents a CloudEvent.

func NewCloudEvent

func NewCloudEvent(source, eventType string, data any, options ...CloudEventOption) (CloudEvent, error)

NewCloudEvent creates a new CloudEvent. By default a new UUID is generated for the ID, the current time is used for the Time and specversion is set to "1.0". This can be overridden by providing options.

func (CloudEvent) JSON

func (e CloudEvent) JSON() []byte

JSON returns the JSON representation of the CloudEvent.

type CloudEventOption

type CloudEventOption func(o *CloudEventOptions)

CloudEventOption is a function that sets options on a CloudEvent.

type CloudEventOptions

type CloudEventOptions struct {
	Time        time.Time
	ID          string
	Subject     string
	DataSchema  string
	SpecVersion string
}

CloudEventOptions contains options for a CloudEvent.

type Event

type Event struct {
	Data            any       `json:"data"`
	Topic           string    `json:"topic"`
	Subject         string    `json:"subject"`
	Type            string    `json:"eventType"`
	Time            time.Time `json:"eventTime"`
	ID              string    `json:"id"`
	DataVersion     string    `json:"dataVersion,omitempty"`
	MetadataVersion string    `json:"metadataVersion,omitempty"`
}

Event represents an event (Event Grid schema).

func NewEvent

func NewEvent(subject, eventType string, data any, options ...EventGridEventOption) (Event, error)

NewEvent creates a new event (EventGrid schema).

func (Event) JSON

func (e Event) JSON() []byte

JSON returns the JSON representation of the Event.

type EventGridEventOption

type EventGridEventOption func(o *EventOptions)

EventOption is a function that sets options on an Event.

type EventOptions

type EventOptions struct {
	Topic           string
	ID              string
	Time            time.Time
	DataVersion     string
	MetadataVersion string
}

EventOptions contains options for an Event.

type Schema

type Schema string

Schema represents the schema of the event.

const (
	// CloudEvents is the CloudEvents schema.
	SchemaCloudEvents Schema = "CloudEvents"
	// EventGrid is the Event Grid schema.
	SchemaEventGrid Schema = "EventGrid"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL