module

AwsLambdaRuntime

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

Constants

VERSION = "0.2.2"

Class methods

run

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
Source
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))
Source
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))
Source

Nested types