module AwsLambdaRuntime

Overview

An AWS Lambda runtime for crystal.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      aws_lambda_runtime:
        github: lagr/aws_lambda_runtime
  2. Run shards install

Defined in:

aws_lambda_runtime.cr
aws_lambda_runtime/client.cr
aws_lambda_runtime/invocation.cr
aws_lambda_runtime/lambda_context.cr

Constant Summary

VERSION = "0.2.2"

Class Method Summary

Class Method Detail

def self.run(&block : JSON::Any, Invocation -> T) forall T #

Permits the runtime to be invoked with a block, parses the event.

AwsLambdaRuntime.run do |event, invocation|
  puts "event is a #{event.class.name}."
  # => event is a JSON::Any.
  {"serialize-this": "my friend"}
end

[View source]
def self.run(handler : Proc(JSON::Any, Invocation, T)) forall T #

Permits the runtime to be passed a handler as a proc, parses the event.

def handler(event, invocation)
  puts "event is a #{event.class.name}."
  # => event is a JSON::Any.
  {"serialize-this": "my friend"}
end

AwsLambdaRuntime.run(->handler(JSON::Any, AwsLambdaRuntime::Invocation))

[View source]
def self.run(handler : Proc(String, Invocation, T)) forall T #

Permits the runtime to be passed a handler as a proc, does not parse the event.

This comes handy if the event context is not of interest or should be parsed in a more specialized manner.

def handler(event, invocation)
  puts "event is a #{event.class.name}."
  # => event is a String.
  {"serialize-this": "my friend"}
end

AwsLambdaRuntime.run(->handler(String, AwsLambdaRuntime::Invocation))

[View source]