function

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package function implements function-level operations.

Index

Constants

View Source
const (
	RequestResponse InvocationType = "RequestResponse"
	Event                          = "Event"
	DryRun                         = "DryRun"
)

Invocation types.

View Source
const CurrentAlias = "current"

CurrentAlias name.

Variables

This section is empty.

Functions

func RegisterPlugin

func RegisterPlugin(name string, plugin Plugin)

RegisterPlugin registers `plugin` by `name`.

Types

type Builder

type Builder interface {
	Build(*Function, *archive.Zip) error
}

Builder reacts to the Build hook.

type Cleaner

type Cleaner interface {
	Clean(*Function) error
}

Cleaner reacts to the Clean hook.

type Config

type Config struct {
	Description      string            `json:"description"`
	Runtime          string            `json:"runtime" validate:"nonzero"`
	Memory           int64             `json:"memory" validate:"nonzero"`
	Timeout          int64             `json:"timeout" validate:"nonzero"`
	Role             string            `json:"role" validate:"nonzero"`
	Handler          string            `json:"handler" validate:"nonzero"`
	Shim             bool              `json:"shim"`
	Environment      map[string]string `json:"environment"`
	Hooks            hooks.Hooks       `json:"hooks"`
	RetainedVersions *int              `json:"retainedVersions"`
	VPC              vpc.VPC           `json:"vpc"`
	KMSKeyArn        string            `json:"kms_arn"`
	DeadLetterARN    string            `json:"deadletter_arn"`
	Region           string            `json:"region"`
	Edge             bool              `json:"edge"`
	Zip              string            `json:"zip"`
}

Config for a Lambda function.

type Deployer

type Deployer interface {
	Deploy(*Function) error
}

Deployer reacts to the Deploy hook.

type Function

type Function struct {
	Config
	Name         string
	FunctionName string
	Path         string
	Service      lambdaiface.LambdaAPI
	Log          log.Interface
	IgnoreFile   []byte
	Plugins      []string
	Alias        string
}

Function represents a Lambda function, with configuration loaded from the "function.json" file on disk.

func (*Function) AWSConfig

func (f *Function) AWSConfig() *aws.Config

AWSConfig returns AWS configuration if function has specified region.

func (*Function) Build

func (f *Function) Build() (io.Reader, error)

Build returns the zipped contents of the function.

func (*Function) BuildBytes

func (f *Function) BuildBytes() ([]byte, error)

BuildBytes returns the generated zip as bytes.

func (*Function) Clean

func (f *Function) Clean() error

Clean invokes the CleanHook, useful for removing build artifacts and so on.

func (*Function) Create

func (f *Function) Create(zip []byte) error

Create the function with the given `zip`.

func (*Function) CreateOrUpdateAlias

func (f *Function) CreateOrUpdateAlias(alias, version string) error

CreateOrUpdateAlias attempts creating the alias, or updates if it already exists.

func (*Function) Delete

func (f *Function) Delete() error

Delete the function including all its versions

func (*Function) Deploy

func (f *Function) Deploy() error

Deploy generates a zip and creates or deploy the function. If the configuration hasn't been changed it will deploy only code, otherwise it will deploy both configuration and code.

func (*Function) DeployCode

func (f *Function) DeployCode(zip []byte, config *lambda.GetFunctionOutput) error

DeployCode deploys function code when changed.

func (*Function) DeployConfigAndCode

func (f *Function) DeployConfigAndCode(zip []byte) error

DeployConfigAndCode updates config and updates function code.

func (*Function) GetAliases

func (f *Function) GetAliases() (*lambda.ListAliasesOutput, error)

GetAliases fetches a list of aliases for the function.

func (*Function) GetConfig

func (f *Function) GetConfig() (*lambda.GetFunctionOutput, error)

GetConfig returns the function configuration.

func (*Function) GetConfigCurrent

func (f *Function) GetConfigCurrent() (*lambda.GetFunctionOutput, error)

GetConfigCurrent returns the function configuration for the current version.

func (*Function) GetConfigQualifier

func (f *Function) GetConfigQualifier(s string) (*lambda.GetFunctionOutput, error)

GetConfigQualifier returns the function configuration for the given qualifier.

func (*Function) GetVersionFromAlias

func (f *Function) GetVersionFromAlias(alias string) (string, error)

Return function version from alias name, if alias not found, return the input

func (*Function) GroupName

func (f *Function) GroupName() string

GroupName returns the CloudWatchLogs group name.

func (*Function) Invoke

func (f *Function) Invoke(event, context interface{}) (reply, logs io.Reader, err error)

Invoke the remote Lambda function, returning the response and logs, if any.

func (*Function) Open

func (f *Function) Open(environment string) error

Open the function.json file and prime the config.

func (*Function) Rollback

func (f *Function) Rollback() error

Rollback the function to the previous.

func (*Function) RollbackVersion

func (f *Function) RollbackVersion(version string) error

RollbackVersion the function to the specified version.

func (*Function) Setenv

func (f *Function) Setenv(name, value string)

Setenv sets environment variable `name` to `value`.

func (*Function) Update

func (f *Function) Update(zip []byte) error

Update the function with the given `zip`.

func (*Function) ZipBytes

func (f *Function) ZipBytes() ([]byte, error)

ZipBytes builds the in-memory zip, or reads the .Zip from disk if specified.

type InvocationType

type InvocationType string

InvocationType determines how an invocation request is made.

type InvokeError

type InvokeError struct {
	Message string   `json:"errorMessage"`
	Type    string   `json:"errorType"`
	Stack   []string `json:"stackTrace"`
	Handled bool
}

InvokeError records an error from an invocation.

func (*InvokeError) Error

func (e *InvokeError) Error() string

Error message.

type Opener

type Opener interface {
	Open(*Function) error
}

Opener reacts to the Open hook.

type Plugin

type Plugin interface{}

A Plugin is a chunk of isolated(ish) logic which reacts to various hooks within the system in order to implement specific features such as runtime inference or environment variable support.

Jump to

Keyboard shortcuts

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