Permalink
Browse files

Official AWS Ruby Support

  • Loading branch information...
tongueroo committed Nov 29, 2018
1 parent 3b44cc8 commit 78501a13fb67c226b4fbd921fa1907b9a51c44cf
Showing with 865 additions and 806 deletions.
  1. +8 −0 CHANGELOG.md
  2. +3 −3 Gemfile.lock
  3. +2 −2 README.md
  4. +0 −2 docs/_docs/app-config.md
  5. +2 −2 docs/_docs/articles.md
  6. +1 −1 docs/_docs/assets-serving.md
  7. +1 −1 docs/_docs/blue-green-deployment.md
  8. +1 −1 docs/_docs/config-rules.md
  9. +1 −1 docs/_docs/contributing.md
  10. +3 −1 docs/_docs/controllers.md
  11. +2 −2 docs/_docs/cors-support.md
  12. +1 −1 docs/_docs/crud-json-activerecord.md
  13. +1 −1 docs/_docs/database-support.md
  14. +1 −1 docs/_docs/debug-ruby-errors.md
  15. +1 −1 docs/_docs/deploy.md
  16. +1 −1 docs/_docs/env-extra.md
  17. +6 −4 docs/_docs/faster-development.md
  18. +1 −1 docs/_docs/function-properties.md
  19. +6 −4 docs/_docs/functions.md
  20. +17 −0 docs/_docs/gem-layer.md
  21. +11 −11 docs/_docs/install.md
  22. +3 −3 docs/_docs/jobs.md
  23. +3 −3 docs/_docs/lambdagems.md
  24. +2 −4 docs/_docs/lazy-loading.md
  25. +6 −10 docs/_docs/megamode-considerations.md
  26. +4 −8 docs/_docs/native-performance.md
  27. +2 −2 docs/_docs/next-steps.md
  28. +2 −2 docs/_docs/prewarming.md
  29. +8 −0 docs/_docs/routing-authorization.md
  30. +1 −1 docs/_docs/routing-custom-domain.md
  31. +1 −0 docs/_docs/shared-resources.md
  32. +13 −3 docs/_docs/upgrading.md
  33. +4 −4 docs/_includes/routing.md
  34. +4 −5 docs/_includes/subnav.html
  35. +1 −1 docs/_reference/jets-gems-check.md
  36. +16 −4 docs/faq.md
  37. BIN docs/img/docs/demo-lambda-functions-controller.png
  38. BIN docs/img/docs/demo-lambda-functions-jobs.png
  39. BIN docs/img/docs/jets-simple-lambda-function-console.png
  40. BIN docs/img/docs/jets-simple-lambda-function-result.png
  41. BIN docs/img/docs/lambda-console-ruby-error.png
  42. BIN docs/img/quick-start/demo-lambda-functions.png
  43. +3 −4 lib/jets.rb
  44. +13 −2 lib/jets/application.rb
  45. +3 −0 lib/jets/builders.rb
  46. +22 −89 lib/jets/builders/code_builder.rb
  47. +55 −0 lib/jets/builders/code_size.rb
  48. +22 −1 lib/jets/builders/gem_replacer.rb
  49. +31 −5 lib/jets/builders/handler_generator.rb
  50. +50 −0 lib/jets/builders/lambda_layer.rb
  51. +10 −5 lib/jets/builders/md5.rb
  52. +1 −0 lib/jets/builders/md5_zip.rb
  53. +35 −0 lib/jets/builders/purger.rb
  54. +25 −5 lib/jets/builders/rack_packager.rb
  55. +1 −5 lib/jets/builders/rackup_wrappers/rackup
  56. +25 −27 lib/jets/builders/ruby_packager.rb
  57. +3 −3 lib/jets/builders/shim_vars/app.rb
  58. +9 −4 lib/jets/builders/shim_vars/base.rb
  59. +2 −2 lib/jets/builders/shim_vars/shared.rb
  60. +0 −9 lib/jets/builders/templates/handler.js
  61. +7 −0 lib/jets/builders/templates/handler.rb
  62. +0 −275 lib/jets/builders/templates/shim.js
  63. +4 −3 lib/jets/builders/tidy.rb
  64. +11 −3 lib/jets/builders/util.rb
  65. +6 −3 lib/jets/cfn/builders/base_child_builder.rb
  66. +1 −1 lib/jets/cfn/builders/interface.rb
  67. +5 −0 lib/jets/cfn/builders/parent_builder.rb
  68. +4 −2 lib/jets/commands/build.rb
  69. +1 −1 lib/jets/commands/help/gems/check.md
  70. +1 −1 lib/jets/commands/main.rb
  71. +4 −2 lib/jets/commands/new.rb
  72. +1 −1 lib/jets/commands/sequence.rb
  73. +2 −2 lib/jets/commands/templates/skeleton/Gemfile.tt
  74. +0 −5 lib/jets/commands/templates/skeleton/config/application.rb.tt
  75. +2 −2 lib/jets/commands/templates/skeleton/config/database.yml.tt
  76. +2 −1 lib/jets/commands/templates/skeleton/config/environments/development.rb
  77. +2 −3 lib/jets/commands/templates/skeleton/config/environments/production.rb
  78. +21 −0 lib/jets/commands/upgrade/v1.rb
  79. +1 −1 lib/jets/controller/renderers/template_renderer.rb
  80. +1 −4 lib/jets/controller/rendering.rb
  81. +45 −6 lib/jets/core.rb
  82. +32 −34 lib/jets/internal/app/jobs/jets/preheat_job.rb
  83. +11 −0 lib/jets/mega/request.rb
  84. +1 −0 lib/jets/overrides/lambda.rb
  85. +31 −0 lib/jets/overrides/lambda/marshaller.rb
  86. +4 −0 lib/jets/overrides/rails.rb
  87. 0 lib/jets/{rails_overrides → overrides/rails}/asset_tag_helper.rb
  88. 0 lib/jets/{rails_overrides → overrides/rails}/common_methods.rb
  89. 0 lib/jets/{rails_overrides → overrides/rails}/rendering_helper.rb
  90. 0 lib/jets/{rails_overrides → overrides/rails}/url_helper.rb
  91. +1 −1 lib/jets/poly_fun/base_executor.rb
  92. +1 −0 lib/jets/preheat.rb
  93. +3 −10 lib/jets/processors/main_processor.rb
  94. +31 −2 lib/jets/{server.rb → rack_server.rb}
  95. +0 −4 lib/jets/rails_overrides.rb
  96. +1 −1 lib/jets/resource.rb
  97. +1 −1 lib/jets/resource/api_gateway/base_path/function.rb
  98. +10 −4 lib/jets/resource/child_stack/app_class.rb
  99. +5 −0 lib/jets/resource/lambda.rb
  100. +8 −6 lib/jets/resource/{ → lambda}/function.rb
  101. +1 −1 lib/jets/resource/{ → lambda}/function/environment.rb
  102. +17 −0 lib/jets/resource/lambda/gem_layer.rb
  103. +46 −0 lib/jets/resource/lambda/layer_version.rb
  104. +0 −148 lib/jets/ruby_server.rb
  105. +52 −0 lib/jets/tmp_loader.rb
  106. 0 {README → readme}/prerelease.md
  107. +5 −0 {README → readme}/testing.md
  108. +1 −1 spec/fixtures/apps/franky/config/application.rb
  109. +5 −5 spec/lib/jets/builders/shim_vars/app_spec.rb
  110. +1 −1 spec/lib/jets/builders/shim_vars/shared_spec.rb
  111. +1 −1 spec/lib/jets/rails_overrides/rails_overrides_spec.rb
  112. +10 −10 spec/lib/jets/resource/{ → lambda}/function_spec.rb
  113. +14 −0 spec/lib/jets/resource/lambda/layer_version_spec.rb
  114. +0 −7 spec/lib/jets/server_spec.rb
  115. +1 −1 vendor/jets-gems
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.

## [1.3.0]
- Official AWS Ruby Support
- Ruby Version 2.5.3 upgrade
- Gem Layer introduced
- Removed node shim
- Build purger: /tmp/jets/project is auto purge when major or minor version changes
- Update default gems source to https://gems2.lambdagems.com

## [1.2.1]
- remove comments about routes workaround, auto blue-green deployments resolves this

@@ -66,7 +66,7 @@ GEM
tzinfo (~> 1.1)
arel (9.0.0)
aws-eventstream (1.0.1)
aws-partitions (1.122.0)
aws-partitions (1.123.0)
aws-sdk-apigateway (1.23.0)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sigv4 (~> 1.0)
@@ -76,7 +76,7 @@ GEM
aws-sdk-cloudwatchlogs (1.12.0)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sigv4 (~> 1.0)
aws-sdk-core (3.43.0)
aws-sdk-core (3.44.0)
aws-eventstream (~> 1.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
@@ -109,7 +109,7 @@ GEM
gems (1.1.1)
json
hashie (3.6.0)
i18n (1.1.1)
i18n (1.2.0)
concurrent-ruby (~> 1.0)
jmespath (1.4.0)
json (2.1.0)
@@ -30,13 +30,13 @@ Jets supports writing AWS Lambda functions with Ruby. You define them in the `ap
app/functions/simple.rb:

```ruby
def handle(event, context)
def handle(event:, context:)
puts "hello world"
{hello: "world"}
end
```

Though simple functions are supported by Jets, aside from the ability to use Ruby, they do not as much value as other ways to write code with Jets.
Though simple functions are supported by Jets, they do not really add much value as other ways to write Ruby code with Jets. Classes like Controllers and Jobs add many conveniences and are more powerful to use. We’ll cover them next.

### Jets Controllers

@@ -51,7 +51,6 @@ config/environments/development.rb:
```ruby
Jets.application.configure do
config.function.memory_size = 1536
config.ruby.lazy_load = true
end
```

@@ -60,7 +59,6 @@ config/environments/production.rb:
```ruby
Jets.application.configure do
config.function.memory_size = 2048
config.ruby.lazy_load = false
end
```

@@ -12,6 +12,6 @@ title: Articles
{% for post in posts %}
* [{{ post.title }}]({{ post.url }}){% endfor %}

<a id="prev" class="btn btn-basic" href="{% link _docs/lambdagems.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/contributing.md %}">Next Step</a>
<a id="prev" class="btn btn-basic" href="{% link _docs/crud-json-activerecord.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link faq.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -34,6 +34,6 @@ Jets.application.configure do
end
```

<a id="prev" class="btn btn-basic" href="{% link _docs/cors-support.md %}">Back</a>
<a id="prev" class="btn btn-basic" href="{% link _docs/config-rules.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/action-filters.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -14,7 +14,7 @@ If you have configured a [Custom Domain]({% link _docs/routing-custom-domain.md

## Manual Blue-Green Deployment

For the most part, Jets auto blue-green deployments suffice. Sometimes manual blue-green deployments are sometimes required though. For example, [upgrading]({% link _docs/upgrading.md %}) between different versions of Jets can required a blue-green deployment.
For the most part, Jets auto blue-green deployments suffice. Manual blue-green deployments are sometimes required though. For example, [upgrading]({% link _docs/upgrading.md %}) between different versions of Jets can required a blue-green deployment.

This is where Jets and AWS Lambda power shines. We simply create another [extra environment]({% link _docs/env-extra.md %}) and switch to it to do a manual blue-green deployment. Here are the steps:

@@ -118,5 +118,5 @@ This results in the rules looking something like this `cis-check-incoming-ssh-di
* [AWS::Config::ConfigRule](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-config-configrule.html) CloudFormation reference

<a id="prev" class="btn btn-basic" href="{% link _docs/shared-resources-functions.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/cors-support.md %}">Next Step</a>
<a id="next" class="btn btn-primary" href="{% link _docs/assets-serving.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -10,6 +10,6 @@ I love pull requests! You can improve Jets too.
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

<a id="prev" class="btn btn-basic" href="{% link _docs/articles.md %}">Back</a>
<a id="prev" class="btn btn-basic" href="{% link _docs/lambdagems.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/next-steps.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -22,7 +22,9 @@ class PostsController < ApplicationController
end
```

Jets creates Lambda functions for each public method in your controller.
Helper methods like `params` provide the parameters from the API Gateway event. The `render` method renders a Lambda Proxy structure back that API Gateway understands.

For each public method in your controller, Jets creates a Lambda function:

![](/img/docs/demo-lambda-functions-controller.png)

@@ -24,6 +24,6 @@ end

The example above adds a response header with `Access-Control-AllowOrigin='*.mydomain.com'`.

<a id="prev" class="btn btn-basic" href="{% link _docs/config-rules.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/assets-serving.md %}">Next Step</a>
<a id="prev" class="btn btn-basic" href="{% link _docs/routing-custom-domain.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/database-support.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -151,5 +151,5 @@ To delete the, here's the curl command:
{"deleted":true}

<a id="prev" class="btn btn-basic" href="{% link _docs/crud-html-activerecord.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/native-performance.md %}">Next Step</a>
<a id="next" class="btn btn-primary" href="{% link _docs/articles.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -9,6 +9,6 @@ Jets supports DynamoDB and ActiveRecord. Both DynamoDB and ActiveRecord can coex

For ActiveRecord, currently PostgreSQL is supported.

<a id="prev" class="btn btn-basic" href="{% link _docs/routing-custom-domain.md %}">Back</a>
<a id="prev" class="btn btn-basic" href="{% link _docs/cors-support.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/database-dynamodb.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -2,7 +2,7 @@
title: Debugging Ruby Errors
---

In [How Jets Works]({% link _docs/native-performance.md %}), we cover that AWS Lambda does not currently support Ruby natively. Jets adds Ruby Support by using a node shim. You might think that this means you will need to debug node errors. But this is not the case at all. Jets surfaces the Ruby stack trace error up through the node shim all the way to the Lambda Console.
Ruby stack trace errors surface up to the Lambda Console.

## Example

@@ -2,7 +2,7 @@
title: Deploy
---

Once you are ready to deploy your app to lambda, it's one command to do so:
Once you are ready to deploy your app to Lambda, it's one command to do so:

jets deploy

@@ -16,7 +16,7 @@ Jets.application.configure do
end
```

Interestingly, since AWS Lambda pricing is based on usage. These extra environments cost you pretty much nothing. They're literally free until you exceed the [free tier](https://aws.amazon.com/free/). Create 10 extra development, staging or uat environments if you need to 🎉
Interestingly, since AWS Lambda pricing is based on usage. These extra environments cost you pretty much nothing. They're literally free until you exceed the [free tier](https://aws.amazon.com/free/). Create 10 extra Development, Staging or UAT environments if you need them 🎉

## Precedence

@@ -4,11 +4,13 @@ title: Faster Development

Development speed with AWS Lambda can be slow due to having to upload the Ruby interpreter and gems as part of the deployment package. Here are some suggestions:

## Lazy Loading
## Minimize Gemfile Changes

[Lazy loading]({% link _docs/lazy-loading.md %}) significantly improves your development workflow speed. Lazy loading is enabled by default in development. Thanks to lazy loading, the `jets deploy` process optimizes things and will only upload a new bundled set of gems when there are changes. Gems do not change as much as your application code, so this optimization speeds up the deploy process significantly. The bundled Ruby interpreter and gems can add up to 100MB zipped, so only uploading to s3 when required is particularly beneficial on slower internet connections. On a typical internet connection, it can take 5 minutes to upload 100MB to S3. The optimization removes this upload time and takes the deploy down to usually about 1 minute after the first deploy.
Jets creates a [Gem Layer]({% link _docs/gem-layer.md %}) to help improve your development workflow speed. The Gem Layer is your application's gem dependencies bundled into a [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html). This is done as as part of the [jets deploy](/reference/jets-deploy/) command.

An additional benefit of lazy loading is that it keeps your application code size small. With lazy loading, your app code is usually under the 3MB limit, which is the current maximum package size for the AWS Lambda Console Editor. This means you can live edit your code, develop, and test without a full deploy. This is even faster than being able to ssh into the server. Here's a screenshot:
Thanks to the use of Lambda Layers, the `jets deploy` process optimizes things and will only upload a new bundled set of gems to s3 when there are changes. As gems do not change as much as your application code, this optimization speeds up the deploy process significantly. It is not uncommon for gems to add up to 50MB zipped, so only uploading to s3 when required is particularly beneficial on slower internet connections. On a typical internet connection, it can take 3 minutes to upload 50MB to S3. The optimization removes this upload time and takes the deploy down to usually about 1 minute after the first deploy.

An additional benefit of the Gem Layer is that it keeps your application code size small. Your our app code is usually under the 3MB limit, which is the current maximum package size for the AWS Lambda Console Editor. This means you can live edit your code, develop, and test without a full deploy. This is even faster than being able to ssh into the server. Here's a screenshot:

![](/img/docs/faster-development-live-edit.png)

@@ -45,5 +47,5 @@ I've actually come to enjoy using Cloud9 and have been pretty happy with it. It
Another approach for a team is to set up a CI/CD pipeline that will deploy when git commits are pushed.

<a id="prev" class="btn btn-basic" href="{% link _docs/debug-ruby-errors.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/lazy-loading.md %}">Next Step</a>
<a id="next" class="btn btn-primary" href="{% link _docs/gem-layer.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -2,7 +2,7 @@
title: Function Properties
---

Jets ultimately translate ruby code into Lambda functions. Each [Lambda function's properties](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html) can be controlled with Jets. Here are the ways to set the function properties and their order of precedence:
Jets ultimately translate Ruby code into Lambda functions. Each [Lambda function's properties](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html) can be controlled with Jets. Here are the ways to set the function properties and their order of precedence:

1. function specific properties - highest precedence
2. class-wide function properties
@@ -2,17 +2,19 @@
title: Functions
---

Jets supports writing AWS Lambda functions with Ruby. You define them in the `app/functions` folder. A function looks like this:
You can write simple Lambda Ruby functions in the `app/functions` folder. A function looks like this:

app/functions/simple.rb:

```ruby
def handle(event, context)
def lambda_handler(event:, context:)
pp event
puts "hello world"
{foo: "bar"}
end
```

The form above is what AWS Lambda Ruby support would probably look like. The default handler is named `handle`. The lambda function shows up in the Lambda console like this:
The default handler is named `lambda_handler`. The lambda function shows up in the Lambda console like this:

![](/img/docs/jets-simple-lambda-function-console.png)

@@ -22,7 +24,7 @@ You can run the function in the AWS Lambda console and see the results:

Here's an article that covers a simple Jets Ruby function: [Jets Simple AWS Lambda Ruby Function](https://blog.boltops.com/2018/10/26/jets-simple-aws-lambda-ruby-function).

Though simple functions are supported by Jets, aside from the ability to use Ruby it does not really add much value. Other classes like [Controllers]({% link _docs/controllers.md %}) and [Jobs]({% link _docs/jobs.md %}) add many conveniences and are more powerful to use. We'll cover them next.
Though simple functions are supported by Jets, they do not really add much value as other ways to write Ruby code with Jets. Classes like [Controllers]({% link _docs/controllers.md %}) and [Jobs]({% link _docs/jobs.md %}) add many conveniences and are more powerful to use. We'll cover them next.

<a id="prev" class="btn btn-basic" href="{% link docs.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/controllers.md %}">Next Step</a>
@@ -0,0 +1,17 @@
---
title: Gem Layer
---

Jets bundles your project's gem dependencies in a Gem Layer which is a [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html). From the AWS Docs:

> With layers, you can use libraries in your function without needing to include them in your deployment package.
## Advantages of Gem Layer

A key advantage is that it results in your code size being smaller. If your application code is under the key [3 MB](https://docs.aws.amazon.com/lambda/latest/dg/limits.html) limit, you are able to see and edit your Lambda code in the AWS Lambda console code editor **live**. This is extremely helpful to debug and test without a full deploy.

An additional advantage of using a separate Gem Layer is that this allows Jets to optimize the deploy process and upload the gems only to s3 only when they change. AWS designed Lambda Layers understanding this benefit. On a slow internet connection this significantly improves your [development speed]({% link _docs/faster-development.md %}) and happiness.

<a id="prev" class="btn btn-basic" href="{% link _docs/faster-development.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/upgrading.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -16,16 +16,6 @@ gem "jets"

## Prerequisites

### AWS CLI

You can install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) via pip.

pip install awscli --upgrade --user

Then [configure it](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).

aws configure

## Dependencies

### Ruby
@@ -34,7 +24,7 @@ Jets uses Ruby 2.5.0 and code written with patch variants of it will work.

### Yarn

For apps with HTML pages, jets uses [webpacker](https://github.com/rails/webpacker) to compile assets which requires node's yarn. [Node version manager](https://github.com/creationix/nvm), nvm, is recommended to install a desired version of node. Here's a node install cheatsheet, though prelease refer to the links for the most updated commands with possible more recent versions:
For apps with HTML pages, jets uses [webpacker](https://github.com/rails/webpacker) to compile assets which requires node's yarn. [Node version manager](https://github.com/creationix/nvm), nvm, is recommended to install a desired version of node. Here's a node install cheatsheet, though please refer to the links for the most updated commands with possible more recent versions:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
# note follow the instructions after the curl command to source nvm
@@ -67,6 +57,16 @@ Here are various ways to install different databases:
yum install -y postgresql-devel # amazonlinux2 and redhat variants
apt-get install libpq-dev # ubuntu and debian variants

### AWS CLI

The AWS CLI is not required but strongly recommended so you can make use of AWS Profiles. You can install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) via pip.

pip install awscli --upgrade --user

Then [configure it](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).

aws configure

<a id="prev" class="btn btn-basic" href="{% link _docs/jobs.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/structure.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -2,13 +2,13 @@
title: Jobs
---

A Jets job handles background jobs. They run outside of the web request/response cycle. Here's an example:
A Jets job handles background work, better suited to run outside of the web request/response cycle. Here's an example:

app/jobs/hard_job.rb:

```ruby
class HardJob < ApplicationJob
class_timeout 300
class_timeout 300 # 300s or 5m, current Lambda max is 15m
rate "10 hours" # every 10 hours
def dig
@@ -28,7 +28,7 @@ You can check for the job functions in the Lambda console:

![](/img/docs/demo-lambda-functions-jobs.png)

You can also see associated CloudWatch Event Rule in the CloudWatch console:
The `rate` and `cron` methhods creates CloudWatch Event Rules to handle scheduling. You can see associated CloudWatch Event Rule in the CloudWatch console:

![](/img/docs/demo-job-cloudwatch-rule.png)

@@ -12,13 +12,13 @@ The Lambda Gems service is currently available for free. Bandwidth and maintaini
Jets.application.configure do
# Sources for check for pre-compiled Lambda gems. Checks the list in order.
config.gems.sources = [
"https://gems.lambdagems.com",
"https://gems2.lambdagems.com",
"https://yoursource.com",
]
# ...
end
```

<a id="prev" class="btn btn-basic" href="{% link _docs/native-performance.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/articles.md %}">Next Step</a>
<a id="prev" class="btn btn-basic" href="{% link faq.md %}">Back</a>
<a id="next" class="btn btn-primary" href="{% link _docs/contributing.md %}">Next Step</a>
<p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
Oops, something went wrong.

0 comments on commit 78501a1

Please sign in to comment.