AwsCron
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
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
Copyright (c) 2016 Wealthsimple.
History
Read CHANGES for details. Built with Gemsmith.
Credits
Developed by Marco Costa at Wealthsimple.