extension

package
v0.0.0-...-8910f3d Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ExtensionID string
	// contains filtered or unexported fields
}

Client is a simple client for the Lambda Extensions API

func NewClient

func NewClient(awsLambdaRuntimeAPI string) *Client

NewClient returns a Lambda Extensions API client

func (*Client) ExitError

func (e *Client) ExitError(ctx context.Context, errorType string) (res StatusResponse, err error)

ExitError reports an error to the platform before exiting. Call it when you encounter an unexpected failure

func (*Client) InitError

func (e *Client) InitError(ctx context.Context, errorType string) (res StatusResponse, err error)

InitError reports an initialization error to the platform. Call it when you registered but failed to initialize

func (*Client) NextEvent

func (e *Client) NextEvent(ctx context.Context) (res NextEventResponse, err error)

NextEvent blocks while long polling for the next lambda invoke or shutdown

func (*Client) RegisterExtension

func (e *Client) RegisterExtension(ctx context.Context, filename string) (res RegisterResponse, err error)

RegisterExtension will register the extension with the Extensions API

func (*Client) SubscribeLogs

func (e *Client) SubscribeLogs(ctx context.Context, types []LogType, params SubscribeLogsParams) (res SubscribeResponse, err error)

SubscribeLogs calls the Logs API to subscribe for the log events.

type EventType

type EventType string

EventType represents the type of events received from /event/next

const (
	// Invoke is a lambda invoke
	Invoke EventType = "INVOKE"

	// Shutdown is a shutdown event for the environment
	Shutdown EventType = "SHUTDOWN"
)

type LogType

type LogType string

LogType represents the type of logs subscribed from Logs API

const (
	// Platform is to receive logs emitted by the platform
	Platform LogType = "platform"
	// Function is to receive logs emitted by the function
	Function LogType = "function"
	// Extension is to receive logs emitted by the extension
	Extension LogType = "extension"
)

type NextEventResponse

type NextEventResponse struct {
	EventType          EventType `json:"eventType"`
	DeadlineMs         int64     `json:"deadlineMs"`
	RequestID          string    `json:"requestId"`
	InvokedFunctionArn string    `json:"invokedFunctionArn"`
	Tracing            Tracing   `json:"tracing"`
}

NextEventResponse is the response for /event/next

type RegisterResponse

type RegisterResponse struct {
	FunctionName    string `json:"functionName"`
	FunctionVersion string `json:"functionVersion"`
	Handler         string `json:"handler"`
}

RegisterResponse is the body of the response for /register

type StatusResponse

type StatusResponse struct {
	Status string `json:"status"`
}

StatusResponse is the body of the response for /init/error and /exit/error

type SubscribeLogsParams

type SubscribeLogsParams struct {
	ListenPort int
	MaxItems   int
	MaxBytes   int
	TimeoutMS  int
}

type SubscribeResponse

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

SubscribeResponse is the response body that is received from Logs API on subscribe

type Tracing

type Tracing struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

Tracing is part of the response for /event/next

Jump to

Keyboard shortcuts

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