Class: Jets::CLI::Concurrency::Info
Instance Attribute Summary
Attributes inherited from Base
#options
Instance Method Summary
collapse
#lambda_functions
Methods inherited from Base
#account_limit, #initialize
#truthy?
#check_deployed!, #check_workers!, #workers_deployed?
Methods inherited from Base
#initialize, #paginate, #paging_params, rescue_api_error
#log
#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2
#output_value, #stack_exists?
included, #reset_cache!
Methods included from Api
#api, #api_key
Instance Method Details
#account_limit_info ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/jets/cli/concurrency/info.rb', line 70
def account_limit_info
message = <<~EOL
Account Limits
Concurrent Executions: #{account_limit.concurrent_executions}
Unreserved Concurrent Executions: #{account_limit.unreserved_concurrent_executions}
EOL
if has_unreserved?
message << "Functions with no reserved limit scale to Unreserved Concurrent Executions\n"
end
warn message
end
|
#concurrency_info ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/jets/cli/concurrency/info.rb', line 10
def concurrency_info
warn "Concurrency for #{Jets.project.namespace}"
presenter = CliFormat::Presenter.new(@options)
presenter.empty_message = "No Lambda Functions found"
presenter. = ["Function"]
presenter. << "Reserved" if has_reserved?
presenter. << "Provisioned" if has_provisioned?
concurrency_settings.each do |function_name, concurrency_info|
row = []
row << function_name.gsub("#{Jets.project.namespace}-", "")
if has_reserved?
reserved = concurrency_info[:reserved_concurrency]
@reserved_concurrency_total ||= 0
@reserved_concurrency_total += reserved.to_i
row << reserved
end
if has_provisioned?
provisioned = concurrency_info[:provisioned_concurrency]
@provisioned_concurrency_total ||= 0
@provisioned_concurrency_total += provisioned.to_i
row << provisioned
end
presenter.rows << row
end
unless presenter.rows.empty?
totals = ["total"]
totals << @reserved_concurrency_total if @reserved_concurrency_total
totals << @provisioned_concurrency_total if @provisioned_concurrency_total
presenter.rows << totals
end
presenter.show
end
|
#concurrency_settings ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/jets/cli/concurrency/info.rb', line 46
def concurrency_settings
concurrency_settings = {}
lambda_functions.each do |lambda_function|
concurrency_info = {
reserved_concurrency: lambda_function.reserved_concurrency,
provisioned_concurrency: lambda_function.provisioned_concurrency
}
concurrency_info.delete_if { |_, v| v.nil? }
concurrency_settings[lambda_function.name] = concurrency_info
end
concurrency_settings
end
|
#has_provisioned? ⇒ Boolean
66
67
68
|
# File 'lib/jets/cli/concurrency/info.rb', line 66
def has_provisioned?
concurrency_settings.any? { |_, info| info.key?(:provisioned_concurrency) }
end
|
#has_reserved? ⇒ Boolean
62
63
64
|
# File 'lib/jets/cli/concurrency/info.rb', line 62
def has_reserved?
concurrency_settings.any? { |_, info| info.key?(:reserved_concurrency) }
end
|
#has_unreserved? ⇒ Boolean
82
83
84
|
# File 'lib/jets/cli/concurrency/info.rb', line 82
def has_unreserved?
concurrency_settings.any? { |_, info| !info.key?(:reserved_concurrency) }
end
|
#run ⇒ Object
5
6
7
8
|
# File 'lib/jets/cli/concurrency/info.rb', line 5
def run
concurrency_info
account_limit_info
end
|