Sha256: bcba3eb80dbc943f54409b820ca3053d0ec679666009f6bc503b2c55c594c722
Contents?: true
Size: 1.55 KB
Versions: 6
Compression:
Stored size: 1.55 KB
Contents
require 'json' # Job public methods get turned into Lambda functions. # # Jets::Job::Base < Jets::Lambda::Functions # Both Jets::Job::Base and Jets::Lambda::Functions have Dsl modules included. # So the Jets::Job::Dsl overrides some of the Jets::Lambda::Functions behavior. module Jets::Job class Base < Jets::Lambda::Functions include Dsl # non-DSL methods include Helpers::KinesisEvent include Helpers::LogEvent include Helpers::S3Event include Helpers::SnsEvent include Helpers::SqsEvent prepend Jets::ExceptionReporting::Process # Tracks bucket each time an s3_event is declared # Map of bucket_name => stack_name (nested part) cattr_accessor :_s3_events # dont want this to be inheritable intentionally self._s3_events = {} class << self def process(event, context, meth) job = new(event, context, meth) job.send(meth) end def perform_now(meth, event={}, context={}) process(event, context, meth) end def perform_later(meth, event={}, context={}) if on_lambda? function_name = "#{self.to_s.underscore}-#{meth}" call = Jets::Commands::Call::Caller.new(function_name, JSON.dump(event), invocation_type: "Event") call.run else Jets.logger.info "INFO: Not on AWS Lambda. In local mode perform_later executes the job with perform_now instead." perform_now(meth, event, context) end end private def on_lambda? !!ENV['AWS_LAMBDA_FUNCTION_NAME'] end end end end
Version data entries
6 entries across 6 versions & 1 rubygems