sse

package
v0.0.0-...-1267af6 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Address to listen on (e.g. ":8080")
	Address string
	// Path for SSE events endpoint (e.g. "/events")
	EventsPath string
	// Path for JSON-RPC endpoint (e.g. "/rpc")
	RPCPath string
	// Optional logger
	Logger Logger
}

Config holds the configuration for the SSE transport

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger interface for transport logging

type Transport

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

Transport implements a server transport using Server-Sent Events (SSE)

func NewTransport

func NewTransport(s server.Server, config *Config) *Transport

NewTransport creates a new SSE transport

func (*Transport) GetHandler

func (t *Transport) GetHandler() http.Handler

GetHandler returns the HTTP handler for the transport

func (*Transport) Publish

func (t *Transport) Publish(eventType string, data interface{}) error

Publish publishes an event to all connected clients

func (*Transport) Start

func (t *Transport) Start() error

Start starts the transport

func (*Transport) StartAsync

func (t *Transport) StartAsync() error

Start starts the transport in a goroutine

func (*Transport) Stop

func (t *Transport) Stop() error

Stop stops the transport

Jump to

Keyboard shortcuts

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