Module: Jets::AwsServices
- Includes:
- GlobalMemoist, StackStatus
- Included in:
- AssetTagHelper, AwsInfo, S3Bucket, Builders::CodeBuilder, Builders::ShimVars::Base, Cfn::Builders::ApiDeploymentBuilder, Cfn::Builders::ApiGatewayBuilder, Cfn::Builders::ApiResourcesBuilder, Cfn::Builders::AuthorizerBuilder, Cfn::Builders::ParentBuilder, Cfn::Ship, Cfn::TemplateSource, Cfn::Upload, Commands::Call, Commands::Call::BaseGuesser, Commands::Clean::Log, Commands::Delete, Commands::StackInfo, Commands::Url, Resource::ApiGateway::BasePath::Role, Resource::ApiGateway::RestApi::ChangeDetection, Resource::ApiGateway::RestApi::LogicalId, Resource::ApiGateway::RestApi::Routes::Change, Resource::ApiGateway::RestApi::Routes::Change::Base, Stack::Output::Lookup, TmpLoader
- Defined in:
- lib/jets/aws_services/global_memoist.rb,
lib/jets/aws_services.rb,
lib/jets/aws_services/s3_bucket.rb,
lib/jets/aws_services/stack_status.rb
Overview
We cache the clients globally to avoid re-instantiating them again after the initial Lambda cold start.
Based on: hashrocket.com/blog/posts/implementing-a-macro-in-ruby-for-memoization Except we use a global variable for the cache. So we’ll use the same client across all instances as well as across Lambda executions after the cold-start. Example:
class Foo
def s3
Aws::S3::Client.new
end
global_memoize :s3
end
foo1 = Foo.new
foo2 = Foo.new
foo1.s3
foo2.s3
A prewarmed request after a cold-start will still use the same s3 client instance since it uses the global variable $__memo_methods as the cache.
Defined Under Namespace
Modules: GlobalMemoist, StackStatus
Classes: S3Bucket
Instance Method Summary
collapse
#lookup, #stack_exists?, #stack_in_progress?
included
Instance Method Details
#apigateway ⇒ Object
18
19
20
|
# File 'lib/jets/aws_services.rb', line 18
def apigateway
Aws::APIGateway::Client.new
end
|
#aws_lambda ⇒ Object
33
34
35
|
# File 'lib/jets/aws_services.rb', line 33
def aws_lambda
Aws::Lambda::Client.new
end
|
#cfn ⇒ Object
23
24
25
|
# File 'lib/jets/aws_services.rb', line 23
def cfn
Aws::CloudFormation::Client.new
end
|
#dynamodb ⇒ Object
28
29
30
|
# File 'lib/jets/aws_services.rb', line 28
def dynamodb
Aws::DynamoDB::Client.new
end
|
#logs ⇒ Object
38
39
40
|
# File 'lib/jets/aws_services.rb', line 38
def logs
Aws::CloudWatchLogs::Client.new
end
|
#s3 ⇒ Object
43
44
45
|
# File 'lib/jets/aws_services.rb', line 43
def s3
Aws::S3::Client.new
end
|
#s3_resource ⇒ Object
48
49
50
|
# File 'lib/jets/aws_services.rb', line 48
def s3_resource
Aws::S3::Resource.new
end
|
#sns ⇒ Object
53
54
55
|
# File 'lib/jets/aws_services.rb', line 53
def sns
Aws::SNS::Client.new
end
|
#sqs ⇒ Object
58
59
60
|
# File 'lib/jets/aws_services.rb', line 58
def sqs
Aws::SQS::Client.new
end
|
#sts ⇒ Object
63
64
65
|
# File 'lib/jets/aws_services.rb', line 63
def sts
Aws::STS::Client.new
end
|