Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSourceClosed = errors.New("source closed")
Functions ¶
This section is empty.
Types ¶
type BadResponseError ¶
func (BadResponseError) Error ¶
func (err BadResponseError) Error() string
type EventSource ¶
type EventSource struct {
// contains filtered or unexported fields
}
EventSource behaves like the EventSource interface from the Server-Sent Events spec implemented in many browsers. See http://www.w3.org/TR/eventsource/#the-eventsource-interface for details.
To use, optionally call Connect(), and then call Next(). If Next() is called prior to Connect(), it will connect for you.
Next() is often called asynchronously in a loop so that the event source can be closed. Next() will block on reading from the server.
If Close() is called while reading an event, Next() will return early, and subsequent calls to Next() will return early. To read new events, Connect() must be called.
If an EOF is received, Next() returns io.EOF, and subsequent calls to Next() will return early. To read new events, Connect() must be called.
func NewEventSource ¶
func (*EventSource) Close ¶
func (source *EventSource) Close() error
func (*EventSource) Next ¶
func (source *EventSource) Next() (Event, error)
type ReadCloser ¶
type ReadCloser struct {
// contains filtered or unexported fields
}
func NewReadCloser ¶
func NewReadCloser(source io.ReadCloser) *ReadCloser
func (*ReadCloser) Close ¶
func (rc *ReadCloser) Close() error
func (*ReadCloser) Next ¶
func (rc *ReadCloser) Next() (Event, error)