Class: RedfishClient::EventListener

Inherits:
Object
  • Object
show all
Defined in:
lib/redfish_client/event_listener.rb

Overview

EventListener class can be used to stream events from Redfish service. It is a thin wrapper around SSE listener that does the dirty work of splitting each event into its EventRecords and reporting them as separate events.

Instance Method Summary collapse

Constructor Details

#initialize(sse_client) ⇒ EventListener

Create new EventListener instance.

Parameters:

  • sse_client (ServerSentEvents::Client)

    SSE client



15
16
17
# File 'lib/redfish_client/event_listener.rb', line 15

def initialize(sse_client)
  @sse_client = sse_client
end

Instance Method Details

#listenObject

Stream events from redfish service.

Events that this method yields are actually EventRecords, extracted from the actual Redfish Event.



23
24
25
26
27
# File 'lib/redfish_client/event_listener.rb', line 23

def listen
  @sse_client.listen do |event|
    split_event_into_records(event).each { |r| yield(r) }
  end
end