Class: Jets::Event::Base

Direct Known Subclasses

ApplicationEvent

Defined Under Namespace

Classes: Error

Instance Attribute Summary

Attributes inherited from Lambda::Functions

#context, #event, #meth

Class Method Summary collapse

Methods included from Util::Logging

log

Methods included from Helpers::SqsEvent

#sqs_events, #sqs_events?, #sqs_records

Methods included from Helpers::SnsEvent

#sns_events, #sns_events?

Methods included from Helpers::S3Event

#s3_events, #s3_events?, #s3_files, #s3_objects, #s3_objects?

Methods included from Helpers::LogEvent

#log_event, #log_event?

Methods included from Helpers::KinesisEvent

#kinesis_data, #kinesis_data?

Methods inherited from Lambda::Functions

#_normalize_options, _prefixes, abstract!, inherited, #initialize, output_keys, subclasses

Methods included from Lambda::Dsl

#lambda_functions

Constructor Details

This class inherits a constructor from Jets::Lambda::Functions

Class Method Details

.handle(event, context, meth = :perform) ⇒ Object



25
26
27
28
# File 'lib/jets/event/base.rb', line 25

def handle(event, context, meth = :perform)
  runner = new(event, context, meth)
  runner.send(meth)
end

.handle_later(meth = :handle, event = {}, context = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/jets/event/base.rb', line 34

def handle_later(meth = :handle, event = {}, context = {})
  function = "#{name.underscore}-#{meth}" # IE: "cool_event-handle"
  call = Jets::CLI::Call.new(
    function: function,
    event: JSON.dump(event),
    invocation_type: "Event"
  )
  resp = begin
    call.invoke
  rescue Jets::CLI::Call::Error => e
    puts "ERROR: #{e.message}".color(:red)
    puts "The stack may not be full deployed yet.  Please check the stack and try again."
    return
  end
  unless resp.status_code == 202
    raise Error, "Error calling Lambda function #{function} with invocation_type Event. status code: #{resp.status_code}"
  end
  resp
end

.handle_now(meth = :handle, event = {}, context = {}) ⇒ Object



30
31
32
# File 'lib/jets/event/base.rb', line 30

def handle_now(meth = :handle, event = {}, context = {})
  handle(event, context, meth)
end