ekster: p83.nl/go/ekster/pkg/sse Index | Files

package sse

import "p83.nl/go/ekster/pkg/sse"


Package Files


func Reader Uses

func Reader(body io.ReadCloser, ch MessageChan) error

Reader returns a channel that contains parsed SSE messages.

func WriteMessages Uses

func WriteMessages(w http.ResponseWriter, messageChan chan Message) error

WriteMessages writes SSE formatted messages to the writer

type Broker Uses

type Broker struct {
    // Events are pushed to this channel by the main UDP daemon
    Notifier chan Message
    // contains filtered or unexported fields

Broker holds open client connections, listens for incoming events on its Notifier channel and broadcast event data to all registered connections

func NewBroker Uses

func NewBroker() (broker *Broker)

NewBroker creates a Broker.

func (*Broker) CloseClient Uses

func (broker *Broker) CloseClient(ch MessageChan)

CloseClient closes the client channel

type Message Uses

type Message struct {
    Event  string
    Data   string
    Object interface{}

Message is a message.

type MessageChan Uses

type MessageChan chan Message

A MessageChan is a channel of channels Each connection sends a channel of bytes to a global MessageChan The main broker listen() loop listens on new connections on MessageChan New event messages are broadcast to all registered connection channels

func StartConnection Uses

func StartConnection(broker *Broker) (MessageChan, error)

StartConnection starts a SSE connection, based on an existing HTTP connection.

Package sse imports 9 packages (graph) and is imported by 4 packages. Updated 2020-11-24. Refresh now. Tools for package owners.