lambda_invoke

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 6 Imported by: 0

README

go-lambda-invoke

Wrapper library around aws-sdk-go-v2/service/lambda to simplify invoking lambda functions with less ceremony.

Installing

To start using go-invoke-lambda, install Go and run go get:

go get github.com/JayJamieson/go-lambda-invoke

Usage

package main

import (
 "log"

 invoke "github.com/JayJamieson/go-lambda-invoke"
)

type input struct {
 Value string `json:"name"`
}

type output struct {
 Value string `json:"name"`
}

func main() {
  var client // create your lambda client
  // or use our thing wrapper

  // client, err := invoke.NewDefaultClient(context.TODO())

  var out output

  // Synchronous invoke
  err := invoke.InvokeSync(context.TODO(), client, &invoke.InvokeInput{
    Name:      "test",
    Qualifier: invoke.DefaultAlias,
    Payload:   input{"hello"},
  }, &out)

 // Asynchronous invoke
  err := invoke.InvokeAsync(context.TODO(), client, &invoke.InvokeInpu{
    Name:      "test",
    Qualifier: invoke.DefaultAlias,
    Payload:   input{"hello"},
  })

}

Documentation

Index

Constants

View Source
const DefaultAlias = "$LATEST"

DefaultAlias is the alias for function invocations.

Variables

This section is empty.

Functions

func InvokeAsync

func InvokeAsync(ctx context.Context, client LambdaClient, in *InvokeInput) error

func InvokeSync

func InvokeSync(ctx context.Context, client LambdaClient, in *InvokeInput, out any) error

func NewDefaultClient

func NewDefaultClient(ctx context.Context) (*lambda.Client, error)

Types

type InvokeError

type InvokeError struct {
	// Message is the error message returned from Lambda.
	Message string `json:"errorMessage"`

	// Handled specifies if the error was controlled or not.
	// For example a timeout is unhandled, while an error returned from
	// the function is handled.
	Handled bool
}

func (*InvokeError) Error

func (e *InvokeError) Error() string

Error message.

type InvokeInput

type InvokeInput struct {
	Name      string
	Qualifier string
	Payload   any
}

type LambdaClient

type LambdaClient interface {
	Invoke(ctx context.Context, params *lambda.InvokeInput, optFns ...func(*lambda.Options)) (*lambda.InvokeOutput, error)
}

Jump to

Keyboard shortcuts

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