Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client works like a regular http.Client, with an additional Subscribe method for connecting to Server Sent Event streams.
type ClientOption ¶
type ClientOption func(*clientOptions)
A ClientOption is a function that can be passed as an argument to Client.Subscribe to alter its behavior.
func AutoRetry ¶
func AutoRetry(retry bool) ClientOption
AutoRetry takes a bool that flags whether the client should automatically reconnect on errors. The ClientOption that you get back should be passed into Client.Subscribe.
func LastEventID ¶
func LastEventID(id string) ClientOption
LastEventID takes the ID that should be passed to the server to start the stream where you left off. The ClientOption that you get back should be passed into Client.Subscribe.
type EventWriter ¶
type EventWriter struct {
// contains filtered or unexported fields
}
EventWriter is a helper for writing events to an http.ResponseWriter stream.
func NewEventWriter ¶
func NewEventWriter(w http.ResponseWriter) *EventWriter
NewEventWriter returns a new EventWriter.
func (*EventWriter) Write ¶
func (evw *EventWriter) Write(e Event) error
Write takes an Event, serializes the Event to bytes, and writes them out to the http stream. If the stream is also an http.Flusher, then it will also flush the bytes out so the event will be sent over the wire immediately. It automatically sets the Content-Type header to text/event-stream.