Class: Conjur::Audit::Follower

Inherits:
Object
  • Object
show all
Defined in:
lib/conjur/audit/follower.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Follower

Initialize a follower that will fetch more records by calling :block: with options to merge into the options passed to the audit method (eg, limit, offset)



7
8
9
# File 'lib/conjur/audit/follower.rb', line 7

def initialize &block
  @fetch = block
end

Instance Method Details

#follow(&block) ⇒ Object

Follow audit events, yielding non-empty arrays of new events to :block: as they are fetched.



14
15
16
17
18
19
20
21
22
# File 'lib/conjur/audit/follower.rb', line 14

def follow &block
  @last_event_id = nil
  
  loop do
    new_events = fetch_new_events
    block.call new_events unless new_events.empty?
    sleep 1 if new_events.empty?
  end
end