hot

package
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event added in v0.1.5

type Event struct {
	ID    string // id (optional)
	Type  string // event type (optional)
	Data  []byte // data
	Retry int    // retry (optional)
}

https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation

func (*Event) Format added in v0.1.5

func (e *Event) Format() *bytes.Buffer

type Server

type Server struct {
	Now func() time.Time // Used for testing
	// contains filtered or unexported fields
}

func New

func New(log log.Log, ps pubsub.Subscriber) *Server

New server-sent event (SSE) server

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Stream added in v0.1.5

type Stream struct {
	// contains filtered or unexported fields
}

func Dial added in v0.1.5

func Dial(log log.Log, url string) (*Stream, error)

Dial creates a server-sent event (SSE) stream. This stream has been adapted from the following minimal eventsource stream: - https://github.com/neelance/eventsource/blob/master/client/client.go Thanks Richard!

func DialWith added in v0.1.5

func DialWith(client *http.Client, log log.Log, url string) (*Stream, error)

DialWith creates a server-sent event (SSE) stream with a custom HTTP client.

func (*Stream) Close added in v0.1.5

func (s *Stream) Close() error

func (*Stream) Next added in v0.1.5

func (s *Stream) Next(ctx context.Context) (*Event, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL