Ruby and Lambda splat out a baby and that child's name is Jets.
Please watch/star this repo to help grow and support the project.
Upgrading: If you are upgrading Jets, please check on the Upgrading Notes.
Jets is a Ruby Serverless Framework. Jets allows you to create serverless applications with a beautiful language: Ruby. It includes everything required to build an application and deploy it to AWS Lambda.
It is key to understand AWS Lambda and API Gateway to understand Jets conceptually. Jets maps your code to Lambda functions and API Gateway resources.
The official documentation is at Ruby on Jets.
Refer to the official docs for more info, but here's a quick intro.
Jets supports writing AWS Lambda functions with Ruby. You define them in the app/functions
folder. A function looks like this:
app/functions/simple.rb:
def lambda_handler(event:, context:)
puts "hello world"
{hello: "world"}
end
Here's the function in the Lambda console:
Though simple functions are supported by Jets, they do not 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.
A Jets controller handles a web request and renders a response. Here's an example:
app/controllers/posts_controller.rb:
class PostsController < ApplicationController
def index
# renders Lambda Proxy structure compatible with API Gateway
render json: {hello: "world", action: "index"}
end
def show
id = params[:id] # params available
# puts goes to the lambda logs
puts event # raw lambda event available
render json: {action: "show", id: id}
end
end
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.
Jets creates Lambda functions for each public method in your controller. Here they are in the Lambda console:
You connect Lambda functions to API Gateway URL endpoints with a routes file:
config/routes.rb:
Jets.application.routes.draw do
get "posts", to: "posts#index"
get "posts/new", to: "posts#new"
get "posts/:id", to: "posts#show"
post "posts", to: "posts#create"
get "posts/:id/edit", to: "posts#edit"
put "posts", to: "posts#update"
delete "posts", to: "posts#delete"
resources :comments # expands to the RESTful routes above
any "posts/hot", to: "posts#hot" # GET, POST, PUT, etc request all work
end
The routes.rb
gets translated to API Gateway resources:
Test your API Gateway endpoints with curl or postman. Note, replace the URL endpoint with the one that is created:
$ curl -s "https://quabepiu80.execute-api.us-east-1.amazonaws.com/dev/posts" | jq .
{
"hello": "world",
"action": "index"
}
A Jets job handles asynchronous background jobs performed outside of the web request/response cycle. Here's an example:
app/jobs/hard_job.rb:
class HardJob < ApplicationJob
rate "10 hours" # every 10 hours
def dig
puts "done digging"
end
cron "0 */12 * * ? *" # every 12 hours
def lift
puts "done lifting"
end
end
HardJob#dig
runs every 10 hours and HardJob#lift
runs every 12 hours. The rate
and cron
methods created CloudWatch Event Rules. Example:
You can test your application with a local server that mimics API Gateway: Jets Local Server. Once ready, deploying to AWS Lambda is a single command.
jets deploy
After deployment, you can test the Lambda functions with the AWS Lambda console or the CLI.
Here are some demos of Jets applications:
Please feel free to add your own example to the jets-examples repo.
Jets Afterburner Mode provides Rails support with little effort. This allows you to run a Rails application on AWS Lambda. Also here's a Tutorial Blog Post: Jets Afterburner: Rails Support.
For more documentation, check out the official docs: Ruby on Jets. Here's a list of useful links:
“void std::vector<T,std::allocator<_Ty>>::push_back(_Ty &&)”: 无法将参数 1 从“const _Ty”转换为“const _Ty &” robot_auto_machine_track d:\code\robot_auto_machine_track\robot_auto_machine_track\robot_six_ang
摘要: This thesis presents a study of the substructure of jets containing bhadrons with the purpose of distinguishing between "single" b-jets, where the b-quark originates at the matrix-element level of
摘要: We discuss the results of a process-oriented analysis of current profile measurements collected from 2005 through 2010 in the Gulf of Mexico by oil industry operators, who are required to measure
Magneto-Centrifugal Launching of Jets from Accretion Disks. II: Inner Disk-Driven Winds Abstract: We follow numerically the time evolution of axisymmetric outflows driven magneto-centrifugally from th
摘要: We train our network using the pre-tag data sample weighted by the Tag-Rate-Matrix to model MJ events. This choice is preferred over the use of a Monte Carlo QCD background because it allows not o
摘要: We present a search for a low-mass SM Higgs boson produced in association with a vector boson (VH) where H decays to b¯b and the vector boson decays escape detection. We are sensitive to ZH → ννb¯
摘要: The production of events with multiple high transverse momentum particles including charged leptons and jets is measured, using 1.04 fb^(1) of proton–proton collision data recorded by the ATLAS de
摘要: A search for physics beyond the Standard Model, in final states with at least one high trans- verse momentum charged lepton (electron or muon) and two additional high transverse mo- mentum leptons
May the New You are able to Jets win at least six game titles this time? Protecting finish Muhammad Wilkerson definitely considers so. "They will certainly stay positive and do a lot more issues a lot
摘要: The results of a search for supersymmetry in events with large missing transverse momentum and heavy flavour jets using an integrated luminosity corresponding to 2.05 fb-1 of pp collisions at sqrt
摘要: Events featuring high energy jets and a large amount of missing transverse energy constitute a key signature for a wide spectrum of new physics models. In this review, the results of two searches
CORTLAND, N.Y. -- Mark Sanchez knows he can't commit turnovers and keep his job. He just can't. And the 6,000 New York Jets fans who showed up Saturday night for the annual Green & White scrimmage pro
It is actually not a good week for Brett Favre. using the 28 24 loss to the Charles Johnson Authentic Jersey Green Bay Packers last Sunday night, MRI testing revealed that Favre has two fractures in h
The NFL convert has returned to Australia to endure a Brandon Gibson Black Jersey calf injury and fracture in his kicking foot after an injury settlement from the Detroit Lions. While it will be easie
www.nikemiamidolphinsstore.com/WOMENS-CAMERON-WAKE-JERSEY.html minnesota Vikings Brett Favre is predicted to unretire again and sign with the Minnesota Vikings today. The 39yearold quarterback arrived
Top head-coaching candidates With plenty of coaching vacancies to fill, demand for talent is high. Check Colombia 2014/15 Away Shirts out the hottest names, like Oregon's Chip Kelly. Iran 2014/15 Home