Module: MovableInk::AWS::ElastiCache
- Included in:
- MovableInk::AWS
- Defined in:
- lib/movable_ink/aws/elasticache.rb
Instance Method Summary collapse
- #all_elasticache_replicas(name) ⇒ Object
- #elasticache(region: my_region) ⇒ Object
- #elasticache_primary(name) ⇒ Object
- #elasticache_replica_in_my_az(name) ⇒ Object
- #elasticache_replicas(name) ⇒ Object
- #node_group_members(name) ⇒ Object
- #node_group_members_in_my_az(name) ⇒ Object
- #replication_group(name) ⇒ Object
Instance Method Details
#all_elasticache_replicas(name) ⇒ Object
45 46 47 48 |
# File 'lib/movable_ink/aws/elasticache.rb', line 45 def all_elasticache_replicas(name) elasticache_replicas(name) .map { |replica| replica.read_endpoint.address } end |
#elasticache(region: my_region) ⇒ Object
6 7 8 9 |
# File 'lib/movable_ink/aws/elasticache.rb', line 6 def elasticache(region: my_region) @elasticache_client ||= {} @elasticache_client[region] ||= Aws::ElastiCache::Client.new(region: region) end |
#elasticache_primary(name) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/movable_ink/aws/elasticache.rb', line 20 def elasticache_primary(name) replication_group(name) .node_groups .first .primary_endpoint .address end |
#elasticache_replica_in_my_az(name) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/movable_ink/aws/elasticache.rb', line 50 def elasticache_replica_in_my_az(name) members = node_group_members_in_my_az(name) begin members .select{|ng| ng.current_role == 'replica'} .first .read_endpoint .address rescue NoMethodError members .first .read_endpoint .address end end |
#elasticache_replicas(name) ⇒ Object
40 41 42 43 |
# File 'lib/movable_ink/aws/elasticache.rb', line 40 def elasticache_replicas(name) node_group_members(name) .select { |ng| ng.current_role == 'replica' } end |
#node_group_members(name) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/movable_ink/aws/elasticache.rb', line 28 def node_group_members(name) replication_group(name) .node_groups .first .node_group_members end |
#node_group_members_in_my_az(name) ⇒ Object
35 36 37 38 |
# File 'lib/movable_ink/aws/elasticache.rb', line 35 def node_group_members_in_my_az(name) node_group_members(name) .select { |ng| ng.preferred_availability_zone == availability_zone } end |
#replication_group(name) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/movable_ink/aws/elasticache.rb', line 11 def replication_group(name) run_with_backoff do @replication_group ||= elasticache .describe_replication_groups(replication_group_id: name) .replication_groups .first end end |