Class: ElasticGraph::IndexerAutoscalerLambda

Inherits:
Object
  • Object
show all
Extended by:
Support::FromYamlFile
Defined in:
lib/elastic_graph/indexer_autoscaler_lambda.rb,
lib/elastic_graph/indexer_autoscaler_lambda/details_logger.rb,
lib/elastic_graph/indexer_autoscaler_lambda/lambda_function.rb,
lib/elastic_graph/indexer_autoscaler_lambda/concurrency_scaler.rb

Defined Under Namespace

Classes: ConcurrencyScaler, DetailsLogger, LambdaFunction

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datastore_core:, sqs_client: nil, lambda_client: nil, cloudwatch_client: nil) ⇒ IndexerAutoscalerLambda

Returns a new instance of IndexerAutoscalerLambda.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/elastic_graph/indexer_autoscaler_lambda.rb', line 32

def initialize(
  datastore_core:,
  sqs_client: nil,
  lambda_client: nil,
  cloudwatch_client: nil
)
  @datastore_core = datastore_core
  @sqs_client = sqs_client
  @lambda_client = lambda_client
  @cloudwatch_client = cloudwatch_client
end

Instance Attribute Details

#datastore_coreObject (readonly)

Returns the value of attribute datastore_core.



30
31
32
# File 'lib/elastic_graph/indexer_autoscaler_lambda.rb', line 30

def datastore_core
  @datastore_core
end

Class Method Details

.from_envObject

Builds an ‘ElasticGraph::IndexerAutoscalerLambda` instance from our lambda ENV vars.



19
20
21
# File 'lib/elastic_graph/indexer_autoscaler_lambda.rb', line 19

def self.from_env
  LambdaSupport.build_from_env(self)
end

.from_parsed_yaml(parsed_yaml, &datastore_client_customization_block) ⇒ Object

A factory method that builds a IndexerAutoscalerLambda instance from the given parsed YAML config. ‘from_yaml_file(file_name, &block)` is also available (via `Support::FromYamlFile`).



25
26
27
# File 'lib/elastic_graph/indexer_autoscaler_lambda.rb', line 25

def self.from_parsed_yaml(parsed_yaml, &datastore_client_customization_block)
  new(datastore_core: DatastoreCore.from_parsed_yaml(parsed_yaml, &datastore_client_customization_block))
end

Instance Method Details

#cloudwatch_clientObject



58
59
60
61
62
63
# File 'lib/elastic_graph/indexer_autoscaler_lambda.rb', line 58

def cloudwatch_client
  @cloudwatch_client ||= begin
    require "aws-sdk-cloudwatch"
    Aws::CloudWatch::Client.new
  end
end

#concurrency_scalerObject



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/elastic_graph/indexer_autoscaler_lambda.rb', line 65

def concurrency_scaler
  @concurrency_scaler ||= begin
    require "elastic_graph/indexer_autoscaler_lambda/concurrency_scaler"
    ConcurrencyScaler.new(
      datastore_core: @datastore_core,
      sqs_client: sqs_client,
      lambda_client: lambda_client,
      cloudwatch_client: cloudwatch_client
    )
  end
end

#lambda_clientObject



51
52
53
54
55
56
# File 'lib/elastic_graph/indexer_autoscaler_lambda.rb', line 51

def lambda_client
  @lambda_client ||= begin
    require "aws-sdk-lambda"
    Aws::Lambda::Client.new
  end
end

#sqs_clientObject



44
45
46
47
48
49
# File 'lib/elastic_graph/indexer_autoscaler_lambda.rb', line 44

def sqs_client
  @sqs_client ||= begin
    require "aws-sdk-sqs"
    Aws::SQS::Client.new
  end
end