trigger

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: 11 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

type EventGrid struct {
	Time     time.Time
	Metadata EventGridMetadata
	ID       string
	// Topic is the topic of the event. It is the same as the source
	// for Cloud Events.
	Topic string
	// Source is the source of the event. It is the same as the topic
	// for Event Grid events.
	Source  string
	Subject string
	Type    string
	Data    any
	Schema  eventgrid.Schema
}

EventGrid represents an Event Grid trigger. It handles both Cloud Events and Event Grid events. CloudEvents contains source where as an Event Grid event contains topic.

func NewEventGrid

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

func (t EventGrid) Parse(v any) error

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

type EventGridMetadata

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

EventGridMetadata represents the metadata for an Event Grid trigger.

type EventGridOption

type EventGridOption func(o *EventGridOptions)

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

type EventGridOptions

type EventGridOptions struct{}

EventGridOptions contains options for an Event Grid trigger.

type Generic

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

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

func (t Generic) Parse(v any) error

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

type GenericOption

type GenericOption func(o *GenericOptions)

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

type GenericOptions

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

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

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

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

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

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

type HTTPOption func(o *HTTPOptions)

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

type HTTPOptions

type HTTPOptions struct {
	Name string
}

HTTPOptions contains options for an HTTP trigger.

type Metadata

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

Metadata represents the metadata of the incoming trigger request.

type MetadataSys

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

func (t Queue) Parse(v any) error

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

type QueueMetadata

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

type QueueOption func(o *QueueOptions)

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

type QueueOptions

type QueueOptions struct{}

QueueOptions contains options for a Queue Storage trigger.

type ServiceBus

type ServiceBus struct {
	Data     data.Raw
	Metadata ServiceBusMetadata
}

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

func NewServiceBus

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

func (t ServiceBus) Parse(v any) error

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

type ServiceBusMetadata

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

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

ServiceBusMetadataClient represents client of the service bus trigger metadata.

type ServiceBusOption

type ServiceBusOption func(o *ServiceBusOptions)

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

type ServiceBusOptions

type ServiceBusOptions struct{}

ServiceBusOptions contains options for a Service Bus trigger.

type TimeISO8601

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

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

MarshalJSON marshals a TimeISO8601 into a JSON time string.

func (*TimeISO8601) UnmarshalJSON

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

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

type Timer

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

Timer represent a Timer trigger.

func NewTimer

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

type TimerOption func(o *TimerOptions)

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

type TimerOptions

type TimerOptions struct {
	Name string
}

TimerOptions contains options for a Timer trigger.

type TimerSchedule

type TimerSchedule struct {
	AdjustForDST bool
}

TimerSchedule represents the Schedule field from the incoming request.

type TimerScheduleStatus

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