function

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package function provides primivites for handler functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadReference    = errors.New("bad reference")
	ErrBindingNotFound = errors.New("binding not found")
)
View Source
var (
	ErrUnknownProperty = errors.New("unknown property")
)

Functions

This section is empty.

Types

type Allocatable

type Allocatable interface {
	Allocate() error
}

type Argument

type Argument struct {
	Name      string
	Type      reflect.Type
	Value     reflect.Value
	Direction Direction
	// contains filtered or unexported fields
}

func NewArgument

func NewArgument(name string, argType reflect.Type, direction Direction) (*Argument, error)

func (*Argument) Allocate

func (a *Argument) Allocate() error

func (*Argument) Argument

func (a *Argument) Argument() reflect.Value

func (*Argument) Instance

func (a *Argument) Instance() *Argument

func (*Argument) Read

func (a *Argument) Read(in map[string]json.RawMessage) error

func (*Argument) Write

func (a *Argument) Write(out map[string]any) error

type Binary

type Binary struct {
	Buffer *bytes.Buffer
}

Convenience type for binary input and outpu bindings. Handles "null" values correctly.

func (*Binary) Allocate

func (b *Binary) Allocate() error

func (Binary) MarshalJSON

func (b Binary) MarshalJSON() ([]byte, error)

func (Binary) UnmarshalJSON

func (b Binary) UnmarshalJSON(data []byte) error

type Binding

type Binding struct {
	Name      string      `json:"name"`
	Type      BindingType `json:"type"`
	Direction Direction   `json:"direction"`
	DataType  DataType    `json:"dataType"`
}

type BindingType

type BindingType string
const (
	TypeServiceBusTrigger BindingType = "serviceBusTrigger"
	TypeServiceBus        BindingType = "serviceBus"
	TypeBlobTrigger       BindingType = "blobTrigger"
	TypeBlob              BindingType = "blob"
	TypeManualTrigger     BindingType = "manualTrigger"
	TypeEventHubTrigger   BindingType = "eventHubTrigger"
	TypeEventHub          BindingType = "eventHub"
	TypeTimerTrigger      BindingType = "timerTrigger"
	TypeQueueTrigger      BindingType = "queueTrigger"
	TypeQueue             BindingType = "queue"
	TypeHttpTrigger       BindingType = "httpTrigger"
	TypeHttp              BindingType = "http"
	TypeMobileTable       BindingType = "mobileTable"
	TypeDocumentDB        BindingType = "documentDB"
	TypeTable             BindingType = "table"
	TypeNotificationHub   BindingType = "notificationHub"
	TypeTwilioSms         BindingType = "twilioSms"
	TypeSendGrid          BindingType = "sendGrid"
)

type Config

type Config struct {
	Bindings   []Binding `json:"bindings"`
	Excluded   bool      `json:"excluded,omitempty"`
	EntryPoint string    `json:"entryPoint,omitempty"`
	ScriptFile string    `json:"scriptFile,omitempty"`
}

func NewConfig

func NewConfig(data []byte) (*Config, error)

func NewConfigFromFile

func NewConfigFromFile(path string) (*Config, error)

type Context

type Context struct {
	Data     RawData
	Metadata RawData
	Outputs  map[string]interface{}
	Logs     []string
	Log      Log
}

Context for handler functions provides access to invocation data, output bindings and function logging.

func NewContext

func NewContext(data RawData, metadata RawData) *Context

NewContext creates a new context struct from provided invocation data.

type DataType

type DataType string
const (
	DataTypeString DataType = "string"
	DataTypeBinary DataType = "binary"
	DataTypeStream DataType = "stream"
)

type Direction

type Direction string
const (
	DirectionIn    Direction = "in"
	DirectionOut   Direction = "out"
	DirectionInOut Direction = "inout"
)

type Function

type Function struct {
	Config    Config
	Reference any
	Arguments []Argument
}

func NewFunction

func NewFunction(config *Config, reference any) (*Function, error)

type H

type H map[string]interface{}

Shortcut for map[string]interface{}, usefull for defining arbitrary JSON structures etc. Shamelessly copied from gin.

type HttpRequest

type HttpRequest struct {
	Url        string
	Method     string
	Body       string
	Query      map[string]string
	Headers    HttpRequestHeaders
	Params     map[string]string
	Identities []struct {
		AuthenticationType string
		IsAuthenticated    bool
		Actor              string
		BootstrapContext   string
		Claims             []string
		Label              string
		Name               string
		NameClaimType      string
		RoleClaimType      string
	}
}

HttpRequest models the HttpTrigger request object.

func (*HttpRequest) BodyJSON

func (h *HttpRequest) BodyJSON(v any) error

Parse JSON encoded request body data. Argument handled in the manner of json.Unmarshal.

func (*HttpRequest) IsJSON

func (h *HttpRequest) IsJSON() bool

IsJson checks if the request body is JSON encoded.

type HttpRequestHeaders

type HttpRequestHeaders map[string][]string

Shotcut for map[string][]string

type HttpResponse

type HttpResponse struct {
	Status  uint32
	Body    interface{}
	Headers HttpResponseHeaders
}

HttpResponse models the HttpTrigger out binding data. All fields are optional. The default value for Status is 200.

func (HttpResponse) MarshalJSON

func (h HttpResponse) MarshalJSON() ([]byte, error)

type HttpResponseHeaders

type HttpResponseHeaders map[string][]string

Shotcut for map[string][]string

func ContentTypeJson

func ContentTypeJson() HttpResponseHeaders

func ContentTypeText

func ContentTypeText() HttpResponseHeaders

func (*HttpResponseHeaders) ContentType

func (h *HttpResponseHeaders) ContentType(val string) *HttpResponseHeaders

ContentType sets the HttpResponseHeaders content type.

func (*HttpResponseHeaders) ContentTypeJson

func (h *HttpResponseHeaders) ContentTypeJson() *HttpResponseHeaders

Shortcut for ContentType("application/json")

func (*HttpResponseHeaders) ContentTypeText

func (h *HttpResponseHeaders) ContentTypeText() *HttpResponseHeaders

Shortcut for ContentType("text/plain")

type Log

type Log struct {
	// contains filtered or unexported fields
}

Log provides a scoped access for context logging functions.

func (*Log) Print

func (l *Log) Print(a ...any)

Print appends to function execution context log. Arguments are handled in the manner of fmt.Sprint.

func (*Log) Printf

func (l *Log) Printf(format string, a ...any)

Printf appends to function execution context log. Arguments are handled in the manner of fmt.Sprintf.

func (*Log) Println

func (l *Log) Println(a ...any)

Println appends to function execution context log. Arguments are handled in the manner of fmt.Sprintln.

type RawData

type RawData map[string]json.RawMessage

RawData type to access data provided in invocation requests.

func (RawData) Bool

func (r RawData) Bool(path string) (bool, error)

Bool unmarshals a bool value from the given path. The path is a property path with support for dot notation.

func (RawData) Float

func (r RawData) Float(path string) (float32, error)

Float unmarshals a float32 value from the given path. The path is a property path with support for dot notation.

func (RawData) Float32

func (r RawData) Float32(path string) (float32, error)

Float32 unmarshals a float32 value from the given path. The path is a property path with support for dot notation.

func (RawData) Float64

func (r RawData) Float64(path string) (float64, error)

Float64 unmarshals a float64 value from the given path. The path is a property path with support for dot notation.

func (RawData) Int

func (r RawData) Int(path string) (int, error)

Int unmarshals an int value from the given path. The path is a property path with support for dot notation.

func (RawData) Int16

func (r RawData) Int16(path string) (int16, error)

Int16 unmarshals an int16 value from the given path. The path is a property path with support for dot notation.

func (RawData) Int32

func (r RawData) Int32(path string) (int32, error)

Int32 unmarshals an int32 value from the given path. The path is a property path with support for dot notation.

func (RawData) Int64

func (r RawData) Int64(path string) (int64, error)

Int64 unmarshals an int64 value from the given path. The path is a property path with support for dot notation.

func (RawData) Int8

func (r RawData) Int8(path string) (int8, error)

Int8 unmarshals an int8 value from the given path. The path is a property path with support for dot notation.

func (RawData) Map

func (r RawData) Map(path string) (map[string]interface{}, error)

Map unmarshals a map[string]interface{} value from the given path. The path is a property path with support for dot notation.

func (RawData) Slice

func (r RawData) Slice(path string) ([]interface{}, error)

Slice unmarshals a []]interface{} value from the given path. The path is a property path with support for dot notation.

func (RawData) String

func (r RawData) String(path string) (string, error)

String unmarshals a string value from the given path. The path is a property path with support for dot notation.

func (RawData) Uint

func (r RawData) Uint(path string) (uint, error)

Uint unmarshals an uint value from the given path. The path is a property path with support for dot notation.

func (RawData) Uint16

func (r RawData) Uint16(path string) (uint16, error)

Uint16 unmarshals an uint16 value from the given path. The path is a property path with support for dot notation.

func (RawData) Uint32

func (r RawData) Uint32(path string) (uint32, error)

Uint32 unmarshals an uint32 value from the given path. The path is a property path with support for dot notation.

func (RawData) Uint64

func (r RawData) Uint64(path string) (uint64, error)

Uint64 unmarshals an uint64 value from the given path. The path is a property path with support for dot notation.

func (RawData) Uint8

func (r RawData) Uint8(path string) (uint8, error)

Uint8 unmarshals an uint8 value from the given path. The path is a property path with support for dot notation.

Jump to

Keyboard shortcuts

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