Module: Jets::AwsServices
- Includes:
- GlobalMemoist, StackStatus
- Included in:
- AssetTagHelper, AwsInfo, S3Bucket, Builders::CodeBuilder, Builders::ShimVars::Base, Cfn::Builders::ApiDeploymentBuilder, Cfn::Builders::ApiGatewayBuilder, Cfn::Builders::ParentBuilder, Cfn::Ship, Cfn::Status, Cfn::Upload, Commands::Call, 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::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
16
17
18
|
# File 'lib/jets/aws_services.rb', line 16
def apigateway
Aws::APIGateway::Client.new
end
|
#aws_lambda ⇒ Object
31
32
33
|
# File 'lib/jets/aws_services.rb', line 31
def aws_lambda
Aws::Lambda::Client.new
end
|
#cfn ⇒ Object
21
22
23
|
# File 'lib/jets/aws_services.rb', line 21
def cfn
Aws::CloudFormation::Client.new
end
|
#dynamodb ⇒ Object
26
27
28
|
# File 'lib/jets/aws_services.rb', line 26
def dynamodb
Aws::DynamoDB::Client.new
end
|
#logs ⇒ Object
36
37
38
|
# File 'lib/jets/aws_services.rb', line 36
def logs
Aws::CloudWatchLogs::Client.new
end
|
#s3 ⇒ Object
41
42
43
|
# File 'lib/jets/aws_services.rb', line 41
def s3
Aws::S3::Client.new
end
|
#s3_resource ⇒ Object
46
47
48
|
# File 'lib/jets/aws_services.rb', line 46
def s3_resource
Aws::S3::Resource.new
end
|
#sns ⇒ Object
51
52
53
|
# File 'lib/jets/aws_services.rb', line 51
def sns
Aws::SNS::Client.new
end
|
#sqs ⇒ Object
56
57
58
|
# File 'lib/jets/aws_services.rb', line 56
def sqs
Aws::SQS::Client.new
end
|
#sts ⇒ Object
61
62
63
|
# File 'lib/jets/aws_services.rb', line 61
def sts
Aws::STS::Client.new
end
|