Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotIdle = errors.New("sse client already running")
ErrNotIdle is the error tor eturn when Do() gets called on an already running client.
var ErrReadingStream = errors.New("sse channel closed")
ErrReadingStream is the error to return when channel event channel is closed because of an error reading the stream
var ErrTimeout = errors.New("timeout exceeeded")
ErrTimeout is the error to return when keepalive timeout is exceeded
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client struct
type ErrConnectionFailed ¶
type ErrConnectionFailed struct {
// contains filtered or unexported fields
}
ErrConnectionFailed contains a nested error
func (*ErrConnectionFailed) Error ¶
func (e *ErrConnectionFailed) Error() string
Error returns the error as a string
func (*ErrConnectionFailed) Unwrap ¶
func (e *ErrConnectionFailed) Unwrap() error
Unwrap returns the wrapped error
type EventBuilder ¶
type EventBuilder interface { AddLine(string) Build() *RawEventImpl }
EventBuilder interface
type EventBuilderImpl ¶
type EventBuilderImpl struct {
// contains filtered or unexported fields
}
EventBuilderImpl implenets the EventBuilder interface. Used to parse incoming event lines
func NewEventBuilder ¶
func NewEventBuilder() *EventBuilderImpl
NewEventBuilder constructs a new event builder
func (*EventBuilderImpl) AddLine ¶
func (b *EventBuilderImpl) AddLine(line string)
AddLine adds a new line belonging to the currently being processed event
func (*EventBuilderImpl) Build ¶
func (b *EventBuilderImpl) Build() *RawEventImpl
Build processes all the added lines and builds the event
type RawEvent ¶
type RawEvent interface { ID() string Event() string Data() string Retry() int64 IsError() bool IsEmpty() bool }
RawEvent interface contains the methods that expose the incoming SSE properties
type RawEventImpl ¶
type RawEventImpl struct {
// contains filtered or unexported fields
}
RawEventImpl represents an incoming SSE event
func (*RawEventImpl) Data ¶
func (r *RawEventImpl) Data() string
Data returns the event associated data
func (*RawEventImpl) IsEmpty ¶
func (r *RawEventImpl) IsEmpty() bool
IsEmpty returns true if the event contains no id, event type and data
func (*RawEventImpl) IsError ¶
func (r *RawEventImpl) IsError() bool
IsError returns true if the message is an error
func (*RawEventImpl) Retry ¶
func (r *RawEventImpl) Retry() int64
Retry returns the expected retry time