lambda

package
v0.44.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// RequestRetryTime represents the number of times calling to AWS resource control.
	RequestRetryTime = 3
	// RetryIntervalDuration represents duration time between retry.
	RetryIntervalDuration = 1 * time.Minute
)

Variables

View Source
var ErrNotFound = errors.New("lambda resource not found")

ErrNotFound lambda resource occurred.

Functions

func DecideRevisionName

func DecideRevisionName(fm FunctionManifest, commit string) (string, error)

DecideRevisionName returns revision name to apply.

func FindArtifactVersions

func FindArtifactVersions(fm FunctionManifest) ([]*model.ArtifactVersion, error)

FindArtifactVersions parses artifact versions from function.yaml.

func FindImageTag

func FindImageTag(fm FunctionManifest) (string, error)

FindImageTag parses image tag from given LambdaFunction manifest.

Types

type Client

type Client interface {
	IsFunctionExist(ctx context.Context, name string) (bool, error)
	CreateFunction(ctx context.Context, fm FunctionManifest) error
	CreateFunctionFromSource(ctx context.Context, fm FunctionManifest, zip io.Reader) error
	UpdateFunction(ctx context.Context, fm FunctionManifest) error
	UpdateFunctionFromSource(ctx context.Context, fm FunctionManifest, zip io.Reader) error
	PublishFunction(ctx context.Context, fm FunctionManifest) (version string, err error)
	GetTrafficConfig(ctx context.Context, fm FunctionManifest) (routingTrafficCfg RoutingTrafficConfig, err error)
	CreateTrafficConfig(ctx context.Context, fm FunctionManifest, version string) error
	UpdateTrafficConfig(ctx context.Context, fm FunctionManifest, routingTraffic RoutingTrafficConfig) error
}

Client is wrapper of AWS client.

type FunctionManifest

type FunctionManifest struct {
	Kind       string               `json:"kind"`
	APIVersion string               `json:"apiVersion,omitempty"`
	Spec       FunctionManifestSpec `json:"spec"`
}

func LoadFunctionManifest

func LoadFunctionManifest(appDir, functionManifestFilename string) (FunctionManifest, error)

LoadFunctionManifest returns FunctionManifest object from a given Function config manifest file.

type FunctionManifestSpec

type FunctionManifestSpec struct {
	Name            string            `json:"name"`
	Role            string            `json:"role"`
	ImageURI        string            `json:"image"`
	S3Bucket        string            `json:"s3Bucket"`
	S3Key           string            `json:"s3Key"`
	S3ObjectVersion string            `json:"s3ObjectVersion"`
	SourceCode      SourceCode        `json:"source"`
	Handler         string            `json:"handler"`
	Runtime         string            `json:"runtime"`
	Memory          int32             `json:"memory"`
	Timeout         int32             `json:"timeout"`
	Tags            map[string]string `json:"tags,omitempty"`
	Environments    map[string]string `json:"environments,omitempty"`
}

FunctionManifestSpec contains configuration for LambdaFunction.

type Registry

type Registry interface {
	Client(name string, cfg *config.PlatformProviderLambdaConfig, logger *zap.Logger) (Client, error)
}

Registry holds a pool of aws client wrappers.

func DefaultRegistry

func DefaultRegistry() Registry

DefaultRegistry returns a pool of aws clients and a mutex associated with it.

type RoutingTrafficConfig

type RoutingTrafficConfig map[TrafficConfigKeyName]VersionTraffic

RoutingTrafficConfig presents a map of primary and secondary version traffic for lambda function alias.

func (*RoutingTrafficConfig) Decode

func (c *RoutingTrafficConfig) Decode(data []byte) error

func (*RoutingTrafficConfig) Encode

func (c *RoutingTrafficConfig) Encode() (string, error)

type SourceCode

type SourceCode struct {
	Git  string `json:"git"`
	Ref  string `json:"ref"`
	Path string `json:"path"`
}

type TrafficConfigKeyName

type TrafficConfigKeyName string

TrafficConfigKeyName represents key for lambda service config map.

const (
	// TrafficPrimaryVersionKeyName represents the key points to primary version config on traffic routing map.
	TrafficPrimaryVersionKeyName TrafficConfigKeyName = "primary"
	// TrafficSecondaryVersionKeyName represents the key points to primary version config on traffic routing map.
	TrafficSecondaryVersionKeyName TrafficConfigKeyName = "secondary"
)

type VersionTraffic

type VersionTraffic struct {
	Version string  `json:"version"`
	Percent float64 `json:"percent"`
}

VersionTraffic presents the version, and the percent of traffic that's routed to it.

Jump to

Keyboard shortcuts

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