triggers

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHTTPInvalidContentType is returned when an invalid Content-Type provided.
	ErrHTTPInvalidContentType = errors.New("invalid Content-Type")
	// ErrHTTPInvalidBody is returned when the HTTP body is invalid.
	ErrHTTPInvalidBody = errors.New("invalid body")
)
View Source
var (
	// ErrTriggerNameIncorrect is returned when the provided trigger
	// name does not match the payload trigger name.
	ErrTriggerNameIncorrect = errors.New("trigger name incorrect")
	// ErrTriggerPayloadMalformed is returned if there is an error
	// with the payload from the Function host.
	ErrTriggerPayloadMalformed = errors.New("trigger payload malformed")
)

Functions

This section is empty.

Types

type EventGrid added in v0.13.0

type EventGrid struct {
	Time     time.Time
	Metadata EventGridMetadata
	ID       string
	Topic    string
	Subject  string
	Type     string
	Data     data.Raw
	Schema   EventGridSchema
}

EventGrid represents an Event Grid trigger. It handles both Cloud Events and Event Grid events. For both types of events, the 'Topic' is used to describe the source of the event. This to match the nomenclature of the Event Grid service.

func NewEventGrid added in v0.13.0

func NewEventGrid(r *http.Request, name string, options ...EventGridOption) (*EventGrid, error)

NewEventGrid creates and returns an Event Grid trigger from the provided *http.Request.

func (EventGrid) Parse added in v0.13.0

func (t EventGrid) Parse(v any) error

Parse the data from the Event Grid trigger into the provided value.

type EventGridMetadata added in v0.13.0

type EventGridMetadata struct {
	Metadata
	Data data.Raw `json:"data"`
}

EventGridMetadata represents the metadata for an Event Grid trigger.

type EventGridOption added in v0.13.0

type EventGridOption func(o *EventGridOptions)

EventGridOption is a function that sets options on an Event Grid trigger.

type EventGridOptions added in v0.13.0

type EventGridOptions struct{}

EventGridOptions contains options for an Event Grid trigger.

type EventGridSchema added in v0.13.0

type EventGridSchema int

EventGridSchema is the type of schema that the Event Grid trigger is using.

const (
	// EventGridSchemaCloudEvents is the CloudEvents schema.
	EventGridSchemaCloudEvents EventGridSchema = iota
	// EventGridSchemaEventGrid is the Event Grid schema.
	EventGridSchemaEventGrid
)

func (EventGridSchema) String added in v0.13.0

func (s EventGridSchema) String() string

String returns the string representation of the EventGridSchema.

type Generic added in v0.15.0

type Generic struct {
	Metadata map[string]any
	Data     data.Raw
}

Generic represents a generic Function App trigger. With custom handlers many triggers that are not HTTP triggers share the same data structure.

func NewGeneric added in v0.15.0

func NewGeneric(r *http.Request, name string, options ...GenericOption) (*Generic, error)

NewGeneric creates an returns a Generic trigger from the provided *http.Request.

func (Generic) Parse added in v0.15.0

func (t Generic) Parse(v any) error

Parse the data of the Generic trigger into the provided value.

type GenericOption added in v0.15.0

type GenericOption func(o *GenericOptions)

GenericOption is a function that sets options on a Generic trigger.

type GenericOptions added in v0.15.0

type GenericOptions struct{}

GenericOptions contains options for a Generic trigger.

type HTTP

type HTTP struct {
	Headers    http.Header
	Params     map[string]string
	Query      map[string]string
	URL        string `json:"Url"`
	Method     string
	Body       data.Raw
	Metadata   HTTPMetadata
	Identities []HTTPIdentity
}

HTTP represents an HTTP trigger.

func NewHTTP

func NewHTTP(r *http.Request, options ...HTTPOption) (*HTTP, error)

NewHTTP creates and returns an HTTP trigger from the provided *http.Request. By default it will use the name "req" for the trigger. This can be overridden with providing a name in the options.

func (HTTP) Form added in v0.5.0

func (t HTTP) Form() (url.Values, error)

Form parses the HTTP trigger for form data sent with Content-Type application/x-www-form-urlencoded and returns it as url.Values.

func (HTTP) MultipartForm added in v0.5.0

func (t HTTP) MultipartForm(maxMemory int64) (*multipart.Form, error)

MultipartForm parses the HTTP trigger for multipart form data and returns the resulting *multipart.Form. The whole request body is parsed and up to a total of maxMemory bytes of its file parts are stored in memory, with the remainder stored on disk in temporary files. If 0 or less is provided it will default to 32 MB.

func (HTTP) Parse

func (t HTTP) Parse(v any) error

Parse the body from the HTTP trigger into the provided value.

type HTTPIdentity added in v0.2.0

type HTTPIdentity struct {
	Actor              any
	BootstrapContext   any
	Label              any
	Name               any
	AuthenticationType string
	NameClaimType      string
	RoleClaimType      string
	Claims             []HTTPIdentityClaims
	IsAuthenticated    bool
}

HTTPIdentity represent a part of the Identities field of the incoming trigger request.

type HTTPIdentityClaims added in v0.2.0

type HTTPIdentityClaims struct {
	Properties     map[string]string
	Issuer         string
	OriginalIssuer string
	Type           string
	Value          string
	ValueType      string
}

HTTPIdentityClaims represent the claims of an HTTPIdentity.

type HTTPMetadata added in v0.2.0

type HTTPMetadata struct {
	Headers map[string]string
	Params  map[string]string
	Query   map[string]string
	Metadata
}

HTTPMetadata represents the metadata for an HTTP trigger.

type HTTPOption added in v0.12.0

type HTTPOption func(o *HTTPOptions)

HTTPOption is a function that sets options on an HTTP trigger.

type HTTPOptions added in v0.12.0

type HTTPOptions struct {
	Name string
}

HTTPOptions contains options for an HTTP trigger.

type Metadata added in v0.2.0

type Metadata struct {
	Sys MetadataSys `json:"sys"`
}

Metadata represents the metadata of the incoming trigger request.

type MetadataSys added in v0.2.0

type MetadataSys struct {
	MethodName string
	UTCNow     time.Time `json:"UtcNow"`
	RandGuid   string
}

MetadataSys contains the sys fields of the incoming trigger request.

type Queue

type Queue struct {
	Metadata QueueMetadata
	Data     data.Raw
}

Queue represents a Queue Storage trigger.

func NewQueue

func NewQueue(r *http.Request, name string, options ...QueueOption) (*Queue, error)

NewQueue creates and returns a new Queue Storage trigger from the provided *http.Request.

func (Queue) Parse added in v0.7.0

func (t Queue) Parse(v any) error

Parse the data of the Queue Storage trigger into the provided value.

type QueueMetadata added in v0.7.0

type QueueMetadata struct {
	DequeueCount    string
	ID              string
	PopReceipt      string
	ExpirationTime  time.Time
	InsertionTime   time.Time
	NextVisibleTime time.Time
	Metadata
}

QueueMetadata represents the metadata for a Queue Storage trigger.

type QueueOption added in v0.12.0

type QueueOption func(o *QueueOptions)

QueueOption is a function that sets options on a Queue Storage trigger.

type QueueOptions added in v0.12.0

type QueueOptions struct{}

QueueOptions contains options for a Queue Storage trigger.

type ServiceBus added in v0.7.0

type ServiceBus struct {
	Data     data.Raw
	Metadata ServiceBusMetadata
}

ServiceBus represents a Service Bus trigger. It supports both queues and topics with subscriptions.

func NewServiceBus added in v0.7.0

func NewServiceBus(r *http.Request, name string, options ...ServiceBusOption) (*ServiceBus, error)

NewServiceBus creates and returns a new Service Bus trigger from the provided *http.Request.

func (ServiceBus) Parse added in v0.7.0

func (t ServiceBus) Parse(v any) error

Parse the data for the Service Bus trigger into the provided value.

type ServiceBusMetadata added in v0.7.0

type ServiceBusMetadata struct {
	MessageReceiver       map[string]any
	MessageSession        map[string]any
	MessageActions        map[string]any
	SessionActions        map[string]any
	ReceiveActions        map[string]any
	ApplicationProperties map[string]any
	UserProperties        map[string]any
	DeliveryCount         string
	LockToken             string
	MessageID             string
	ContentType           string
	SequenceNumber        string
	Metadata
	ExpiresAtUTC    TimeISO8601 `json:"ExpiresAtUtc"`
	ExpiresAt       TimeISO8601
	EnqueuedTimeUTC TimeISO8601 `json:"EnqueuedTimeUtc"`
	EnqueuedTime    TimeISO8601
	Client          ServiceBusMetadataClient
}

ServiceBusMetadata represents the metadata for a Service Bus trigger.

type ServiceBusMetadataClient added in v0.7.0

type ServiceBusMetadataClient struct {
	FullyQualifiedNamespace string
	Identifier              string
	TransportType           int
	IsClosed                bool
}

ServiceBusMetadataClient represents client of the service bus trigger metadata.

type ServiceBusOption added in v0.12.0

type ServiceBusOption func(o *ServiceBusOptions)

ServiceBusOption is a function that sets options on a Service Bus trigger.

type ServiceBusOptions added in v0.12.0

type ServiceBusOptions struct{}

ServiceBusOptions contains options for a Service Bus trigger.

type TimeISO8601 added in v0.7.0

type TimeISO8601 struct {
	time.Time
	// contains filtered or unexported fields
}

TimeISO8601 is a wrapper around time.Time that supports JSON marshalling/unmarshalling with format ISO8601 and ISO8601 with a provided timezone.

func (TimeISO8601) MarshalJSON added in v0.7.0

func (t TimeISO8601) MarshalJSON() ([]byte, error)

MarshalJSON marshals a TimeISO8601 into a JSON time string.

func (*TimeISO8601) UnmarshalJSON added in v0.7.0

func (t *TimeISO8601) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a JSON time string into a TimeISO8601. It supports with and without timezone.

type Timer added in v0.2.0

type Timer struct {
	ScheduleStatus TimerScheduleStatus
	Metadata       Metadata
	Schedule       TimerSchedule
	IsPastDue      bool
}

Timer represent a Timer trigger.

func NewTimer added in v0.2.0

func NewTimer(r *http.Request, options ...TimerOption) (*Timer, error)

NewTimer creates and returns a Timer trigger from the provided *http.Request. By default it will use the name "timer" for the trigger. This can be overridden with providing a name in the options.

type TimerOption added in v0.12.0

type TimerOption func(o *TimerOptions)

TimerOption is a function that sets options on a Timer trigger.

type TimerOptions added in v0.12.0

type TimerOptions struct {
	Name string
}

TimerOptions contains options for a Timer trigger.

type TimerSchedule added in v0.2.0

type TimerSchedule struct {
	AdjustForDST bool
}

TimerSchedule represents the Schedule field from the incoming request.

type TimerScheduleStatus added in v0.2.0

type TimerScheduleStatus struct {
	Last        time.Time
	Next        time.Time
	LastUpdated time.Time
}

TimerScheduleStatus represents the ScheduleStatus field from the incoming request.

Jump to

Keyboard shortcuts

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