sse: Index | Files

package sse

import ""


Package Files

options.go reader.go serialize.go server.go

type ConfigFunc Uses

type ConfigFunc func(*Server)

ConfigFunc is a function used to initialize a new server.

func WithBufferSize Uses

func WithBufferSize(bufferSize int) ConfigFunc

WithBufferSize sets the internal buffer for each connected client. This buffer counts distinct events. The default is 100.

type Server Uses

type Server struct {
    ServeHTTP http.HandlerFunc
    // contains filtered or unexported fields

Server is an http.Handler that will fanout Server-Sent Events to all connected clients.

func NewServer Uses

func NewServer(events <-chan interface{}, configs ...ConfigFunc) *Server

NewServer creates a new server with the given event channel. The server returned by this function has not yet started.

func (*Server) Handler Uses

func (s *Server) Handler(r *http.Request) response.Response

Handler converts an HTTP request into a streaming response. This can be used with libraries that utilize efritz/response. Alternatively, the ServeHTTP member on the Server struct is a http.HandlerFunc that can be served directly.

func (*Server) Start Uses

func (s *Server) Start() error

Start will begin serializing events that come in on the event channel and sending the payload to each registered client. This method will block until the event channel has closed.

Package sse imports 7 packages (graph) and is imported by 1 packages. Updated 2019-01-22. Refresh now. Tools for package owners.