event

package
v0.0.0-...-089673d Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 16 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// TransformationVersion is indicative of the revision of how Event Gateway transforms a request into CloudEvents format.
	TransformationVersion = "0.1"

	// CloudEventsVersion currently supported by Event Gateway
	CloudEventsVersion = "0.1"
)
View Source
const SystemEventReceivedType = TypeName("eventgateway.event.received")

SystemEventReceivedType is a system event emitted when the Event Gateway receives an event.

View Source
const SystemFunctionInvocationFailedType = TypeName("eventgateway.function.invocationFailed")

SystemFunctionInvocationFailedType is a system event emitted after successful function invocation.

View Source
const SystemFunctionInvokedType = TypeName("eventgateway.function.invoked")

SystemFunctionInvokedType is a system event emitted after successful function invocation.

View Source
const SystemFunctionInvokingType = TypeName("eventgateway.function.invoking")

SystemFunctionInvokingType is a system event emitted before invoking a function.

View Source
const (
	// TypeHTTPRequest is a special type of event HTTP requests that are not CloudEvents.
	TypeHTTPRequest = TypeName("http.request")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrAuthorizerDoesNotExists

type ErrAuthorizerDoesNotExists struct{}

ErrAuthorizerDoesNotExists occurs when there authorizer function doesn't exists.

func (ErrAuthorizerDoesNotExists) Error

type ErrEventTypeAlreadyExists

type ErrEventTypeAlreadyExists struct {
	Name TypeName
}

ErrEventTypeAlreadyExists occurs when event type with specified name already exists.

func (ErrEventTypeAlreadyExists) Error

type ErrEventTypeHasSubscriptions

type ErrEventTypeHasSubscriptions struct{}

ErrEventTypeHasSubscriptions occurs when there are subscription for the event type.

func (ErrEventTypeHasSubscriptions) Error

type ErrEventTypeNotFound

type ErrEventTypeNotFound struct {
	Name TypeName
}

ErrEventTypeNotFound occurs when event type cannot be found.

func (ErrEventTypeNotFound) Error

func (e ErrEventTypeNotFound) Error() string

type ErrEventTypeValidation

type ErrEventTypeValidation struct {
	Message string
}

ErrEventTypeValidation occurs when event type payload doesn't validate.

func (ErrEventTypeValidation) Error

func (e ErrEventTypeValidation) Error() string

type ErrParsingCloudEvent

type ErrParsingCloudEvent struct {
	Message string
}

ErrParsingCloudEvent occurs when payload is not valid CloudEvent.

func (ErrParsingCloudEvent) Error

func (e ErrParsingCloudEvent) Error() string

type Event

type Event struct {
	EventType          TypeName               `json:"eventType" validate:"required"`
	EventTypeVersion   string                 `json:"eventTypeVersion,omitempty"`
	CloudEventsVersion string                 `json:"cloudEventsVersion" validate:"required"`
	Source             string                 `json:"source" validate:"uri,required"`
	EventID            string                 `json:"eventID" validate:"required"`
	EventTime          *time.Time             `json:"eventTime,omitempty"`
	SchemaURL          string                 `json:"schemaURL,omitempty"`
	Extensions         zap.MapStringInterface `json:"extensions,omitempty"`
	ContentType        string                 `json:"contentType,omitempty"`
	Data               interface{}            `json:"data"`
}

Event is a default event structure. All data that passes through the Event Gateway is formatted to a format defined CloudEvents v0.1 spec.

func FromRequest

func FromRequest(r *http.Request) (*Event, error)

FromRequest takes an HTTP request and returns an Event along with path. Most of the implementation is based on https://github.com/cloudevents/spec/blob/master/http-transport-binding.md. This function also supports legacy mode where event type is sent in Event header.

func New

func New(eventType TypeName, mimeType string, payload interface{}) *Event

New return new instance of Event.

func (*Event) IsSystem

func (e *Event) IsSystem() bool

IsSystem indicates if the event is a system event.

func (Event) MarshalLogObject

func (e Event) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject is a part of zapcore.ObjectMarshaler interface

func (*Event) Validate

func (e *Event) Validate() error

Validate Event struct

type HTTPRequestData

type HTTPRequestData struct {
	Headers map[string]string   `json:"headers"`
	Query   map[string][]string `json:"query"`
	Body    interface{}         `json:"body"`
	Host    string              `json:"host"`
	Path    string              `json:"path"`
	Method  string              `json:"method"`
	Params  map[string]string   `json:"params"`
}

HTTPRequestData is a event schema used for sending events to HTTP subscriptions.

func NewHTTPRequestData

func NewHTTPRequestData(r *http.Request, eventData interface{}) *HTTPRequestData

NewHTTPRequestData returns a new instance of HTTPRequestData

type Service

type Service interface {
	GetEventType(space string, name TypeName) (*Type, error)
	ListEventTypes(space string, filters ...metadata.Filter) (Types, error)
	CreateEventType(eventType *Type) (*Type, error)
	UpdateEventType(newEventType *Type) (*Type, error)
	DeleteEventType(space string, name TypeName) error
}

Service represents service for managing event types.

type SystemEventReceivedData

type SystemEventReceivedData struct {
	Path    string            `json:"path"`
	Event   Event             `json:"event"`
	Headers map[string]string `json:"headers"`
}

SystemEventReceivedData struct.

type SystemFunctionInvocationFailedData

type SystemFunctionInvocationFailedData struct {
	Space      string      `json:"space"`
	FunctionID function.ID `json:"functionId"`
	Event      Event       `json:"event"`
	Error      error       `json:"error"`
}

SystemFunctionInvocationFailedData struct.

type SystemFunctionInvokedData

type SystemFunctionInvokedData struct {
	Space      string      `json:"space"`
	FunctionID function.ID `json:"functionId"`
	Event      Event       `json:"event"`
	Result     []byte      `json:"result"`
}

SystemFunctionInvokedData struct.

type SystemFunctionInvokingData

type SystemFunctionInvokingData struct {
	Space      string      `json:"space"`
	FunctionID function.ID `json:"functionId"`
	Event      Event       `json:"event"`
}

SystemFunctionInvokingData struct.

type Type

type Type struct {
	Space        string       `json:"space" validate:"required,min=3,space"`
	Name         TypeName     `json:"name" validate:"required"`
	AuthorizerID *function.ID `json:"authorizerId,omitempty"`

	Metadata metadata.Metadata `json:"metadata,omitempty"`
}

Type is a registered event type.

func (Type) MarshalLogObject

func (t Type) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject is a part of zapcore.ObjectMarshaler interface

type TypeName

type TypeName string

TypeName uniquely identifies an event type.

type Types

type Types []*Type

Types is an array of subscriptions.

Jump to

Keyboard shortcuts

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