handler

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 6 Imported by: 6 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Lambda Handler Data Structures and types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallHandler

func CallHandler(reflection TaskReflection, ctx context.Context, input []byte) (ret interface{}, err error)

CallHandler calls a TaskReflections Handler with the correct objects using reflection Mostly borrowed from the aws-lambda-go package

func CallHandlerFunction

func CallHandlerFunction(handlerSymbol interface{}, ctx context.Context, input interface{}) (interface{}, error)

CallHandlerFunction does reflection inline and should only be used for testing

func CreateHandler

func CreateHandler(tm *TaskHandlers) (func(context context.Context, input *RawMessage) (interface{}, error), error)

CreateHandler returns the handler passed to the lambda.Start function

func ValidateHandler

func ValidateHandler(handlerSymbol interface{}) error

ValidateHandler checks a handler is a function with the correct arguments and return values

Types

type RawMessage

type RawMessage struct {
	Task  *string
	Input json.RawMessage
	// contains filtered or unexported fields
}

RawMessage is the struct passed to the Lambda Handler It contains the name of the Task and the Inputs Raw message

func (*RawMessage) UnmarshalJSON

func (message *RawMessage) UnmarshalJSON(data []byte) error

type TaskError

type TaskError struct {
	ErrorString string
	Task        *string
	Tasks       []string
}

TaskError is a error type a task function may throw handling it in the state machine is a good idea

func (*TaskError) Error

func (t *TaskError) Error() string

type TaskHandlers

type TaskHandlers map[string]interface{}

TaskHandlers maps a Task Name String to a function <pre>ahsufasiu</pre>

func (*TaskHandlers) Reflect

func (t *TaskHandlers) Reflect() map[string]TaskReflection

TaskHandlers Returns a map of TaskReflections from TaskHandlers

func (*TaskHandlers) Tasks

func (t *TaskHandlers) Tasks() []string

Tasks returns all Task names from a TaskHandlers Map

func (*TaskHandlers) Validate

func (t *TaskHandlers) Validate() error

TaskHandlers validates all handlers in a TaskHandlers map

type TaskReflection

type TaskReflection struct {
	Handler   reflect.Value
	Type      reflect.Type
	EventType reflect.Type
}

TaskReflection caches lots of the reflected values from the Task functions in order to speed up calls

func CreateTaskReflection

func CreateTaskReflection(handlerSymbol interface{}) TaskReflection

CreateTaskReflection creates a TaskReflection from a handler function

Jump to

Keyboard shortcuts

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