Class: EndpointSecurity::Recorder

Inherits:
Object
  • Object
show all
Defined in:
lib/endpoint_security/recorder.rb

Overview

Writes subscribed events as newline-delimited JSON.

Instance Method Summary collapse

Constructor Details

#initialize(events:, out: $stdout, **client_options) ⇒ Recorder

Returns a new instance of Recorder.

Parameters:

  • events (Array<Symbol>) —

    events to record

  • out (IO) (defaults to: $stdout) —

    destination for JSON lines



10
11
12
13
14
# File 'lib/endpoint_security/recorder.rb', line 10

def initialize(events:, out: $stdout, **client_options)
  @events = events
  @out = out
  @client_options = client_options
end

Instance Method Details

#run ⇒ Client

Starts recording and blocks until the client stops.

Returns:



18
19
20
21
22
23
24
# File 'lib/endpoint_security/recorder.rb', line 18

def run
  Client.open(**@client_options) do |client|
    client.subscribe(@events)
    @events.each { |event| client.on(event) { |message| @out.puts(JSON.generate(message.to_h)) } }
    client.run
  end
end