class Awful::Kinesis

Constants

COLORS

Public Instance Methods

color(string) click to toggle source
# File lib/awful/kinesis.rb, line 21
def color(string)
  set_color(string, COLORS.fetch(string.to_sym, :yellow))
end
dump(name) click to toggle source
# File lib/awful/kinesis.rb, line 59
def dump(name)
  kinesis.describe_stream(stream_name: name).stream_description.output do |stream|
    puts YAML.dump(stringify_keys(stream.to_hash))
  end
end
kinesis() click to toggle source
# File lib/awful/kinesis.rb, line 17
def kinesis
  @_kinesis ||= Aws::Kinesis::Client.new
end
ls() click to toggle source
# File lib/awful/kinesis.rb, line 42
def ls
  paginate_streams(:stream_names) do |start|
    kinesis.list_streams(exclusive_start_stream_name: start)
  end.output do |streams|
    if options[:long]
      print_table streams.map { |name|
        s = kinesis.describe_stream(stream_name: name).stream_description
        op = s.has_more_shards ? '>' : ''
        [s.stream_name, op + s.shards.count.to_s, color(s.stream_status), s.encryption_type, s.retention_period_hours.to_s + 'h', s.stream_creation_timestamp]
      }
    else
      puts streams
    end
  end
end
paginate_streams(thing) { |token| ... } click to toggle source

special-case paginator for streams

# File lib/awful/kinesis.rb, line 26
def paginate_streams(thing)
  token = nil
  things = []
  loop do
    resp = yield(token)
    items = resp.send(thing)
    things += items
    token = items.last
    break unless resp.has_more_streams
  end
  things
end