Help us shape the future of Go! Take the 2026 Go Developer Survey

sse

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

sse

Server sent events publisher in Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	Type() string
	Data() []byte
}

func JSONEvent

func JSONEvent(kind string, data any) (Event, error)

func NewEvent

func NewEvent(kind string, data []byte) Event

type EventServer

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

func NewEventServer

func NewEventServer() *EventServer

func (*EventServer) Broadcast

func (e *EventServer) Broadcast(name string, event Event) error

func (*EventServer) Create

func (e *EventServer) Create(name string)

func (*EventServer) ServeHTTP

func (e *EventServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Subscriber

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

func NewSubscriber

func NewSubscriber() Subscriber

func (Subscriber) Close

func (s Subscriber) Close()

func (Subscriber) Push

func (s Subscriber) Push(event Event) error

func (Subscriber) WriteEvents

func (s Subscriber) WriteEvents(w http.ResponseWriter) error

type Topic

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

func NewTopic

func NewTopic(backlog int) *Topic

func (*Topic) Broadcast

func (t *Topic) Broadcast(event Event) error

func (*Topic) Subscribe

func (t *Topic) Subscribe(sub Subscriber)

func (*Topic) Unsubscribe

func (t *Topic) Unsubscribe(ctx context.Context, sub Subscriber)

type Topics

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

func NewTopics

func NewTopics() *Topics

func (*Topics) Create

func (t *Topics) Create(name string) *Topic

Jump to

Keyboard shortcuts

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