Project

aws_cron

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
AWS Elastic Beanstalk cron scheduling support
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 8.1
~> 0.10
~> 0.1
~> 11.0
~> 4.5
~> 3.5
~> 0.45

Runtime

 Project Readme

AwsCron

Gem Version CircleCI Dependency Status Code Climate codecov Gitter chat

Table of Contents

  • Features
    • Examples
  • Requirements
  • Setup
  • Tests
  • Versioning
  • Code of Conduct
  • Contributions
  • License
  • History
  • Credits

Features

AwsCron does all the housekeeping related to handling requests from AWS Elastic Beanstalk Periodic Tasks.

  • Handles HTTP responses, even in case of exceptions
  • Reliable error logging, using your preferred logger
  • Timezone-aware cron scheduling
    • AWS only allows UTC scheduling. AwsCron helps you use your desired timezone instead.

Keep in mind that you still have to set up an AWS Elastic Beanstalk environment with a proper cron.yml file.

Examples

Rails

class MyAwsControllerResponsibleForCronCalls
  include AwsCron::Controller
  
  timezone 'America/New_York'
   
  def foo_endpoint
    run { GenericTask.run } # No timezone checks made, just response handling and logging
  end
  
  def timezoned_9am_endpoint
    run_in_tz '0 9 * * *' do
      TimezoneSpecific9AMTask.run
    end
  end
end

Complex example

class MyAwsControllerResponsibleForCronCalls
  include AwsCron::Controller
   
  def foo_endpoint
    run { GenericTask.run }
  end
  
  def timezoned_9am_endpoint
    run_in_tz '0 9 * * *' do
      TimezoneSpecific9AMTask.run
    end
  end
  
  protected

  def time_provider # Prefer using `timezone 'ZONE'`, unless you want a custom time provider
    ActiveSupport::TimeZone.new('America/New_York')
  end
  
  def return_object # AWS Scheduler always expects ok, even in case of errors
    render :json => {message: 'ok'}
  end
end

Requirements

  1. Ruby 2.3.0

Setup

For a secure install, type the following (recommended):

gem cert --add <(curl --location --silent /gem-public.pem)
gem install aws_cron --trust-policy MediumSecurity

NOTE: A HighSecurity trust policy would be best but MediumSecurity enables signed gem verification while allowing the installation of unsigned dependencies since they are beyond the scope of this gem.

For an insecure install, type the following (not recommended):

gem install aws_cron

Add the following to your Gemfile:

gem "aws_cron"

Tests

To test, run:

bundle exec rake

Versioning

Read Semantic Versioning for details. Briefly, it means:

  • Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
  • Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
  • Major (X.y.z) - Incremented for any backwards incompatible public API changes.

Code of Conduct

Please note that this project is released with a CODE OF CONDUCT. By participating in this project you agree to abide by its terms.

Contributions

Read CONTRIBUTING for details.

License

MIT License

Copyright (c) 2016 Wealthsimple.

History

Read CHANGES for details. Built with Gemsmith.

Credits

Developed by Marco Costa at Wealthsimple.