/server_sent_event_stage

A GenStage producer which parses the ServerSentEvent protocol

Primary LanguageElixirMIT LicenseMIT

ServerSentEventStage

A GenStage producer which parses the ServerSentEvent protocol.

Build Status codecov

Installation

def deps do
  [
    {:server_sent_event_stage, "~> 0.1.0"}
  ]
end

Use

start_link/1 starts the server:

iex> {:ok, pid} = ServerSentEventStage.start_link(url: "https://...")
iex> Enum.take(GenStage.stream([pid]), 2)
[%ServerSentEventStage.Event{}, %ServerSentEventStage.Event{}]

More likely, you'll want to add it as a part of a supervision tree:

# in a Supervisor.init callback
children = [
    {ServerSentEventStage, url: "https://..."},
    ...
]

Documentation

Full documentation is available on HexDocs.

License

server_sent_event_stage is licensed under the MIT license.