Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stream ¶
type Stream struct {
// Events emits the events received by the stream
Events chan StreamEvent
Ready chan bool
// Errors emits any errors encountered while reading events from the stream.
// It's mainly for informative purposes - the client isn't required to take any
// action when an error is encountered. The stream will always attempt to continue,
// even if that involves reconnecting to the server.
Errors chan error
// Logger is a logger that, when set, will be used for logging debug messages
Logger *log.Logger
// contains filtered or unexported fields
}
Stream handles a connection for receiving Server Sent Events. It will try and reconnect if the connection is lost, respecting both received retry delays and event id's.
func Subscribe ¶
Subscribe to the Events emitted from the specified url. If lastEventId is non-empty it will be sent to the server in case it can replay missed events.
func SubscribeWith ¶
SubscribeWith takes a http client and request providing customization over both headers and control over the http client settings (timeouts, tls, etc)
func SubscribeWithRequest ¶
SubscribeWithRequest will take an http.Request to setup the stream, allowing custom headers to be specified, authentication to be configured, etc.
type StreamEvent ¶
type StreamEvent interface {
// Id is an identifier that can be used to allow a client to replay
// missed Events by returning the Last-Event-Id header.
// Return empty string if not required.
Id() string
// The name of the event. Return empty string if not required.
Event() string
// The payload of the event.
Data() string
Retry() int64
}
type SubscriptionError ¶
func (SubscriptionError) Error ¶
func (e SubscriptionError) Error() string
Click to show internal directories.
Click to hide internal directories.