Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Subscribe(stream string, handler func(msg *Event)) error
- func (c *Client) SubscribeChan(stream string, ch chan *Event) (io.Closer, error)
- func (c *Client) SubscribeChanRaw(ch chan *Event) (io.Closer, error)
- func (c *Client) SubscribeRaw(handler func(msg *Event)) error
- func (c *Client) Unsubscribe(ch chan *Event)
- type Event
- type EventLog
- type EventStreamReader
- type Server
- type Stream
- type StreamRegistration
- type Subscriber
Constants ¶
const DefaultBufferSize = 1024
DefaultBufferSize size of the queue that holds the streams messages.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { URL string Connection *http.Client Retry time.Time Headers map[string]string EncodingBase64 bool EventID string // contains filtered or unexported fields }
Client handles an incoming server stream
func NewClientWithoutRetry ¶
NewClient creates a new client without retry logic
func (*Client) SubscribeChan ¶
SubscribeChan sends all events to the provided channel
func (*Client) SubscribeChanRaw ¶
SubscribeChanRaw sends all events to the provided channel
func (*Client) SubscribeRaw ¶
SubscribeRaw to an sse endpoint
func (*Client) Unsubscribe ¶
Unsubscribe unsubscribes a channel
type EventStreamReader ¶
type EventStreamReader struct {
// contains filtered or unexported fields
}
EventStreamReader scans an io.Reader looking for EventStream messages.
func NewEventStreamReader ¶
func NewEventStreamReader(eventStream io.Reader) *EventStreamReader
NewEventStreamReader creates an instance of EventStreamReader.
func (*EventStreamReader) ReadEvent ¶
func (self *EventStreamReader) ReadEvent() ([]byte, error)
ReadEvent scans the EventStream for events.
type Server ¶
type Server struct { // Specifies the size of the message buffer for each stream BufferSize int // Enables creation of a stream when a client connects AutoStream bool // Enables automatic replay for each new subscriber that connects AutoReplay bool EncodeBase64 bool Streams map[string]*Stream // contains filtered or unexported fields }
Server Is our main struct
func (*Server) Close ¶
func (s *Server) Close()
Close shuts down the server, closes all of the streams and connections
func (*Server) CreateStream ¶
CreateStream will create a new stream and register it
func (*Server) HTTPHandler ¶
func (s *Server) HTTPHandler(w http.ResponseWriter, r *http.Request)
HTTPHandler serves new connections with events for a given stream ...
func (*Server) RemoveStream ¶
RemoveStream will remove a stream
func (*Server) StreamExists ¶
StreamExists checks whether a stream by a given id exists
type Stream ¶
type Stream struct { // Enables replaying of eventlog to newly added subscribers AutoReplay bool Eventlog EventLog // contains filtered or unexported fields }
Stream ...
type StreamRegistration ¶
type StreamRegistration struct {
// contains filtered or unexported fields
}
StreamRegistration ...
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber ...