Add basic Event Stream struct

master
Milton Mazzarri 2017-04-19 16:33:23 -05:00
parent 0968e947ae
commit cf4b60223e
No known key found for this signature in database
GPG Key ID: CF3DE6E356E17F1E
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
defmodule Hunter.EventStream do
@moduledoc """
Event stream is a simple stream of text data encoded using UTF-8
Messages in the event stream are separated by a pair of newline characters. A
colon as the first character of a line is in essence a comment, and is ignored.
## Fields
* `id` - event id
* `event` - the event's type
* `data` - data field for the message, this data is JSON-encoded
* `retry` - re-connection time to use when attempting to send the event.
See: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format
"""
@type t :: %__MODULE__{
id: String.t,
event: String.t,
data: String.t,
retry: non_neg_integer
}
defstruct [:id, :event, :data, :retry]
end